Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java')
-rw-r--r--jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java32
1 files changed, 26 insertions, 6 deletions
diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java
index ac32ad6d72..517f714203 100644
--- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java
+++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/CompressExtension.java
@@ -74,28 +74,34 @@ public abstract class CompressExtension extends AbstractExtension
private final Queue<FrameEntry> entries = new ConcurrentArrayQueue<>();
private final IteratingCallback flusher = new Flusher();
- private final Deflater deflater;
- private final Inflater inflater;
+ private Deflater deflaterImpl;
+ private Inflater inflaterImpl;
protected AtomicInteger decompressCount = new AtomicInteger(0);
private int tailDrop = TAIL_DROP_NEVER;
private int rsvUse = RSV_USE_ALWAYS;
protected CompressExtension()
{
- deflater = new Deflater(Deflater.DEFAULT_COMPRESSION,NOWRAP);
- inflater = new Inflater(NOWRAP);
tailDrop = getTailDropMode();
rsvUse = getRsvUseMode();
}
public Deflater getDeflater()
{
- return deflater;
+ if (deflaterImpl == null)
+ {
+ deflaterImpl = new Deflater(Deflater.DEFAULT_COMPRESSION,NOWRAP);
+ }
+ return deflaterImpl;
}
public Inflater getInflater()
{
- return inflater;
+ if (inflaterImpl == null)
+ {
+ inflaterImpl = new Inflater(NOWRAP);
+ }
+ return inflaterImpl;
}
/**
@@ -155,6 +161,8 @@ public abstract class CompressExtension extends AbstractExtension
}
byte[] output = new byte[DECOMPRESS_BUF_SIZE];
+ Inflater inflater = getInflater();
+
while(buf.hasRemaining() && inflater.needsInput())
{
if (!supplyInput(inflater,buf))
@@ -346,6 +354,16 @@ public abstract class CompressExtension extends AbstractExtension
}
return true;
}
+
+ @Override
+ protected void doStop() throws Exception
+ {
+ if(deflaterImpl != null)
+ deflaterImpl.end();
+ if(inflaterImpl != null)
+ inflaterImpl.end();
+ super.doStop();
+ }
@Override
public String toString()
@@ -429,6 +447,8 @@ public abstract class CompressExtension extends AbstractExtension
LOG.debug("Compressing {}: {} bytes in {} bytes chunk",entry,remaining,outputLength);
boolean needsCompress = true;
+
+ Deflater deflater = getDeflater();
if (deflater.needsInput() && !supplyInput(deflater,data))
{

Back to the top