Author: davsclaus
Date: Fri Oct  5 07:10:18 2012
New Revision: 1394387

URL: http://svn.apache.org/viewvc?rev=1394387&view=rev
Log:
CAMEL-5675: Flush java bean introspector cache when stopping Camel. And 
property editor is not thread safe.

Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=1394387&r1=1394386&r2=1394387&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
 Fri Oct  5 07:10:18 2012
@@ -103,6 +103,9 @@ public final class IntrospectionSupport 
             LOG.debug("Clearing cache[size={}, hits={}, misses={}]", new 
Object[]{CACHE.size(), CACHE.getHits(), CACHE.getMisses()});
         }
         CACHE.clear();
+
+        // flush java beans introspector as it may be in use by the 
PropertyEditor
+        java.beans.Introspector.flushCaches();
     }
 
     public static boolean isGetter(Method method) {
@@ -484,14 +487,19 @@ public final class IntrospectionSupport 
         if (typeConverter != null) {
             return typeConverter.mandatoryConvertTo(type, value);
         }
-        PropertyEditor editor = PropertyEditorManager.findEditor(type);
-        if (editor != null) {
-            editor.setAsText(value.toString());
-            return editor.getValue();
-        }
         if (type == URI.class) {
             return new URI(value.toString());
         }
+        PropertyEditor editor = PropertyEditorManager.findEditor(type);
+        if (editor != null) {
+            // property editor is not thread safe, so we need to lock
+            Object answer;
+            synchronized (editor) {
+                editor.setAsText(value.toString());
+                answer = editor.getValue();
+            }
+            return answer;
+        }
         return null;
     }
     


Reply via email to