Skip to content

Commit c4b92ef

Browse files
committed
revert eager static ref to plugin + better exception handling around render
1 parent 17ff080 commit c4b92ef

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/rx/exceptions/OnErrorThrowable.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ public static class OnNextValue extends RuntimeException {
110110

111111
private static final long serialVersionUID = -3454462756050397899L;
112112

113-
private static final RxJavaErrorHandler ERROR_HANDLER = RxJavaPlugins.getInstance().getErrorHandler();
114-
115113
private final Object value;
116114

117115
/**
@@ -164,7 +162,7 @@ private static String renderValue(Object value){
164162
return ((Enum<?>) value).name();
165163
}
166164

167-
String pluggedRendering = ERROR_HANDLER.handleOnNextValueRendering(value);
165+
String pluggedRendering = RxJavaPlugins.getInstance().getErrorHandler().handleOnNextValueRendering(value);
168166
if (pluggedRendering != null) {
169167
return pluggedRendering;
170168
}

src/main/java/rx/plugins/RxJavaErrorHandler.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import rx.Observable;
1919
import rx.Subscriber;
2020
import rx.annotations.Experimental;
21+
import rx.exceptions.Exceptions;
2122
import rx.exceptions.OnErrorThrowable;
2223

2324
/**
@@ -65,11 +66,15 @@ public void handleError(Throwable e) {
6566
*/
6667
@Experimental
6768
public final String handleOnNextValueRendering(Object item) {
69+
6870
try {
6971
return render(item);
72+
} catch (InterruptedException e) {
73+
Thread.currentThread().interrupt();
7074
} catch (Throwable t) {
71-
return item.getClass().getName() + ERROR_IN_RENDERING_SUFFIX;
75+
Exceptions.throwIfFatal(t);
7276
}
77+
return item.getClass().getName() + ERROR_IN_RENDERING_SUFFIX;
7378
}
7479

7580
/**
@@ -84,9 +89,10 @@ public final String handleOnNextValueRendering(Object item) {
8489
*
8590
* @param item the last emitted item, that caused the exception wrapped in {@link OnErrorThrowable.OnNextValue}.
8691
* @return a short {@link String} representation of the item if one is known for its type, or null for default.
92+
* @throws InterruptedException if the rendering thread is interrupted
8793
*/
8894
@Experimental
89-
protected String render (Object item) {
95+
protected String render (Object item) throws InterruptedException {
9096
//do nothing by default
9197
return null;
9298
}

0 commit comments

Comments
 (0)