Hi,
I have prepared a patch to be able to use properties in native encoding. In EBCDIC Environment the FileInputStream is localized but not the ByteArrayInputStream therefore loading a properties using the WebappClassLoader class loader fails.
Any comment before I commit the attached patch?
Cheers
Jean-Frederic
Index: catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
retrieving revision 1.48
diff -u -r1.48 WebappClassLoader.java
--- catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
30 Mar 2005 13:01:00 -0000 1.48
+++ catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
3 May 2005 06:46:51 -0000
@@ -354,6 +354,11 @@
*/
protected boolean hasExternalRepositories = false;
+ /**
+ * need conversion for properties files
+ */
+ protected boolean needConvert = false;
+
/**
* All permission.
@@ -1444,6 +1449,15 @@
public void start() throws LifecycleException {
started = true;
+ String encoding = null;
+ try {
+ encoding = System.getProperty("file.encoding");
+ } catch (Exception e) {
+ return;
+ }
+ if (encoding.indexOf("EBCDIC")!=-1) {
+ needConvert = true;
+ }
}
@@ -1695,6 +1709,8 @@
Resource resource = null;
+ boolean fileNeedConvert = false;
+
for (i = 0; (entry == null) && (i < repositoriesLength); i++) {
try {
@@ -1728,6 +1744,12 @@
return null;
}
+ if (needConvert) {
+ if (path.endsWith(".properties")) {
+ fileNeedConvert = true;
+ }
+ }
+
// Register the full path for modification checking
// Note: Only syncing on a 'constant' object is needed
synchronized (allPermission) {
@@ -1855,8 +1877,8 @@
byte[] binaryContent = new byte[contentLength];
+ int pos = 0;
try {
- int pos = 0;
while (true) {
int n = binaryStream.read(binaryContent, pos,
@@ -1874,6 +1896,14 @@
return null;
}
+ if (fileNeedConvert) {
+ String str = new String(binaryContent,0,pos);
+ try {
+ binaryContent = str.getBytes("UTF-8");
+ } catch (Exception e) {
+ return null;
+ }
+ }
entry.binaryContent = binaryContent;
// The certificates are only available after the JarEntry --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
