Refine search
private static File tmpdir0() { File f; try { f = toDirectory(SystemPropertyUtil.get("io.netty.tmpdir")); if (f != null) { logger.debug("-Dio.netty.tmpdir: {}", f); return f; f = toDirectory(SystemPropertyUtil.get("java.io.tmpdir")); if (f != null) { logger.debug("-Dio.netty.tmpdir: {} (java.io.tmpdir)", f); return f; if (isWindows()) { f = toDirectory(System.getenv("TEMP")); if (f != null) { logger.debug("-Dio.netty.tmpdir: {} (%TEMP%)", f); return f;
private static int bitMode0() { int bitMode = SystemPropertyUtil.getInt("io.netty.bitMode", 0); if (bitMode > 0) { logger.debug("-Dio.netty.bitMode: {}", bitMode); return bitMode; bitMode = SystemPropertyUtil.getInt("sun.arch.data.model", 0); if (bitMode > 0) { logger.debug("-Dio.netty.bitMode: {} (sun.arch.data.model)", bitMode); return bitMode; bitMode = SystemPropertyUtil.getInt("com.ibm.vm.bitmode", 0); if (bitMode > 0) { logger.debug("-Dio.netty.bitMode: {} (com.ibm.vm.bitmode)", bitMode); return bitMode; String arch = SystemPropertyUtil.get("os.arch", "").toLowerCase(Locale.US).trim(); if ("amd64".equals(arch) || "x86_64".equals(arch)) { bitMode = 64; String vm = SystemPropertyUtil.get("java.vm.name", "").toLowerCase(Locale.US); Pattern BIT_PATTERN = Pattern.compile("([1-9][0-9]+)-?bit"); Matcher m = BIT_PATTERN.matcher(vm);
int somaxconn = PlatformDependent.isWindows() ? 200 : 128; File file = new File("/proc/sys/net/core/somaxconn"); BufferedReader in = null; in = new BufferedReader(new FileReader(file)); somaxconn = Integer.parseInt(in.readLine()); if (logger.isDebugEnabled()) { logger.debug("{}: {}", file, somaxconn); if (SystemPropertyUtil.getBoolean("io.netty.net.somaxconn.trySysctl", false)) { tmp = sysctlGetInt("kern.ipc.somaxconn"); if (tmp == null) { logger.debug("Failed to get SOMAXCONN from sysctl and file {}. Default: {}", file, somaxconn);
private static Throwable explicitNoUnsafeCause0() { final boolean noUnsafe = SystemPropertyUtil.getBoolean("io.netty.noUnsafe", false); logger.debug("-Dio.netty.noUnsafe: {}", noUnsafe); if (noUnsafe) { logger.debug("sun.misc.Unsafe: unavailable (io.netty.noUnsafe)"); return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (io.netty.noUnsafe)"); } // Legacy properties String unsafePropName; if (SystemPropertyUtil.contains("io.netty.tryUnsafe")) { unsafePropName = "io.netty.tryUnsafe"; } else { unsafePropName = "org.jboss.netty.tryUnsafe"; } if (!SystemPropertyUtil.getBoolean(unsafePropName, true)) { String msg = "sun.misc.Unsafe: unavailable (" + unsafePropName + ")"; logger.debug(msg); return new UnsupportedOperationException(msg); } return null; }
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("mac") && !name.contains("bsd") && !name.startsWith("darwin")) { throw new IllegalStateException("Only supported on BSD"); } String staticLibName = "netty_transport_native_kqueue"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
private static boolean isAndroid0() { // Idea: Sometimes java binaries include Android classes on the classpath, even if it isn't actually Android. // Rather than check if certain classes are present, just check the VM, which is tied to the JDK. // Optional improvement: check if `android.os.Build.VERSION` is >= 24. On later versions of Android, the // OpenJDK is used, which means `Unsafe` will actually work as expected. // Android sets this property to Dalvik, regardless of whether it actually is. String vmName = SystemPropertyUtil.get("java.vm.name"); boolean isAndroid = "Dalvik".equals(vmName); if (isAndroid) { logger.debug("Platform: Android"); } return isAndroid; }
/** * Returns the value of the Java system property with the specified * {@code key}, while falling back to the specified default value if * the property access fails. * * @return the property value. * {@code def} if there's no such property or if an access to the * specified property is not allowed. */ public static int getInt(String key, int def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Integer.parseInt(value); } catch (Exception e) { // Ignore } logger.warn( "Unable to parse the integer system property '{}':{} - using the default value: {}", key, value, def ); return def; }
DEFAULT_EVENT_LOOP_THREADS = Math.max(1, SystemPropertyUtil.getInt( "io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2)); if (logger.isDebugEnabled()) { logger.debug("-Dio.netty.eventLoopThreads: {}", DEFAULT_EVENT_LOOP_THREADS);
systemClassLoader = getSystemClassLoader(); String vmName = SystemPropertyUtil.get("java.vm.name", "").toLowerCase(); if (!vmName.startsWith("ibm j9") && logger.debug("maxDirectMemory: {} bytes (maybe)", maxDirectMemory); } else { logger.debug("maxDirectMemory: {} bytes", maxDirectMemory);
private static boolean maybeSuperUser0() { String username = SystemPropertyUtil.get("user.name"); if (isWindows()) { return "Administrator".equals(username); } // Check for root and toor as some BSDs have a toor user that is basically the same as root. return "root".equals(username) || "toor".equals(username); }
/** * Returns {@code true} if and only if the system property with the specified {@code key} * exists. */ public static boolean contains(String key) { return get(key) != null; }
@Override public Integer run() { return Math.max(1, SystemPropertyUtil.getInt("io.netty.handler.ssl.openssl.bioNonApplicationBufferSize", 2048)); } });
@Override public Boolean run() { return SystemPropertyUtil.getBoolean( "io.netty.handler.ssl.openssl.useKeyManagerFactory", true); } });
private static void loadNativeLibrary() { String name = SystemPropertyUtil.get("os.name").toLowerCase(Locale.UK).trim(); if (!name.startsWith("linux")) { throw new IllegalStateException("Only supported on Linux"); } String staticLibName = "netty_transport_native_epoll"; String sharedLibName = staticLibName + '_' + PlatformDependent.normalizedArch(); ClassLoader cl = PlatformDependent.getClassLoader(Native.class); try { NativeLibraryLoader.load(sharedLibName, cl); } catch (UnsatisfiedLinkError e1) { try { NativeLibraryLoader.load(staticLibName, cl); logger.debug("Failed to load {}", sharedLibName, e1); } catch (UnsatisfiedLinkError e2) { ThrowableUtil.addSuppressed(e1, e2); throw e1; } } }
/** * Returns the value of the Java system property with the specified * {@code key}, while falling back to the specified default value if * the property access fails. * * @return the property value. * {@code def} if there's no such property or if an access to the * specified property is not allowed. */ public static long getLong(String key, long def) { String value = get(key); if (value == null) { return def; } value = value.trim(); try { return Long.parseLong(value); } catch (Exception e) { // Ignore } logger.warn( "Unable to parse the long integer system property '{}':{} - using the default value: {}", key, value, def ); return def; }
private static Throwable explicitNoUnsafeCause0() { final boolean noUnsafe = SystemPropertyUtil.getBoolean("io.netty.noUnsafe", false); logger.debug("-Dio.netty.noUnsafe: {}", noUnsafe); if (noUnsafe) { logger.debug("sun.misc.Unsafe: unavailable (io.netty.noUnsafe)"); return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (io.netty.noUnsafe)"); } // Legacy properties String unsafePropName; if (SystemPropertyUtil.contains("io.netty.tryUnsafe")) { unsafePropName = "io.netty.tryUnsafe"; } else { unsafePropName = "org.jboss.netty.tryUnsafe"; } if (!SystemPropertyUtil.getBoolean(unsafePropName, true)) { String msg = "sun.misc.Unsafe: unavailable (" + unsafePropName + ")"; logger.debug(msg); return new UnsupportedOperationException(msg); } return null; }
DEFAULT_EVENT_LOOP_THREADS = Math.max(1, SystemPropertyUtil.getInt( "io.netty.eventLoopThreads", NettyRuntime.availableProcessors() * 2)); if (logger.isDebugEnabled()) { logger.debug("-Dio.netty.eventLoopThreads: {}", DEFAULT_EVENT_LOOP_THREADS);
systemClassLoader = getSystemClassLoader(); String vmName = SystemPropertyUtil.get("java.vm.name", "").toLowerCase(); if (!vmName.startsWith("ibm j9") && logger.debug("maxDirectMemory: {} bytes (maybe)", maxDirectMemory); } else { logger.debug("maxDirectMemory: {} bytes", maxDirectMemory);
private static boolean maybeSuperUser0() { String username = SystemPropertyUtil.get("user.name"); if (isWindows()) { return "Administrator".equals(username); } // Check for root and toor as some BSDs have a toor user that is basically the same as root. return "root".equals(username) || "toor".equals(username); }