costin      01/09/15 17:33:30

  Modified:    src/share/org/apache/tomcat/modules/mappers
                        ReloadInterceptor.java
               src/share/org/apache/tomcat/util/compat Jdk11Compat.java
               src/share/org/apache/tomcat/util/depend
                        DependClassLoader.java
  Added:       src/share/org/apache/tomcat/util/compat/jar Handler.java
  Log:
  Fix 3358: JDK1.1 compat problems due to missing jar: protocol.
  
  Note that the 'compat' jar: handler is added only if none found, and it support the 
most minimal
  functionality - parsing URLs using the default handler, so new URL( "jar:..." ) 
works.
  
  In future we may expand this to a complete support for jar: handler in JDK1.1.
  
  Revision  Changes    Path
  1.11      +1 -1      
jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/ReloadInterceptor.java
  
  Index: ReloadInterceptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/mappers/ReloadInterceptor.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ReloadInterceptor.java    2001/08/22 03:03:08     1.10
  +++ ReloadInterceptor.java    2001/09/16 00:33:30     1.11
  @@ -154,7 +154,7 @@
        ClassLoader cl=context.getClassLoader();
        
        ClassLoader loader=DependClassLoader.getDependClassLoader( dm, cl,
  -                  context.getAttribute( Context.ATTRIB_PROTECTION_DOMAIN));
  +                  context.getAttribute( Context.ATTRIB_PROTECTION_DOMAIN), debug);
   
        context.setClassLoader(loader);
        context.setAttribute( "org.apache.tomcat.classloader", loader);
  
  
  
  1.12      +32 -1     
jakarta-tomcat/src/share/org/apache/tomcat/util/compat/Jdk11Compat.java
  
  Index: Jdk11Compat.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/compat/Jdk11Compat.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Jdk11Compat.java  2001/09/07 04:25:20     1.11
  +++ Jdk11Compat.java  2001/09/16 00:33:30     1.12
  @@ -61,6 +61,7 @@
   import org.apache.tomcat.util.depend.*;
   
   import java.net.URL;
  +import java.net.MalformedURLException;
   import java.util.ResourceBundle;
   import java.util.Locale;
   
  @@ -199,8 +200,38 @@
            }
        } else {
            compat=new Jdk11Compat();
  +         // Install jar handler if none installed
  +         try {
  +             URL url=new URL( "jar:file:/test.jar!/foo");
  +         } catch( MalformedURLException ex ) {
  +             if( dL >0) d( "Installing jar protocol handler ");
  +             String handlers=System.getProperty("java.protocol.handler.pkgs");
  +             if( handlers==null ) {
  +                 handlers=URL_COMPAT_HANDLERS;
  +             } else {
  +                 if( handlers.indexOf( URL_COMPAT_HANDLERS) < 0 ) {
  +                     handlers+=":" + URL_COMPAT_HANDLERS;
  +                 }
  +             }
  +             System.getProperties().put("java.protocol.handler.pkgs", handlers);
  +             if( dL > 0 ) {
  +                 try {
  +                     URL url=new URL( "jar:file:/test.jar!/foo");
  +                 } catch( MalformedURLException ex1 ) {
  +                     d("Jar protocol failing ");
  +                     ex1.printStackTrace();
  +                 }
  +             }
  +         }
        }
       }
  -    
  +
  +    private static final String URL_COMPAT_HANDLERS=
  +     "org.apache.tomcat.util.compat";
  +
  +    private static final int dL=10;
  +    private static void d(String s ) {
  +        System.err.println( "Jdk11Compat: " + s );
  +    }
   
   }
  
  
  
  1.1                  
jakarta-tomcat/src/share/org/apache/tomcat/util/compat/jar/Handler.java
  
  Index: Handler.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * [Additional notices, if required by prior licensing conditions]
   *
   */
  
  package org.apache.tomcat.util.compat.jar;
  
  import java.net.*;
  import java.io.*;
  import java.util.*;
  
  
  /** Jar: protocol handler for JDK1.1 ( where it is not present ).
   *  Only minimal functionality is implemented right now, to get
   *  URL objects created.
   */
  public class Handler extends java.net.URLStreamHandler {
  
      protected java.net.URLConnection openConnection(URL u)
        throws IOException
      {
        // Not implemented.
        return null;
      }
  }
  
  
  
  1.12      +6 -2      
jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java
  
  Index: DependClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DependClassLoader.java    2001/09/14 06:00:14     1.11
  +++ DependClassLoader.java    2001/09/16 00:33:30     1.12
  @@ -87,19 +87,20 @@
       protected ClassLoader parent;
       protected ClassLoader parent2;
       
  -    final static int debug=0;
  +    private static int debug=0;
       DependManager dependM;
       protected Object pd;
       static Jdk11Compat jdkCompat=Jdk11Compat.getJdkCompat();
   
       public static DependClassLoader getDependClassLoader( DependManager depM,
                                                          ClassLoader parent,
  -                                                       Object pd ) {
  +                                                       Object pd, int debug ) {
        if( jdkCompat.isJava2() ) {
            try {
                Class c=Class.forName( 
"org.apache.tomcat.util.depend.DependClassLoader12");
                DependClassLoader dcl=(DependClassLoader)c.newInstance();
                dcl.init( depM, parent, pd );
  +             dcl.debug=debug;
                return dcl;
            } catch(Exception ex ) {
                ex.printStackTrace();
  @@ -241,6 +242,9 @@
            // Bojan Smojver <[EMAIL PROTECTED]>: remove jar:
            if( fileN.startsWith( "file:" ))
                fileN=fileN.substring( 5 );
  +         // If the standard URL parser is used ( jdk1.1 compat )
  +         if( fileN.startsWith( "/file:" ))
  +             fileN=fileN.substring( 6 );
            f=new File(fileN);
            if( debug > 0 ) log( "Jar dep "  +f + " " + f.exists() );
            if( ! f.exists()) f=null;
  
  
  

Reply via email to