Abdera
  1. Abdera
  2. ABDERA-249

Abdera fails to completely read streams using GZIP compression

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.0
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Mac OS X, Java 1.6

      Description

      Test code:

      Abdera abdera = new Abdera();
      AbderaClient client = new AbderaClient(abdera);
      ClientResponse resp = client.get("http://www.facebook.com/activitystreams/feed.php?source_id=499225640");
      Document<Feed> doc = resp.getDocument();
      doc.complete();
      

      When reading a stream that is gzip-compressed (such as the sample facebook stream above), Abdera throws an exception:

      Exception in thread "main" org.apache.abdera.parser.ParseException: java.lang.RuntimeException: [was class java.io.EOFException] Unexpected end of ZLIB input stream
      	at org.apache.abdera.parser.stax.FOMBuilder.next(FOMBuilder.java:260)
      	at org.apache.axiom.om.impl.llom.OMNodeImpl.build(OMNodeImpl.java:318)
      	at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:614)
      	at org.apache.abdera.parser.stax.FOMElement.complete(FOMElement.java:845)
      	at org.apache.abdera.parser.stax.FOMFeed.sortEntries(FOMFeed.java:167)
      	at FacebookStreamReader.main(FacebookStreamReader.java:42)
      Caused by: java.lang.RuntimeException: [was class java.io.EOFException] Unexpected end of ZLIB input stream
      	at com.ctc.wstx.util.ExceptionUtil.throwRuntimeException(ExceptionUtil.java:18)
      	at com.ctc.wstx.sr.StreamScanner.throwLazyError(StreamScanner.java:706)
      	at com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:3655)
      	at com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:809)
      	at org.apache.axiom.om.impl.builder.StAXBuilder.createOMText(StAXBuilder.java:245)
      	at org.apache.axiom.om.impl.builder.StAXBuilder.createOMText(StAXBuilder.java:216)
      	at org.apache.abdera.parser.stax.FOMBuilder.applyTextFilter(FOMBuilder.java:158)
      	at org.apache.abdera.parser.stax.FOMBuilder.next(FOMBuilder.java:206)
      	... 5 more
      Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
      	at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:223)
      	at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:141)
      	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:92)
      	at java.io.FilterInputStream.read(FilterInputStream.java:116)
      	at org.apache.abdera.protocol.client.util.AutoReleasingInputStream.read(AutoReleasingInputStream.java:56)
      	at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:264)
      	at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:306)
      	at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:158)
      	at java.io.InputStreamReader.read(InputStreamReader.java:167)
      	at com.ctc.wstx.io.MergedReader.read(MergedReader.java:101)
      	at com.ctc.wstx.io.ReaderSource.readInto(ReaderSource.java:84)
      	at com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:57)
      	at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:967)
      	at com.ctc.wstx.sr.BasicStreamReader.readTextSecondary(BasicStreamReader.java:4626)
      	at com.ctc.wstx.sr.BasicStreamReader.readCoalescedText(BasicStreamReader.java:4124)
      	at com.ctc.wstx.sr.BasicStreamReader.finishToken(BasicStreamReader.java:3699)
      	at com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:3647)
      	... 10 more
      

      If I force the stream to be un-compressed, via this code, it works:

      Abdera abdera = new Abdera();
      AbderaClient client = new AbderaClient(abdera);
      RequestOptions options = client.getDefaultRequestOptions();
      options.setAcceptEncoding((String)null);
      ClientResponse resp = client.get("http://www.facebook.com/activitystreams/feed.php?source_id=499225640", options);
      Document<Feed> doc = resp.getDocument();
      doc.complete();
      

      There is some code in org.apache.abdera.protocol.client.util.AutoReleasingInputStream that is not properly handling the EOFException. If I modify that code to also catch the EOFException and behave as though it had gotten back a -1 from the read() method, then it also starts working.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            James Falkner
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development