RFR: JDK-8030781: System.setProperties(null) drops all system properties (RELEASE not set)

Mike Duigou mike.duigou at oracle.com
Tue Jan 7 17:46:08 UTC 2014


On Jan 7 2014, at 06:45 , Alan Bateman <Alan.Bateman at oracle.com> wrote:

> On 07/01/2014 14:29, Erik Joelsson wrote:
>> Updated review with a regression test. I'm not familiar with jtreg so tried pattern matching on existing tests and translated the reproducer from the bug report. I suspect that this test should not be run in the same jvm instance as other tests as it destructively changes the system properties. Is that something that can be expressed to jtreg?
>> 
>> http://cr.openjdk.java.net/~erikj/8030781/webrev.01/
>> 
>> /Erik
> Thanks for spending time on test, I wasn't sure if this was going to be a separate JBS issue or not.
> 
> I think a more complete test would check that the other system properties are reset (as in the table in System#getProperties). Also I think it should change some of the these to nonsense values and see that setProperties(null) restores them to their original values. This might be a bit more than what you were thinking but it's the sort of test that should have been there to catch this issue in the first place.

I developed a test for JDK-8022854 (https://bugs.openjdk.java.net/browse/JDK-8022854)

public class SystemPropertiesReinit {
    public static void main(String... args) {
        Properties first = System.getProperties();

        System.setProperties(null);

        Properties second = System.getProperties();

        Properties diff1 = (Properties) first.clone();
        Properties diff2 = (Properties) second.clone();

        diff1.keySet().removeAll(second.keySet());
        diff2.keySet().removeAll(first.keySet());

        System.out.println("Appearing in second: " + diff2 );
        System.out.println("Missing from second: " + diff1 );

        assert diff1.isEmpty() && diff2.isEmpty() : "Not empty";
    }
}

This test would be relevant except that without the fix that 8022854 provides it will fail. For 8030781 the test will have to be more specific and check particular properties.

Mike

> 
> "@run main/othervm SetPropertiesNull" will ensure that it runs in its own VM but it might not be necessary here as system properties is one of the things that jtreg will reset.
> 
> -Alan




More information about the build-dev mailing list