-
Bug
-
Resolution: Done
-
Critical
-
2.3.1
-
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.