luehe       2004/04/14 10:35:41

  Modified:    catalina/src/share/org/apache/catalina/loader
                        StandardClassLoader.java WebappClassLoader.java
  Log:
  Added support for exception chaining.
  
  Revision  Changes    Path
  1.9       +12 -10    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java
  
  Index: StandardClassLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- StandardClassLoader.java  2 Mar 2004 12:31:57 -0000       1.8
  +++ StandardClassLoader.java  14 Apr 2004 17:35:41 -0000      1.9
  @@ -370,7 +370,10 @@
               URL url = new URL(null, repository, streamHandler);
               super.addURL(url);
           } catch (MalformedURLException e) {
  -            throw new IllegalArgumentException(e.toString());
  +            IllegalArgumentException iae = new IllegalArgumentException
  +                ("Invalid repository: " + repository);
  +            iae.initCause(e);
  +            throw iae;
           }
   
           // Add this repository to our internal list
  @@ -454,7 +457,7 @@
                   } catch (Exception se) {
                       if (debug >= 4)
                           log("      -->Exception-->ClassNotFoundException", se);
  -                    throw new ClassNotFoundException(name);
  +                    throw new ClassNotFoundException(name, se);
                   }
               }
           }
  @@ -473,7 +476,7 @@
                       clazz = super.findClass(name);
                   }
               } catch(AccessControlException ace) {
  -                throw new ClassNotFoundException(name);
  +                throw new ClassNotFoundException(name, ace);
               } catch (RuntimeException e) {
                   if (debug >= 4)
                       log("      -->RuntimeException Rethrown", e);
  @@ -774,10 +777,8 @@
                   } catch (SecurityException se) {
                       String error = "Security Violation, attempt to use " +
                           "Restricted Class: " + name;
  -                    System.out.println(error);
  -                    se.printStackTrace();
                       log(error);
  -                    throw new ClassNotFoundException(error);
  +                    throw new ClassNotFoundException(error, se);
                   }
               }
           }
  @@ -944,9 +945,10 @@
                            repository + "'");
                   }
               } catch (Throwable t) {
  -                t.printStackTrace();
  -                throw new IllegalArgumentException
  -                    ("addRepositoryInternal: " + t);
  +                IllegalArgumentException iae = new IllegalArgumentException
  +                    ("addRepositoryInternal");
  +                iae.initCause(t);
  +                throw iae;
               } finally {
                   if (jarFile != null) {
                       try {
  
  
  
  1.32      +9 -9      
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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- WebappClassLoader.java    27 Feb 2004 14:58:44 -0000      1.31
  +++ WebappClassLoader.java    14 Apr 2004 17:35:41 -0000      1.32
  @@ -545,7 +545,10 @@
               hasExternalRepositories = true;
               repositoryURLs = null;
           } catch (MalformedURLException e) {
  -            throw new IllegalArgumentException(e.toString());
  +            IllegalArgumentException iae = new IllegalArgumentException
  +                ("Invalid repository: " + repository);
  +            iae.initCause(e);
  +            throw iae;
           }
   
       }
  @@ -842,7 +845,7 @@
                   } catch (Exception se) {
                       if (log.isTraceEnabled())
                           log.trace("      -->Exception-->ClassNotFoundException", 
se);
  -                    throw new ClassNotFoundException(name);
  +                    throw new ClassNotFoundException(name, se);
                   }
               }
           }
  @@ -860,8 +863,7 @@
                       throw cnfe;
                   }
               } catch(AccessControlException ace) {
  -                ace.printStackTrace();
  -                throw new ClassNotFoundException(name);
  +                throw new ClassNotFoundException(name, ace);
               } catch (RuntimeException e) {
                   if (log.isTraceEnabled())
                       log.trace("      -->RuntimeException Rethrown", e);
  @@ -871,7 +873,7 @@
                   try {
                       clazz = super.findClass(name);
                   } catch(AccessControlException ace) {
  -                    throw new ClassNotFoundException(name);
  +                    throw new ClassNotFoundException(name, ace);
                   } catch (RuntimeException e) {
                       if (log.isTraceEnabled())
                           log.trace("      -->RuntimeException Rethrown", e);
  @@ -1269,10 +1271,8 @@
                   } catch (SecurityException se) {
                       String error = "Security Violation, attempt to use " +
                           "Restricted Class: " + name;
  -                    System.out.println(error);
  -                    //se.printStackTrace();
                       log.info(error, se);
  -                    throw new ClassNotFoundException(error);
  +                    throw new ClassNotFoundException(error, se);
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to