https://issues.apache.org/bugzilla/show_bug.cgi?id=56956

            Bug ID: 56956
           Summary: [PATCH] add constructor NPOIFSFileSystem(FileChannel
                    channel, boolean readOnly)
           Product: POI
           Version: 3.11-dev
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P2
         Component: POIFS
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 31998
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31998&action=edit
Proposed patch

This patch simply adds a public NPOIFSFileSystem(FileChannel channel, boolean
readOnly) constructor, since NPOIFSFileSystem(FileChannel) only allows to
create a read-write one. This is especially important because of this change:

http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/nio/FileBackedDataSource.java?r1=1590319&r2=1590556&diff_format=h

Since that change, using NPOIFileSystem with a non-writable FileChannel went
from working to failing with:

java.nio.channels.NonWritableChannelException
    at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:838)
    at
org.apache.poi.poifs.nio.FileBackedDataSource.read(FileBackedDataSource.java:77)
    at
org.apache.poi.poifs.filesystem.NPOIFSFileSystem.getBlockAt(NPOIFSFileSystem.java:439)
    at
org.apache.poi.poifs.filesystem.NPOIFSFileSystem.readBAT(NPOIFSFileSystem.java:413)

This new constructor will allow to avoid such regression in client code. I'm
using the regression severity because of this (hopefully that's appropriate).

On a related note, NPOIFSFileSystem(File) is implying read-only mode, while
NPOIFSFileSystem(FileChannel) is implying read-write. Is this intended?

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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to