This discussion is archived
1 Reply Latest reply: Oct 24, 2011 9:28 AM by 895123 RSS

Help--> Using GZIPOutputStream, but never end.

843790 Newbie
Currently Being Moderated
I written serialization object with GZIPOutputStream.
But recent my Aplication hang 24 hours. I print stack , see the thread is runnable,and lock (0x20fbca10)
Can any one help me?How the "Deflater.deflateBytes" never end?

I have two thread.
thread 1: write serialization object (when receive a message)
thread 2: close GZip file(when a stop request)


"RMI TCP Connection(22352)-10.9.146.14" daemon prio=6 tid=0x0792b8d8 nid=0x7b18 runnable [0x4b01d000..0x4b01fa18]
java.lang.Thread.State: RUNNABLE
     at java.util.zip.Deflater.deflateBytes(Native Method)
     at java.util.zip.Deflater.deflate(Deflater.java:290)
     - locked <0x20fbca10> (a java.util.zip.Deflater)
     at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:159)
     at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:118)
     at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)
     - locked <0x1ff90e98> (a java.util.zip.GZIPOutputStream)
     at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
     at java.io.BufferedOutputStream.write(BufferedOutputStream.java:109)
     - locked <0x1f41f740> (a java.io.BufferedOutputStream)
     at java.io.FilterOutputStream.write(FilterOutputStream.java:80)


"MessageListenerThread - F_LinkTopic" prio=6 tid=0x05def670 nid=0x16d8 waiting for monitor entry [0x0f90f000..0x0f90fd98]
java.lang.Thread.State: BLOCKED (on object monitor)
     at java.util.zip.Deflater.deflate(Deflater.java:284)
     - locked <0x20fbca10> (a java.util.zip.Deflater)
     at java.util.zip.GZIPOutputStream.finish(GZIPOutputStream.java:86)
     at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:146)
     at java.io.FilterOutputStream.close(FilterOutputStream.java:143)
  • 1. Re: Help--> Using GZIPOutputStream, but never end.
    895123 Newbie
    Currently Being Moderated
    I have seen an almost identical problem within an Apache CXF web service. In my situation the end of the stack looks almost identical, stuck forever (apparently) inside the native Deflater.deflateBytes.
    In my situation I have seen this with two threads, each independently using GZIPOutputStream.

    I am really starting to think that there is a thread safety issue with the native GZIP code - two independent objects in two threads are simultaneously zipping and both get stuck with 100% CPU utilization in the native code. Interestingly my situation is also in the close processing, but not inside the finish processing. Of all the situations I see with searching for similar situations (search the web for Deflater.java:306) there seems to be a set of common circumstances:
    * Exactly the same last few levels on the stack (ending in Deflater.deflateBytes (Native Method)
    * Two threads interacting with GZIP
    * Often seems to relate to close processing (perhaps a short data remainder problem?)

    My situation is documented here:
    http://www.java.net/forum/topic/glassfish/glassfish/glassfish-301-gzip-problem-threads-apparently-spinning-100-cpu-use

    Salient details of thread dump:
    "http-thread-pool-8080-(18)" - Thread t@950
    java.lang.Thread.State: RUNNABLE
    at java.util.zip.Deflater.deflateBytes(Native Method)
    at java.util.zip.Deflater.deflate(Deflater.java:306)
    - locked <21b0c5> (a java.util.zip.ZStreamRef)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:159)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:118)
    at java.util.zip.GZIPOutputStream.write(GZIPOutputStream.java:72)
    - locked <132ba84> (a java.util.zip.GZIPOutputStream)
    at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:46)
    at org.apache.cxf.io.AbstractThresholdOutputStream.write(AbstractThresholdOutputStream.java:69)
    at org.apache.cxf.io.AbstractWrappedOutputStream.write(AbstractWrappedOutputStream.java:46)
    at org.apache.cxf.io.AbstractThresholdOutputStream.unBuffer(AbstractThresholdOutputStream.java:89)
    at org.apache.cxf.io.AbstractThresholdOutputStream.close(AbstractThresholdOutputStream.java:100)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.AbstractHTTPDestination$BackChannelConduit.close(AbstractHTTPDestination.java:619)