From 65d24a7647470879b891e78550166e60881a7225 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Mon, 26 Aug 2013 08:15:30 +0200 Subject: [PATCH] [#1735] Disable usage of JdkZlibDecoder by default, will be enabled in 4.1.0.Final --- .../codec/compression/ZlibCodecFactory.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java b/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java index 60f51073b0..d4ef176b8d 100644 --- a/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java +++ b/codec/src/main/java/io/netty/handler/codec/compression/ZlibCodecFactory.java @@ -16,11 +16,22 @@ package io.netty.handler.codec.compression; import io.netty.util.internal.PlatformDependent; +import io.netty.util.internal.SystemPropertyUtil; +import io.netty.util.internal.logging.InternalLogger; +import io.netty.util.internal.logging.InternalLoggerFactory; /** * Creates a new {@link ZlibEncoder} and a new {@link ZlibDecoder}. */ public final class ZlibCodecFactory { + private static final InternalLogger logger = InternalLoggerFactory.getInstance(ZlibCodecFactory.class); + + private static final boolean noJdkZlibDecoder; + + static { + noJdkZlibDecoder = !SystemPropertyUtil.getBoolean("io.netty.noJdkZlibDecoder", true); + logger.debug("-Dio.netty.noJdkZlibDecoder: {}", noJdkZlibDecoder); + } public static ZlibEncoder newZlibEncoder(int compressionLevel) { if (PlatformDependent.javaVersion() < 7) { @@ -79,7 +90,7 @@ public final class ZlibCodecFactory { } public static ZlibDecoder newZlibDecoder() { - if (PlatformDependent.javaVersion() < 7) { + if (PlatformDependent.javaVersion() < 7 || noJdkZlibDecoder) { return new JZlibDecoder(); } else { return new JdkZlibDecoder(); @@ -91,7 +102,7 @@ public final class ZlibCodecFactory { case ZLIB_OR_NONE: return new JZlibDecoder(wrapper); default: - if (PlatformDependent.javaVersion() < 7) { + if (PlatformDependent.javaVersion() < 7 || noJdkZlibDecoder) { return new JZlibDecoder(wrapper); } else { return new JdkZlibDecoder(wrapper); @@ -100,7 +111,7 @@ public final class ZlibCodecFactory { } public static ZlibDecoder newZlibDecoder(byte[] dictionary) { - if (PlatformDependent.javaVersion() < 7) { + if (PlatformDependent.javaVersion() < 7 || noJdkZlibDecoder) { return new JZlibDecoder(dictionary); } else { return new JdkZlibDecoder(dictionary);