-
Notifications
You must be signed in to change notification settings - Fork 7.6k
1.x: Do not hide original exception with RxJavaHooks.enableAssemblyTracking() #4213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
artem-zinnatullin
wants to merge
1
commit into
ReactiveX:1.x
from
artem-zinnatullin:az/1.x/fix-enableAssemblyTracking
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
52 changes: 0 additions & 52 deletions
52
src/main/java/rx/exceptions/AssemblyStackTraceException.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,10 @@ | |
*/ | ||
package rx.internal.operators; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import rx.Observable.OnSubscribe; | ||
import rx.Subscriber; | ||
import rx.exceptions.AssemblyStackTraceException; | ||
|
||
/** | ||
* Captures the current stack when it is instantiated, makes | ||
|
@@ -30,7 +31,7 @@ public final class OnSubscribeOnAssembly<T> implements OnSubscribe<T> { | |
|
||
final OnSubscribe<T> source; | ||
|
||
final String stacktrace; | ||
final StackTraceElement[] assemblyStacktrace; | ||
|
||
/** | ||
* If set to true, the creation of PublisherOnAssembly will capture the raw | ||
|
@@ -40,15 +41,14 @@ public final class OnSubscribeOnAssembly<T> implements OnSubscribe<T> { | |
|
||
public OnSubscribeOnAssembly(OnSubscribe<T> source) { | ||
this.source = source; | ||
this.stacktrace = createStacktrace(); | ||
this.assemblyStacktrace = assemblyStacktrace(); | ||
} | ||
|
||
static String createStacktrace() { | ||
StackTraceElement[] stes = Thread.currentThread().getStackTrace(); | ||
static StackTraceElement[] assemblyStacktrace() { | ||
final StackTraceElement[] in = new Exception().getStackTrace(); | ||
final List<StackTraceElement> out = new ArrayList<StackTraceElement>(in.length); | ||
|
||
StringBuilder sb = new StringBuilder("Assembly trace:"); | ||
|
||
for (StackTraceElement e : stes) { | ||
for (StackTraceElement e : in) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll open separate PR after this one where I'll move filtering stacktrace to |
||
String row = e.toString(); | ||
if (!fullStackTrace) { | ||
if (e.getLineNumber() <= 1) { | ||
|
@@ -85,27 +85,41 @@ static String createStacktrace() { | |
continue; | ||
} | ||
} | ||
sb.append("\n at ").append(row); | ||
out.add(e); | ||
} | ||
|
||
return sb.append("\nOriginal exception:").toString(); | ||
|
||
return out.toArray(new StackTraceElement[out.size()]); | ||
} | ||
|
||
static Throwable addAssembly(Throwable original, StackTraceElement[] assemblyStacktrace) { | ||
final StackTraceElement[] originalStacktrace = original.getStackTrace(); | ||
final StackTraceElement[] resultingStacktrace = new StackTraceElement[originalStacktrace.length + assemblyStacktrace.length]; | ||
|
||
System.arraycopy(originalStacktrace, 0, resultingStacktrace, 0, originalStacktrace.length); | ||
|
||
System.arraycopy(assemblyStacktrace, 0, resultingStacktrace, | ||
originalStacktrace.length, assemblyStacktrace.length); | ||
|
||
original.setStackTrace(resultingStacktrace); | ||
|
||
return original; | ||
} | ||
|
||
@Override | ||
public void call(Subscriber<? super T> t) { | ||
source.call(new OnAssemblySubscriber<T>(t, stacktrace)); | ||
source.call(new OnAssemblySubscriber<T>(t, assemblyStacktrace)); | ||
} | ||
|
||
static final class OnAssemblySubscriber<T> extends Subscriber<T> { | ||
|
||
final Subscriber<? super T> actual; | ||
|
||
final String stacktrace; | ||
final StackTraceElement[] assemblyStacktrace; | ||
|
||
public OnAssemblySubscriber(Subscriber<? super T> actual, String stacktrace) { | ||
public OnAssemblySubscriber(Subscriber<? super T> actual, StackTraceElement[] assemblyStacktrace) { | ||
super(actual); | ||
this.actual = actual; | ||
this.stacktrace = stacktrace; | ||
this.assemblyStacktrace = assemblyStacktrace; | ||
} | ||
|
||
@Override | ||
|
@@ -115,8 +129,7 @@ public void onCompleted() { | |
|
||
@Override | ||
public void onError(Throwable e) { | ||
e = new AssemblyStackTraceException(stacktrace, e); | ||
actual.onError(e); | ||
actual.onError(addAssembly(e, assemblyStacktrace)); | ||
} | ||
|
||
@Override | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This field had a purpose to show the stacktrace in debug mode by viewing the field as string!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk, it consumes memory and I've never used it during debugging. You really need it? I think you should be able to get ~normal output from
Arrays.toString(assemblyStacktrace)
in the debugger