[
https://issues.apache.org/jira/browse/DERBY-5173?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-5173:
--------------------------------------
Attachment: derby-5173-1a.diff
I'm not sure if there's an easy way to add a regression test for this bug, or
if it's worthwhile given that the issue is mostly cosmetic and the bug is
somewhat of an edge case.
In any case, here's a fix for the problem. Following the steps to reproduce
described in the previous comment, I now get this error message:
ij> connect 'jdbc:derby:db;dataEncryption=true;bootPassword=abc1234xyz';
ERROR XJ040: Failed to start database 'db' with class loader
sun.misc.Launcher$AppClassLoader@18a80d4, see the next exception for details.
ERROR XBCXU: Encryption of an un-encrypted database failed: Exception during
creation of file /tmp/db/seg0/n461.dat for container
The ClassCastException is gone. And if ij had called printStackTrace() or
otherwise followed the getCause() exception chain (it currently only follows
the SQLException.getNextException() chain), it would have shown the underlying
exception too:
Caused by: java.io.FileNotFoundException: /tmp/db/seg0/n461.dat (Permission
denied)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:233)
at
org.apache.derby.impl.io.DirRandomAccessFile.<init>(DirRandomAccessFile.java:57)
at
org.apache.derby.impl.io.DirFile4.getRandomAccessFile(DirFile4.java:275)
at
org.apache.derby.impl.store.raw.data.RAFContainer.run(RAFContainer.java:1692)
... 45 more
> RAFContainer.privGetRandomAccessFile() unwraps wrong exception type
> -------------------------------------------------------------------
>
> Key: DERBY-5173
> URL: https://issues.apache.org/jira/browse/DERBY-5173
> Project: Derby
> Issue Type: Bug
> Components: Store
> Affects Versions: 10.7.1.1
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Attachments: derby-5173-1a.diff
>
>
> RAFContainer.privGetRandomAccessFile() catches and unwraps
> PrivilegedActionExceptions raised in the privileged code:
> catch( PrivilegedActionException pae){
> throw (StandardException) pae.getException();
> }
> The problem is that the privileged code is this:
> case GET_RANDOM_ACCESS_FILE_ACTION: {
> return actionFile.getRandomAccessFile("rw");
> } // end of case BACKUP_CONTAINER_ACTION
> getRandomAccessFile() only has one checked exception, and that is
> FileNotFoundException. If it ever happens to raise FNFE,
> privGetRandomAccessFile() will fail with a ClassCastException and hide the
> underlying error.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira