You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2012/05/30 03:41:15 UTC

svn commit: r1344071 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/catalina/core/DefaultInstanceManager.java webapps/docs/changelog.xml

Author: kkolinko
Date: Wed May 30 01:41:15 2012
New Revision: 1344071

URL: http://svn.apache.org/viewvc?rev=1344071&view=rev
Log:
Merged revision 1344068 from tomcat/trunk:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53322
Follow JavaBeans specification when converting setter method name into property name for resource injection.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1344068

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java?rev=1344071&r1=1344070&r2=1344071&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/DefaultInstanceManager.java Wed May 30 01:41:15 2012
@@ -19,6 +19,7 @@
 package org.apache.catalina.core;
 
 
+import java.beans.Introspector;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Field;
@@ -360,7 +361,7 @@ public class DefaultInstanceManager impl
                                 && methodName.length() > 3
                                 && method.getParameterTypes().length == 1
                                 && method.getReturnType().getName().equals("void")) {
-                            String fieldName = Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
+                            String fieldName = getName(method);
                             if (injections.containsKey(fieldName)) {
                                 annotations.add(new AnnotationCacheEntry(
                                         method.getName(),
@@ -661,15 +662,9 @@ public class DefaultInstanceManager impl
     }
 
     public static String getName(Method setter) {
-        StringBuilder name = new StringBuilder(setter.getName());
-
-        // remove 'set'
-        name.delete(0, 3);
-
-        // lowercase first char
-        name.setCharAt(0, Character.toLowerCase(name.charAt(0)));
-
-        return name.toString();
+        // Note: method signature has already been checked for correctness.
+        // The method name always starts with "set".
+        return Introspector.decapitalize(setter.getName().substring(3));
     }
 
     private static String normalize(String jndiName){

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1344071&r1=1344070&r2=1344071&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed May 30 01:41:15 2012
@@ -140,6 +140,11 @@
         the <code>JreMemoryLeakPreventionListener</code> does not trigger a
         full GC every hour. (markt)
       </fix>
+      <fix>
+        <bug>53322</bug>: When processing resource injection, correctly infer
+        property name from its setter method if the name starts with several
+        uppercase characters. (kkolinko)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



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