eclipse-ee4j / eclipse-ee4j/tyrus

java.nio.BufferUnderflowException when receiving gzipped Inputstream

Open
#600 3 comments 0 reactions 0 assignees View on GitHub
Component: client Priority: Major Type: Bug
Dominant language
Java
Stars
128
Forks
49
PR merge metrics
No merged PRs in 30d

Description

Hello,

We have an application that connects to Tomcat for receiving and sending request.
I have moved from receiving and sending to InputStream from ByteBuffer.
I discovered that Tyrus have problem receiving Gzipped Inputstream.
I find it also strange that the exception is generated in ByteBuffer class when im working with streams.
I can receive gzipped streams in Tomcat without problem and it works without gzip.

java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Unknown Source)
at java.nio.HeapByteBuffer.get(Unknown Source)
at org.glassfish.tyrus.core.InputStreamBuffer.getNextByte(InputStreamBuffer.java:130)
at org.glassfish.tyrus.core.BufferedInputStream.read(BufferedInputStream.java:66)
at java.io.InputStream.read(Unknown Source)
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.GZIPInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)
at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.(Unknown Source)
at advit.web.dxweb.DxService.handleIn(DxService.java:26)
at advit.web.dxweb.TyrusWsClient$MyMessageHandler.handleMessage(TyrusWsClient.java:293)
at advit.web.dxweb.TyrusWsClient.onMessage(TyrusWsClient.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.glassfish.tyrus.core.AnnotatedEndpoint.callMethod(AnnotatedEndpoint.java:477)
at org.glassfish.tyrus.core.AnnotatedEndpoint.access$100(AnnotatedEndpoint.java:87)
at org.glassfish.tyrus.core.AnnotatedEndpoint$WholeHandler$1.onMessage(AnnotatedEndpoint.java:573)
at org.glassfish.tyrus.core.InputStreamBuffer$1.run(InputStreamBuffer.java:180)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

----------------------------For sending from Tomcat:
WsPayLoad payl = new WsPayLoad();
try (ObjectOutputStream ous = new ObjectOutputStream(new GZIPOutputStream(sess.getBasicRemote().getSendStream()))![](https://java.net/jira/images/icons/emoticons/wink.gif)

{ ous.writeObject(payl); ous.flush(); }

----------------------For receiving on Tyrus client:
@Override
public void handleMessage(InputStream ins)

{ ObjectInputStream in = new ObjectInputStream( new GZIPInputStream(ins);); WsPayLoad obj = in.readObject();//Exception thrown here }
#### Environment
Windows
#### Affected Versions
[1.12]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.