Author: markt
Date: Mon Jun  4 19:38:00 2012
New Revision: 1346107

URL: http://svn.apache.org/viewvc?rev=1346107&view=rev
Log:
Rework fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=53333

Modified:
    tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java

Modified: tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java?rev=1346107&r1=1346106&r2=1346107&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java (original)
+++ tomcat/trunk/java/org/apache/catalina/deploy/NamingResources.java Mon Jun  
4 19:38:00 2012
@@ -1143,24 +1143,20 @@ public class NamingResources extends Lif
             }
         }
 
-        Class<?> injectionClass = getInjectionTargetType(context, resource);
-        if (injectionClass == null) {
+        Class<?> compatibleClass =
+                getCompatibleType(context, resource, typeClass);
+        if (compatibleClass == null) {
             // Indicates that a compatible type could not be identified that
             // worked for all injection targets
             return false;
         }
 
-        if (typeClass == null) {
-                // Only injectionTarget defined - use it
-                resource.setType(injectionClass.getCanonicalName());
-                return true;
-        } else {
-            return injectionClass.isAssignableFrom(typeClass);
-        }
+        resource.setType(compatibleClass.getCanonicalName());
+        return true;
     }
 
-    private Class<?> getInjectionTargetType(Context context,
-            ResourceBase resource) {
+    private Class<?> getCompatibleType(Context context,
+            ResourceBase resource, Class<?> typeClass) {
 
         Class<?> result = null;
 
@@ -1186,17 +1182,28 @@ public class NamingResources extends Lif
             }
             targetType = convertPrimitiveType(targetType);
 
-            // Figure out the common type - if there is one
-            if (result == null) {
-                result = targetType;
-            } else if (targetType.isAssignableFrom(result)) {
-                // NO-OP - This will work
-            } else if (result.isAssignableFrom(targetType)) {
-                // Need to use more specific type
-                result = targetType;
+            if (typeClass == null) {
+                // Need to find a common type amongst the injection targets
+                if (result == null) {
+                    result = targetType;
+                } else if (targetType.isAssignableFrom(result)) {
+                    // NO-OP - This will work
+                } else if (result.isAssignableFrom(targetType)) {
+                    // Need to use more specific type
+                    result = targetType;
+                } else {
+                    // Incompatible types
+                    return null;
+                }
             } else {
-                // Incompatible types
-                return null;
+                // Each injection target needs to be consistent with the 
defined
+                // type
+                if (targetType.isAssignableFrom(typeClass)) {
+                    result = typeClass;
+                } else {
+                    // Incompatible types
+                    return null;
+                }
             }
         }
         return result;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to