Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49994
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Oct 2010 11:57:04 +0000 (11:57 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 8 Oct 2010 11:57:04 +0000 (11:57 +0000)
Lookup of JNDI references should return a new object instance each time

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1005789 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/naming/NamingContext.java
java/org/apache/naming/NamingContextBindingsEnumeration.java

index 96315f0..fec3fc7 100644 (file)
@@ -797,10 +797,6 @@ public class NamingContext implements Context {
                 try {
                     Object obj = NamingManager.getObjectInstance
                         (entry.value, name, this, env);
-                    if (obj != null) {
-                        entry.value = obj;
-                        entry.type = NamingEntry.ENTRY;
-                    }
                     return obj; 
                 } catch (NamingException e) {
                     throw e;
index 3a618f8..918e513 100644 (file)
@@ -105,13 +105,13 @@ public class NamingContextBindingsEnumeration
     
     private Binding nextElementInternal() throws NamingException {
         NamingEntry entry = iterator.next();
+        Object value;
         
         // If the entry is a reference, resolve it
         if (entry.type == NamingEntry.REFERENCE
                 || entry.type == NamingEntry.LINK_REF) {
             try {
-                // A lookup will resolve the entry
-                ctx.lookup(new CompositeName(entry.name));
+                value = ctx.lookup(new CompositeName(entry.name));
             } catch (NamingException e) {
                 throw e;
             } catch (Exception e) {
@@ -119,12 +119,11 @@ public class NamingContextBindingsEnumeration
                 ne.initCause(e);
                 throw ne;
             }
+        } else {
+            value = entry.value;
         }
         
-        return new Binding(entry.name, entry.value.getClass().getName(), 
-                           entry.value, true);
+        return new Binding(entry.name, value.getClass().getName(), value, true);
     }
-
-
 }