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

Knut Anders Hatlen updated DERBY-6162:
--------------------------------------

    Attachment: d6162-2a-deprecation.diff

I see the deprecation warning if I don't set j15lib in ant.properties. The 
File.toURL() method wasn't deprecated until Java 6, so we only see the warning 
if java15compile.classpath is constructed from Java 6 or newer class libraries.

We could silence the warning by replacing the call to File.toURL() with a call 
to File.toURI() and then call toURL() on the returned URI instance, as 
suggested by the deprecation text in java.io.File's javadoc. However, the call 
doesn't seem to be necessary. It is used when the test copies a custom policy 
file from derbyTesting.jar (or the classes directory) to the test directory. 
This is not necessary, since SecurityManagerTestSetup knows how to use policy 
files in derbyTesting.jar (or classes) directly.

The attached patch (d6162-2a-deprecation.diff) removes the code that copies the 
policy file, including the call to the deprecated method. This code was 
duplicated in lots of tests, and the patch fixes all occurrences. (One 
exception: SecurityPolicyReloadingTest actually needs to copy the policy file 
to a writable location in order to modify it and see if Derby picks up the 
changes. In this test, I changed the toURL() call to the suggested 
toURI().toURL().)

All the modified tests passed when I ran them individually. Running suites.All 
now to verify that the patch didn't break anything else.
                
> Simplify privileged actions in NetworkServerControlApiTest
> ----------------------------------------------------------
>
>                 Key: DERBY-6162
>                 URL: https://issues.apache.org/jira/browse/DERBY-6162
>             Project: Derby
>          Issue Type: Improvement
>          Components: Test
>    Affects Versions: 10.11.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Trivial
>             Fix For: 10.11.0.0
>
>         Attachments: d6162-1a.diff, d6162-2a-deprecation.diff
>
>
> Noticed two privileged blocks in NetworkServerControlApiTest that could be 
> simplified:
> - privInetAddressGetByName() tests whether the PrivilegedActionException 
> wraps a SecurityException. PAE only wraps checked exceptions, and 
> SecurityException is an unchecked exception, so that can never happen.
> - fileExists() could use the existing helper method 
> PrivilegedFileOpsForTests.exists() and remove its privileged block.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to