commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1352055 - in /commons/proper/digester/trunk/core/src: main/java/org/apache/commons/digester3/binder/BinderClassLoader.java test/java/org/apache/commons/digester3/binder/BinderClassLoaderTestCase.java
Date Wed, 20 Jun 2012 12:21:40 GMT
Author: simonetripodi
Date: Wed Jun 20 12:21:40 2012
New Revision: 1352055

URL: http://svn.apache.org/viewvc?rev=1352055&view=rev
Log:
[DIGESTER-165] BinderClassLoader does not override getResource - patch provided by Dirk Schaube

Modified:
    commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/BinderClassLoader.java
    commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/BinderClassLoaderTestCase.java

Modified: commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/BinderClassLoader.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/BinderClassLoader.java?rev=1352055&r1=1352054&r2=1352055&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/BinderClassLoader.java
(original)
+++ commons/proper/digester/trunk/core/src/main/java/org/apache/commons/digester3/binder/BinderClassLoader.java
Wed Jun 20 12:21:40 2012
@@ -65,17 +65,14 @@ final class BinderClassLoader
         return action.run();
     }
 
-    private final ClassLoader adaptedClassLoader;
-
     private BinderClassLoader( ClassLoader adaptedClassLoader )
     {
         super( adaptedClassLoader );
-        this.adaptedClassLoader = adaptedClassLoader;
     }
 
     public ClassLoader getAdaptedClassLoader()
     {
-        return adaptedClassLoader;
+        return getParent();
     }
 
     /**
@@ -89,7 +86,7 @@ final class BinderClassLoader
         {
             return PRIMITIVE_TYPES.get( name );
         }
-        return adaptedClassLoader.loadClass( name );
+        return getParent().loadClass( name );
     }
 
 }

Modified: commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/BinderClassLoaderTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/BinderClassLoaderTestCase.java?rev=1352055&r1=1352054&r2=1352055&view=diff
==============================================================================
--- commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/BinderClassLoaderTestCase.java
(original)
+++ commons/proper/digester/trunk/core/src/test/java/org/apache/commons/digester3/binder/BinderClassLoaderTestCase.java
Wed Jun 20 12:21:40 2012
@@ -21,6 +21,9 @@ package org.apache.commons.digester3.bin
 
 import static org.apache.commons.digester3.binder.BinderClassLoader.createBinderClassLoader;
 import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URL;
 
 import org.junit.Test;
 
@@ -95,4 +98,25 @@ public final class BinderClassLoaderTest
         assertSame( expected, actual );
     }
 
+    @Test
+    public void testGetResource()
+    {
+        ClassLoader clToAdapt = new ClassLoader()
+        {
+
+            @Override
+            public URL getResource( String name )
+            {
+                if ( "xxx".equals( name ) )
+                {
+                    return super.getResource( "org/apache/commons/digester3/binder/BinderClassLoaderTestCase.class"
);
+                }
+                return super.getResource( name );
+            }
+
+        };
+        ClassLoader binderCl = createBinderClassLoader( clToAdapt );
+        assertNotNull( binderCl.getResource( "xxx" ) );
+    }
+
 }



Mime
View raw message