excel-streaming-reader icon indicating copy to clipboard operation
excel-streaming-reader copied to clipboard

NPE in StreamingWorkbookReader.init(InputStream) exception handler

Open ms1111 opened this issue 7 years ago • 1 comments

In StreamingWorkbookReader.init(InputStream), if there's a RuntimeException, f.delete() is called. f may be null at this point, giving a NullPointerException.

    try {
      f = writeInputStreamToFile(is, builder.getBufferSize());
...
    } catch(IOException e) {
      throw new ReadException("Unable to read input stream", e);
    } catch(RuntimeException e) {
      f.delete();   // <----
      throw e;
    }

This is pretty harmless, but it does hide the original exception. I suppose it just needs an if (f != null) guard.

ms1111 avatar Oct 11 '18 19:10 ms1111

Good catch, we should definitely add a null guard there.

monitorjbl avatar Oct 14 '18 21:10 monitorjbl