Skip to content

Commit 397f93b

Browse files
committed
Prevent exception from being serialized in ErrorInfo
The wrong @decorator was put in the wrong place to mark the throwable fieldd as transient, now this is fixed and the exception is not serialized. So if a non-serializable throwable is passed, that's not an issue, since it's not going to be serialized. The need for EnsureExceptionSerializable is also gone.
1 parent 09d137f commit 397f93b

7 files changed

Lines changed: 19 additions & 123 deletions

File tree

app/src/main/java/org/schabi/newpipe/error/AcraReportSender.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public void send(@NonNull final Context context, @NonNull final CrashReportData
3838
UserAction.UI_ERROR,
3939
ErrorInfo.SERVICE_NONE,
4040
"ACRA report",
41-
R.string.app_ui_crash,
42-
null));
41+
R.string.app_ui_crash));
4342
}
4443
}

app/src/main/java/org/schabi/newpipe/error/EnsureExceptionSerializable.java

Lines changed: 0 additions & 103 deletions
This file was deleted.

app/src/main/java/org/schabi/newpipe/error/ErrorInfo.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.schabi.newpipe.error
22

33
import android.os.Parcelable
44
import androidx.annotation.StringRes
5+
import kotlinx.parcelize.IgnoredOnParcel
56
import kotlinx.parcelize.Parcelize
67
import org.schabi.newpipe.R
78
import org.schabi.newpipe.extractor.Info
@@ -21,11 +22,14 @@ class ErrorInfo(
2122
val userAction: UserAction,
2223
val serviceName: String,
2324
val request: String,
24-
val messageStringId: Int,
25-
@Transient // no need to store throwable, all data for report is in other variables
26-
var throwable: Throwable? = null
25+
val messageStringId: Int
2726
) : Parcelable {
2827

28+
// no need to store throwable, all data for report is in other variables
29+
// also, the throwable might not be serializable, see TeamNewPipe/NewPipe#7302
30+
@IgnoredOnParcel
31+
var throwable: Throwable? = null
32+
2933
private constructor(
3034
throwable: Throwable,
3135
userAction: UserAction,
@@ -36,9 +40,10 @@ class ErrorInfo(
3640
userAction,
3741
serviceName,
3842
request,
39-
getMessageStringId(throwable, userAction),
40-
throwable
41-
)
43+
getMessageStringId(throwable, userAction)
44+
) {
45+
this.throwable = throwable
46+
}
4247

4348
private constructor(
4449
throwable: List<Throwable>,
@@ -50,9 +55,10 @@ class ErrorInfo(
5055
userAction,
5156
serviceName,
5257
request,
53-
getMessageStringId(throwable.firstOrNull(), userAction),
54-
throwable.firstOrNull()
55-
)
58+
getMessageStringId(throwable.firstOrNull(), userAction)
59+
) {
60+
this.throwable = throwable.firstOrNull()
61+
}
5662

5763
// constructors with single throwable
5864
constructor(throwable: Throwable, userAction: UserAction, request: String) :

app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ class ErrorUtil {
2020

2121
/**
2222
* Reports a new error by starting a new activity.
23-
* <br></br>
24-
* Ensure that the data within errorInfo is serializable otherwise
25-
* an exception will be thrown!<br></br>
26-
* [EnsureExceptionSerializable] might help.
2723
*
2824
* @param context
2925
* @param errorInfo

app/src/main/java/org/schabi/newpipe/local/subscription/SubscriptionsImportFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ public void onCreate(final Bundle savedInstanceState) {
9090
new ErrorInfo(new String[]{}, UserAction.SUBSCRIPTION_IMPORT_EXPORT,
9191
NewPipe.getNameOfService(currentServiceId),
9292
"Service does not support importing subscriptions",
93-
R.string.general_error,
94-
null));
93+
R.string.general_error));
9594
activity.finish();
9695
}
9796
}

app/src/main/java/org/schabi/newpipe/player/playererror/PlayerErrorHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.google.android.exoplayer2.ExoPlaybackException;
1313

1414
import org.schabi.newpipe.R;
15-
import org.schabi.newpipe.error.EnsureExceptionSerializable;
1615
import org.schabi.newpipe.error.ErrorInfo;
1716
import org.schabi.newpipe.error.ErrorUtil;
1817
import org.schabi.newpipe.error.UserAction;
@@ -70,7 +69,7 @@ private void reportError(@NonNull final ExoPlaybackException exception,
7069
ErrorUtil.createNotification(
7170
context,
7271
new ErrorInfo(
73-
EnsureExceptionSerializable.ensureSerializable(exception),
72+
exception,
7473
UserAction.PLAY_STREAM,
7574
"Player error[type=" + exception.type + "] occurred while playing: "
7675
+ info.getUrl(),

app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ private void showError(DownloadMission mission, UserAction action, @StringRes in
583583

584584
ErrorUtil.createNotification(mContext,
585585
new ErrorInfo(ErrorInfo.Companion.throwableToStringList(mission.errObject), action,
586-
service, request.toString(), reason, null));
586+
service, request.toString(), reason));
587587
}
588588

589589
public void clearFinishedDownloads(boolean delete) {

0 commit comments

Comments
 (0)