File tree 1 file changed +7
-1
lines changed
src/main/java/rx/internal/util/unsafe
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 22
22
/**
23
23
* All use of this class MUST first check that UnsafeAccess.isUnsafeAvailable() == true
24
24
* 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}.
25
28
*/
26
29
public final class UnsafeAccess {
27
30
private UnsafeAccess () {
28
31
throw new IllegalStateException ("No instances!" );
29
32
}
30
33
31
34
public static final Unsafe UNSAFE ;
35
+
36
+ private static final boolean DISABLED_BY_USER = System .getProperty ("rx.unsafe-disable" ) != null ;
37
+
32
38
static {
33
39
Unsafe u = null ;
34
40
try {
@@ -48,7 +54,7 @@ private UnsafeAccess() {
48
54
}
49
55
50
56
public static boolean isUnsafeAvailable () {
51
- return UNSAFE != null ;
57
+ return UNSAFE != null && ! DISABLED_BY_USER ;
52
58
}
53
59
54
60
/*
You can’t perform that action at this time.
0 commit comments