[ 
https://issues.apache.org/jira/browse/DERBY-6503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Knut Anders Hatlen updated DERBY-6503:
--------------------------------------

    Attachment: d6503-1a.diff

Attaching a patch (d6503-1a.diff) which fixes the error handling so
that it doesn't result in a ClassCastException that hides the
underlying IOException. This means the IOException is propagated up
from FileUtil.limitAccessToOwner(), so some calling code that was not
prepared to see IOExceptions had to be changed as well.

Description of the changes:

*java/engine/org/apache/derby/iapi/services/io/FilePermissionService.java*
*java/engine/org/apache/derby/iapi/services/io/FilePermissionServiceImpl.java*

Add a new interface for changing the file permissions, and an
implementation class that uses the java.nio.file.attribute package.
This abstraction layer allows us to compile the code that accesses
java.nio.file.attribute separately using JDK 7, so that it doesn't
have to do everything through reflection. This makes the code easier
to read and modify, and also makes the error handling simpler.

*build.xml*
*tools/jar/extraDBMSclasses.properties*
*java/engine/org/apache/derby/iapi/services/io/build.xml*

Only build FilePermissionServiceImpl.java when using JDK 7 or higher.

*java/engine/org/apache/derby/iapi/services/io/FileUtil.java*

Use the new FilePermissionService instead of reflection to call the
java.nio.file.attribute functionality.

Add "throws IOException" to limitAccessToOwner(), so that callers will
have to handle it.

Make the copyDirectory() methods catch IOException from
limitAccessToOwner() and return false (which is the same way as they
handle all other IOExceptions, see DERBY-1981).

*java/drda/org/apache/derby/impl/drda/DssTrace.java*

Add "throws IOException" to method declaration. IOExceptions are
already handled by the caller.

*java/engine/org/apache/derby/impl/io/DirFile.java*

Wrap the new IOException thrown by limitAccessToOwner() in a
FileNotFoundException to satisfy the StorageFile.getOutputStream()
interface (which says any error that prevents the file from being
opened should result in a FileNotFoundException).

*java/engine/org/apache/derby/impl/services/monitor/FileMonitor.java*

Catch IOException and return false if the permissions cannot be
changed for the newly created system home directory (which is how this
piece of code handles other exceptions too).

*java/engine/org/apache/derby/impl/store/raw/RawStore.java*
*java/engine/org/apache/derby/impl/store/raw/data/RAFContainer.java*
*java/engine/org/apache/derby/impl/store/raw/log/LogToFile.java*

Catch the new IOException and wrap it in a StandardException with a
high-level description of the operation that failed.

*java/engine/org/apache/derby/impl/store/raw/data/StreamFileContainer.java*

Handle all IOExceptions, not only FileNotFoundExceptions. These
exceptions end up wrapped in a StandardException by the callers.

*java/engine/org/apache/derby/io/StorageFile.java*
*java/testing/org/apache/derbyTesting/functionTests/util/corruptio/CorruptFile.java*

Add "throws IOException" to the signature of limitAccessToOwner().
Callers will handle the exception.

> Starting network server on a network drive fails with JDK 7 on Windows
> ----------------------------------------------------------------------
>
>                 Key: DERBY-6503
>                 URL: https://issues.apache.org/jira/browse/DERBY-6503
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Server, Services
>    Affects Versions: 10.10.1.1
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>         Attachments: d6503-1a.diff
>
>
> Starting a network server on a network drive with JDK 7 on Windows fails. The 
> reported exception is a ClassCastException, but the underlying exception is 
> the following:
> java.nio.file.AccessDeniedException: \\host\path\derby.log
>       at 
> sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
>       at 
> sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
>       at 
> sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
>       at 
> sun.nio.fs.WindowsAclFileAttributeView.setAcl(WindowsAclFileAttributeView.java:221)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:601)
>       at 
> org.apache.derby.iapi.services.io.FileUtil.limitAccessToOwnerViaACLs(FileUtil.java:897)
>       at 
> org.apache.derby.iapi.services.io.FileUtil.limitAccessToOwner(FileUtil.java:747)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.PBmakeFileHPW(SingleStream.java:205)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.run(SingleStream.java:401)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.run(SingleStream.java:72)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.makeFileHPW(SingleStream.java:394)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.createDefaultStream(SingleStream.java:356)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.makeStream(SingleStream.java:132)
>       at 
> org.apache.derby.impl.services.stream.SingleStream.boot(SingleStream.java:92)
>       at 
> org.apache.derby.impl.services.monitor.BaseMonitor.boot(BaseMonitor.java:1991)
>       at 
> org.apache.derby.impl.services.monitor.TopService.bootModule(TopService.java:334)
>       at 
> org.apache.derby.impl.services.monitor.BaseMonitor.startModule(BaseMonitor.java:541)
>       at 
> org.apache.derby.impl.services.monitor.FileMonitor.startModule(FileMonitor.java:44)
>       at 
> org.apache.derby.iapi.services.monitor.Monitor.startSystemModule(Monitor.java:362)
>       at 
> org.apache.derby.impl.services.monitor.BaseMonitor.runWithState(BaseMonitor.java:343)
>       at 
> org.apache.derby.impl.services.monitor.FileMonitor.<init>(FileMonitor.java:58)
>       at 
> org.apache.derby.iapi.services.monitor.Monitor.startMonitor(Monitor.java:285)
>       at org.apache.derby.iapi.jdbc.JDBCBoot.boot(JDBCBoot.java:67)
>       at org.apache.derby.jdbc.EmbeddedDriver.boot(EmbeddedDriver.java:199)
>       at org.apache.derby.jdbc.EmbeddedDriver.<clinit>(EmbeddedDriver.java:95)
>       at java.lang.Class.forName0(Native Method)
>       at java.lang.Class.forName(Class.java:188)
>       at 
> org.apache.derby.impl.drda.NetworkServerControlImpl.startNetworkServer(NetworkServerControlImpl.java:1032)
>       at 
> org.apache.derby.impl.drda.NetworkServerControlImpl.blockingStart(NetworkServerControlImpl.java:732)
>       at 
> org.apache.derby.impl.drda.NetworkServerControlImpl.executeWork(NetworkServerControlImpl.java:2277)
>       at 
> org.apache.derby.drda.NetworkServerControl.main(NetworkServerControl.java:353)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to