File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
src/main/java/rx/internal/util/unsafe Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 2222/**
2323 * All use of this class MUST first check that UnsafeAccess.isUnsafeAvailable() == true
2424 * otherwise NPEs will happen in environments without "suc.misc.Unsafe" such as Android.
25+ * <p>
26+ * Note that you can force RxJava to not use Unsafe API by setting any value to System Property
27+ * {@code rx.unsafe-disable}.
2528 */
2629public final class UnsafeAccess {
2730 private UnsafeAccess () {
2831 throw new IllegalStateException ("No instances!" );
2932 }
3033
3134 public static final Unsafe UNSAFE ;
35+
36+ private static final boolean DISABLED_BY_USER = System .getProperty ("rx.unsafe-disable" ) != null ;
37+
3238 static {
3339 Unsafe u = null ;
3440 try {
@@ -48,7 +54,7 @@ private UnsafeAccess() {
4854 }
4955
5056 public static boolean isUnsafeAvailable () {
51- return UNSAFE != null ;
57+ return UNSAFE != null && ! DISABLED_BY_USER ;
5258 }
5359
5460 /*
You can’t perform that action at this time.
0 commit comments