tyrus icon indicating copy to clipboard operation
tyrus copied to clipboard

java.nio.BufferUnderflowException when receiving gzipped Inputstream

Open glassfishrobot opened this issue 9 years ago • 3 comments

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()))

{ 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]

glassfishrobot avatar May 09 '16 04:05 glassfishrobot

  • Issue Imported From: https://github.com/tyrus-project/tyrus/issues/600
  • Original Issue Raised By:@glassfishrobot
  • Original Issue Assigned To: @pavelbucek

glassfishrobot avatar Feb 10 '18 20:02 glassfishrobot

@glassfishrobot Commented Reported by hugolarson

glassfishrobot avatar May 09 '16 04:05 glassfishrobot

@glassfishrobot Commented This issue was imported from java.net JIRA TYRUS-423

glassfishrobot avatar Apr 25 '17 03:04 glassfishrobot