Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/main/java/rx/internal/util/unsafe/UnsafeAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,19 @@
/**
* All use of this class MUST first check that UnsafeAccess.isUnsafeAvailable() == true
* otherwise NPEs will happen in environments without "suc.misc.Unsafe" such as Android.
* <p>
* Note that you can force RxJava to not use Unsafe API by setting any value to System Property
* {@code rx.unsafe-disable}.
*/
public final class UnsafeAccess {
private UnsafeAccess() {
throw new IllegalStateException("No instances!");
}

public static final Unsafe UNSAFE;

private static final boolean DISABLED_BY_USER = System.getProperty("rx.unsafe-disable") != null;

static {
Unsafe u = null;
try {
Expand All @@ -48,7 +54,7 @@ private UnsafeAccess() {
}

public static boolean isUnsafeAvailable() {
return UNSAFE != null;
return UNSAFE != null && !DISABLED_BY_USER;
}

/*
Expand Down