You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/12/30 07:55:10 UTC
DO NOT REPLY [Bug 25816] New: -
Serializer default output properties are not immutable
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25816>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=25816
Serializer default output properties are not immutable
Summary: Serializer default output properties are not immutable
Product: XalanJ2
Version: CurrentCVS
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xml.serializer
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: minchau@ca.ibm.com
Code like this, which calls the factory in org.apache.xml.serializer:
java.util.Properties prop0 =
OutputPropertiesFactory.getDefaultMethodProperties("xml");
String val = prop0.getProperty("encoding");
System.out.println("enc = " + val);
prop0.setProperty("encoding","UTF-BRIAN");
val = prop0.getProperty("encoding");
System.out.println("enc = " + val);
// DEFAULT VALUE IS CHANGED ! THIS IS BAD, ISN'T IT ?
java.util.Properties prop1 =
OutputPropertiesFactory.getDefaultMethodProperties("xml");
val = prop1.getProperty("encoding");
System.out.println("enc = " + val);
return new Properties(defaultProperties);
-------------------------------------
Will write this out:
enc = UTF-8
enc = UTF-BRIAN
enc = UTF-BRIAN
The last line shows that we have changed the default value within the factory.
I think this is bad. The simplest solution I can see is that the last line of
OutputPropertiesFactory.getDefaultMethodProperties(String method) should be:
return new Properties(defaultProperties);
rather than
return defaultProperties;
In this way properties can be changed by the caller in the Properties object,
but the default values are unchanged for the next call to the factory.