Allow to disable the use of sun.misc.Unsafe via a System property. See #272
This commit is contained in:
parent
2cea0dee73
commit
1a53f9e0bd
@ -26,6 +26,11 @@ import java.util.zip.Deflater;
|
||||
* Utility that detects various properties specific to the current runtime
|
||||
* environment, such as Java version and the availability of the
|
||||
* {@code sun.misc.Unsafe} object.
|
||||
*
|
||||
* <br>
|
||||
* You can disable the use of {@code sun.misc.Unsafe} if you specify
|
||||
* the System property <strong>org.jboss.netty.tryUnsafe</strong> with
|
||||
* value of <code>false</code>. Default is <code>true</code>.
|
||||
*/
|
||||
public final class DetectionUtil {
|
||||
|
||||
@ -41,6 +46,11 @@ public final class DetectionUtil {
|
||||
}
|
||||
|
||||
private static boolean hasUnsafe(ClassLoader loader) {
|
||||
boolean useUnsafe = Boolean.valueOf(SystemPropertyUtil.get("org.jboss.netty.tryUnsafe", "true"));
|
||||
if (!useUnsafe) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> unsafeClazz = Class.forName("sun.misc.Unsafe", true, loader);
|
||||
return hasUnsafeField(unsafeClazz);
|
||||
|
Loading…
Reference in New Issue
Block a user