[kepler-dev] [Bug 3874] - ptolemy.util.StringUtilities.mergePropertiesFile() deletes properties

bugzilla-daemon at ecoinformatics.org bugzilla-daemon at ecoinformatics.org
Wed Jul 8 09:28:49 PDT 2009


http://bugzilla.ecoinformatics.org/show_bug.cgi?id=3874


cxh at eecs.berkeley.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #6 from cxh at eecs.berkeley.edu  2009-07-08 09:28 -------
Fixed.  I'm not sure what the cause is here, I can't get a small test to fail.
Basically, we read the system properties and create a java.util.Properties, see
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html

We then read in the properties file and then call putAll and merge in
the previous system properties. 

 public static void mergePropertiesFile() throws IOException {
        Properties systemProperties = System.getProperties();
        Properties newProperties = new Properties();
        String propertyFileName = "$CLASSPATH/lib/ptII.properties";

        // FIXME: xxxxxxCLASSPATHxxxxxx is an ugly hack
        URL propertyFileURL = FileUtilities.nameToURL(
                "xxxxxxCLASSPATHxxxxxx/lib/ptII.properties", null, null);

        if (propertyFileURL == null) {
            throw new IOException("Could not find " + propertyFileName);
        }

        newProperties.load(propertyFileURL.openStream());
        // systemProperties is a HashSet, so we merge in the new properties.
        newProperties.putAll(systemProperties);
        System.setProperties(newProperties); 
    }


For some reason, in Kepler, this results in a partially truncated set of
properties.  I suspect a threading bug.

Happily, if I instantiate newProperties with:
 Properties newProperties = new Properties(systemProperties);

and remove the putAll() call, then the problem goes away.

I'm not sure why this makes a difference, but it does.


More information about the Kepler-dev mailing list