You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by zo...@apache.org on 2003/10/14 16:50:19 UTC
cvs commit: xml-xalan/java/src/org/apache/xml/serializer Encodings.java
zongaro 2003/10/14 07:50:19
Modified: java/src/org/apache/xml/serializer Tag: xslt20-compiled
Encodings.java
Log:
Propagating change from myself (minchau@ca.ibm.com) for version 1.4 of
this file to the xslt20-compiled branch. Original comment:
Code in Encodings that uses Class.getResource should instead use
SecuritySupport.getResourceAsStream.
Revision Changes Path
No revision
No revision
1.3.2.1 +20 -16 xml-xalan/java/src/org/apache/xml/serializer/Encodings.java
Index: Encodings.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/serializer/Encodings.java,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -r1.3 -r1.3.2.1
--- Encodings.java 14 Aug 2003 16:27:42 -0000 1.3
+++ Encodings.java 14 Oct 2003 14:50:19 -0000 1.3.2.1
@@ -68,6 +68,8 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import org.apache.xml.utils.ObjectFactory;
+
/**
* Provides information about encodings. Depends on the Java runtime
* to provides writers for the different encodings, but can be used
@@ -89,7 +91,7 @@
/**
* Standard filename for properties file with encodings data.
*/
- static final String ENCODINGS_FILE = "Encodings.properties";
+ static final String ENCODINGS_FILE = "org/apache/xml/serializer/Encodings.properties";
/**
* Standard filename for properties file with encodings data.
@@ -350,6 +352,8 @@
try
{
String urlString = null;
+ InputStream is = null;
+
try
{
urlString = System.getProperty(ENCODINGS_PROP, "");
@@ -358,26 +362,26 @@
{
}
- if (urlString != null && urlString.length() > 0)
+ if (urlString != null && urlString.length() > 0) {
url = new URL(urlString);
- if (url == null)
- {
- url = Encodings.class.getResource(ENCODINGS_FILE);
+ is = url.openStream();
+ }
+
+ if (is == null) {
+ SecuritySupport ss = SecuritySupport.getInstance();
+ is = ss.getResourceAsStream(ObjectFactory.findClassLoader(),
+ ENCODINGS_FILE);
}
Properties props = new Properties();
- if (url != null)
- {
- InputStream is = url.openStream();
+ if (is != null) {
props.load(is);
is.close();
- }
- else
- {
- // Seems to be no real need to force failure here, let the system
- // do its best... The issue is not really very critical, and the
- // output will be in any case _correct_ though maybe not always
- // human-friendly... :)
+ } else {
+ // Seems to be no real need to force failure here, let the
+ // system do its best... The issue is not really very critical,
+ // and the output will be in any case _correct_ though maybe not
+ // always human-friendly... :)
// But maybe report/log the resource problem?
// Any standard ways to report/log errors (in static context)?
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org