Use system jzlib instead of bundled jzlib

- Resolves: rhbz#878391
This commit is contained in:
Mikolaj Izdebski 2012-12-13 14:21:39 +01:00
parent 3ee121e6e0
commit bec080b98c
2 changed files with 118 additions and 1 deletions

View File

@ -0,0 +1,104 @@
From 423dc10334f211db7256944a0a9f40c8ca82359b Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Thu, 13 Dec 2012 04:20:46 +0100
Subject: [PATCH] Port netty to jzlib 1.1.0
---
.../netty/handler/codec/compression/ZlibDecoder.java | 2 +-
.../netty/handler/codec/compression/ZlibEncoder.java | 6 ++----
.../netty/handler/codec/compression/ZlibUtil.java | 18 ++++++++++--------
.../codec/spdy/SpdyHeaderBlockJZlibCompressor.java | 2 +-
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibDecoder.java b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibDecoder.java
index f31a430..e93efd8 100644
--- a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibDecoder.java
+++ b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibDecoder.java
@@ -77,7 +77,7 @@ public class ZlibDecoder extends OneToOneDecoder {
synchronized (z) {
int resultCode;
- resultCode = z.inflateInit(JZlib.W_ZLIB);
+ resultCode = z.inflateInit();
if (resultCode != JZlib.Z_OK) {
ZlibUtil.fail(z, "initialization failure", resultCode);
}
diff --git a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java
index 46f711e..88e7342 100644
--- a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java
+++ b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibEncoder.java
@@ -144,8 +144,7 @@ public class ZlibEncoder extends OneToOneStrictEncoder implements LifeCycleAware
}
synchronized (z) {
- int resultCode = z.deflateInit(compressionLevel, windowBits, memLevel,
- ZlibUtil.convertWrapperType(wrapper));
+ int resultCode = z.deflateInit(compressionLevel, ZlibUtil.convertWrapperType(wrapper), memLevel);
if (resultCode != JZlib.Z_OK) {
ZlibUtil.fail(z, "initialization failure", resultCode);
}
@@ -230,8 +229,7 @@ public class ZlibEncoder extends OneToOneStrictEncoder implements LifeCycleAware
synchronized (z) {
int resultCode;
- resultCode = z.deflateInit(compressionLevel, windowBits, memLevel,
- JZlib.W_ZLIB); // Default: ZLIB format
+ resultCode = z.deflateInit(compressionLevel, windowBits, memLevel);
if (resultCode != JZlib.Z_OK) {
ZlibUtil.fail(z, "initialization failure", resultCode);
} else {
diff --git a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibUtil.java b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibUtil.java
index 954edde..93d204f 100644
--- a/src/main/java/org/jboss/netty/handler/codec/compression/ZlibUtil.java
+++ b/src/main/java/org/jboss/netty/handler/codec/compression/ZlibUtil.java
@@ -32,25 +32,27 @@ final class ZlibUtil {
(z.msg != null? ": " + z.msg : ""));
}
- static Enum<?> convertWrapperType(ZlibWrapper wrapper) {
- Enum<?> convertedWrapperType;
- switch (wrapper) {
+ static int convertWrapperType(ZlibWrapper wrapper, int windowBits) {
+ switch (wrapper) {
case NONE:
- convertedWrapperType = JZlib.W_NONE;
+ windowBits = -windowBits;
break;
case ZLIB:
- convertedWrapperType = JZlib.W_ZLIB;
break;
case GZIP:
- convertedWrapperType = JZlib.W_GZIP;
+ windowBits += 16;
break;
case ZLIB_OR_NONE:
- convertedWrapperType = JZlib.W_ZLIB_OR_NONE;
break;
default:
throw new Error();
}
- return convertedWrapperType;
+
+ return windowBits;
+ }
+
+ static int convertWrapperType(ZlibWrapper wrapper) {
+ return convertWrapperType(wrapper, 15);
}
private ZlibUtil() {
diff --git a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java
index 612419d..957649b 100644
--- a/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java
+++ b/src/main/java/org/jboss/netty/handler/codec/spdy/SpdyHeaderBlockJZlibCompressor.java
@@ -46,7 +46,7 @@ class SpdyHeaderBlockJZlibCompressor extends SpdyHeaderBlockCompressor {
}
int resultCode = z.deflateInit(
- compressionLevel, windowBits, memLevel, JZlib.W_ZLIB);
+ compressionLevel, windowBits, memLevel);
if (resultCode != JZlib.Z_OK) {
throw new CompressionException(
"failed to initialize an SPDY header block deflater: " + resultCode);
--
1.7.11.7

View File

@ -1,6 +1,6 @@
Name: netty
Version: 3.5.11
Release: 1%{?dist}
Release: 2%{?dist}
Summary: An asynchronous event-driven network application framework and tools for Java
Group: Development/Libraries
@ -8,6 +8,8 @@ License: ASL 2.0
URL: https://netty.io/
Source0: https://github.com/downloads/%{name}/%{name}/%{name}-%{version}.Final-dist.tar.bz2
Patch0: %{name}-port-to-jzlib-1.1.0.patch
BuildArch: noarch
BuildRequires: maven
@ -73,6 +75,13 @@ rm -rf jar doc license
sed s/jboss-logging-spi/jboss-logging/ -i pom.xml
# Remove bundled jzlib and use system jzlib
rm -rf src/main/java/org/jboss/netty/util/internal/jzlib
%pom_add_dep com.jcraft:jzlib
sed -i s/org.jboss.netty.util.internal.jzlib/com.jcraft.jzlib/ \
$(find src/main/java/org/jboss/netty/handler/codec -name \*.java | sort -u)
%patch0 -p1
%build
# skipping tests because we don't have easymockclassextension
mvn-rpmbuild -Dmaven.test.skip=true install javadoc:aggregate
@ -103,6 +112,10 @@ install -pm 644 pom.xml $RPM_BUILD_ROOT/%{_mavenpomdir}/JPP-%{name}.pom
%{_javadocdir}/%{name}
%changelog
* Thu Dec 13 2012 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.5.11-2
- Use system jzlib instead of bundled jzlib
- Resolves: rhbz#878391
* Mon Dec 3 2012 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.5.11-1
- Update to upstream version 3.5.11