tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader WebappClassLoader.java
Date Wed, 04 May 2005 07:30:24 GMT
jfclere     2005/05/04 00:30:24

  Modified:    catalina/src/share/org/apache/catalina/loader
                        WebappClassLoader.java
  Log:
  Allow to use properties in native encoding.
  In EBCDIC Environments the FileInputStream is localized but not the
  ByteArrayInputStream therefore loading a properties from such
  a file using the WebappClassLoader class loader failed.
  
  Revision  Changes    Path
  1.49      +32 -2     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java
  
  Index: WebappClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/WebappClassLoader.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- WebappClassLoader.java	30 Mar 2005 13:01:00 -0000	1.48
  +++ WebappClassLoader.java	4 May 2005 07:30:24 -0000	1.49
  @@ -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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message