Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-658

NullPointerException when using GZIP

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Critical Critical
    • 2.3.2.Final
    • 2.3.1
    • jaxrs
    • None
    • Low

      I do have a method which uses a StremingOutput in combination with GZIP. When now a WebApplicationException gets thrown, the GZIPEncodingInterceptor produces a NPE.

      To reproduce:

      @GET
      @GZIP
      @Produces({"application/json;charset=UTF-8"})
      public StreamingOutput getTest() {
         return new StreamingOutput() {
            @Override
            public void write(OutputStream outputStream) throws IOException, WebApplicationException {
               throw new WebApplicationException(404);
            }
         }
      } 
      

      Now the problem relies in the GZIPEncodingInterceptor.java (package org.jboss.resteasy.plugins.interceptors.encoding) on line 91:

      try {
        context.proceed();
      } finally {
        gzipOutputStream.getGzip().finish();
        context.setOutputStream(old);
      }
      

      In the finally block, the interceptor tries to access the gzip trhough getGzip() and is calling finish on it. Of course nothing has been written to the output stream and therefor the method commit was not yet called on the GZipOutputStream which leads to the fact, that the gzip object itself was not yet initialized and is null.

      Through this the NPE occurs.

              patriot1burke@gmail.com Bill Burke (Inactive)
              coresystems_rit Thierry Rietsch (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: