poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 58098] New: NPE at NPOIFSFileSystem.<init>
Date Fri, 03 Jul 2015 10:14:46 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=58098

            Bug ID: 58098
           Summary: NPE at NPOIFSFileSystem.<init>
           Product: POI
           Version: 3.12-FINAL
          Hardware: PC
            Status: NEW
          Severity: minor
          Priority: P2
         Component: POIFS
          Assignee: dev@poi.apache.org
          Reporter: tcavaleiro@gmail.com

An NPE is being throw when opening a XLSX file that is currently opened by
Excel (write mode).
On my opinion it should throw the java.io.FileNotFoundException instead.


Stacktrace:
Exception in thread "main" java.lang.NullPointerException
    at
org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:235)
    at
org.apache.poi.poifs.filesystem.NPOIFSFileSystem.<init>(NPOIFSFileSystem.java:165)
    at xxxxxx.CloseableWorkbook.create(CloseableWorkbook.java:271)
    at xxxxxx.ReadExcel.main(ReadExcel.java:29)


Issue story description:
NPOIFSFileSystem first tries to open the file and then gets an
java.io.FileNotFoundException: (....).xlsx (The process cannot access the file
because it is being used by another process) however since there is no null
check on the channel it gets an NPE.

Class NPOIFSFileSystem should be modified to check for channel first...

private NPOIFSFileSystem(FileChannel channel, File srcFile, boolean readOnly,
boolean closeChannelOnError)
         throws IOException
    {
       (...) // try 

       } catch(IOException e) {
          if(closeChannelOnError && channel != null) {
             channel.close();
          }
          throw e;
(...)


PS: Actually the null check if being done when handling RuntimeException.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message