/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.tomcat.jdbc.pool;


import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;

public class ClassLoaderUtil {
    private static final Log log = LogFactory.getLog(ClassLoaderUtil.class);
    
    private static final boolean onlyAttemptFirstLoader = 
        Boolean.getBoolean(System.getProperty("org.apache.tomcat.jdbc.pool.onlyAttemptCurrentClassLoader", "false")); 
    
    public static Class loadClass(String className, ClassLoader... classLoaders) throws ClassNotFoundException {
        ClassNotFoundException last = null;
        StringBuffer errorMsg = null;
        for (ClassLoader cl : classLoaders) {
            try {
                if (cl!=null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Attempting to load class["+className+"] from "+cl);
                    }
                    return Class.forName(className, true, cl);
                } else {
                    throw new ClassNotFoundException("Classloader is null");
                }
            } catch (ClassNotFoundException x) {
                last = x;
                if (errorMsg==null) {
                    errorMsg = new StringBuffer();
                } else {
                    errorMsg.append(";");
                }
                errorMsg.append("ClassLoader:");
                errorMsg.append(cl.toString());
            }
            if (onlyAttemptFirstLoader) {
                break;
            }
        }
        throw new ClassNotFoundException("Unable to load class:"+className+" from "+errorMsg, last);
    }



}

@@ -1023,20 +1023,16 @@
 class);%0A
-    
 %0A    pri
@@ -1081,17 +1081,16 @@
 Loader =
- 
 %0A       
@@ -1199,22 +1199,17 @@
 alse%22));
- %0A    
+%0A
 %0A    pub
@@ -1224,16 +1224,19 @@
 ic Class
+%3C?%3E
  loadCla
@@ -2129,24 +2129,132 @@
 sLoader:%22);%0A
+                if (cl == null) %7B%0A                    errorMsg.append(%22null%22);%0A                %7D else %7B%0A    
             
@@ -2289,16 +2289,34 @@
 ing());%0A
+                %7D%0A
         

Fix possible NPE highlighted by Eclipse