tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper JspC.java
Date Mon, 22 Nov 2004 14:44:55 GMT
yoavs       2004/11/22 06:44:55

  Modified:    webapps/docs changelog.xml
               jasper2/src/share/org/apache/jasper JspC.java
  Log:
  Bugzilla 32330: JspC changes context classloader
  
  Revision  Changes    Path
  1.177     +3 -0      jakarta-tomcat-catalina/webapps/docs/changelog.xml
  
  Index: changelog.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v
  retrieving revision 1.176
  retrieving revision 1.177
  diff -u -r1.176 -r1.177
  --- changelog.xml	19 Nov 2004 16:58:11 -0000	1.176
  +++ changelog.xml	22 Nov 2004 14:44:55 -0000	1.177
  @@ -72,6 +72,9 @@
         <update>
           Updated JspC usage messages to include recently added configurable parameters.
(yoavs)
         </update>
  +      <fix>
  +        <bug>32330</bug>: JspC changes context classloader. (yoavs)
  +      </fix>
       </changelog>
     </subsection>
   
  
  
  
  1.90      +22 -3     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java
  
  Index: JspC.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- JspC.java	19 Nov 2004 14:30:22 -0000	1.89
  +++ JspC.java	22 Nov 2004 14:44:55 -0000	1.90
  @@ -812,6 +812,8 @@
       private void processFile(String file)
           throws JasperException
       {
  +        ClassLoader originalClassLoader = null;
  +
           try {
               // set up a scratch/output dir if none is provided
               if (scratchDir == null) {
  @@ -835,8 +837,9 @@
                   clctxt.setServletPackageName(targetPackage);
               }
   
  -            if( loader==null )
  -                initClassLoader( clctxt );
  +            if( loader==null ) {
  +                originalClassLoader = initClassLoader( clctxt );
  +            }
   
               clctxt.setClassLoader(loader);
               clctxt.setClassPath(classPath);
  @@ -876,6 +879,10 @@
                                                 e.getMessage()));
               }
               throw new JasperException(e);
  +        } finally {
  +            if(originalClassLoader != null) {
  +                Thread.currentThread().setContextClassLoader(originalClassLoader);
  +            }
           }
       }
   
  @@ -1081,7 +1088,15 @@
           tagPluginManager = new TagPluginManager(context);
       }
   
  -    private void initClassLoader(JspCompilationContext clctxt)
  +    /**
  +     * Initializes the classloader as/if needed for the given
  +     * compilation context.
  +     *
  +     * @param clctxt The compilation context
  +     * @return The original classloader before modifying
  +     * @throws IOException If an error occurs
  +     */
  +    private ClassLoader initClassLoader(JspCompilationContext clctxt)
           throws IOException {
   
           classPath = getClassPath();
  @@ -1158,7 +1173,11 @@
           URL urlsA[]=new URL[urls.size()];
           urls.toArray(urlsA);
           loader = new URLClassLoader(urlsA, this.getClass().getClassLoader());
  +
  +        ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
           Thread.currentThread().setContextClassLoader(loader);
  +
  +        return originalClassLoader;
       }
   
       /**
  
  
  

---------------------------------------------------------------------
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