This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4a0bb04e19612a6d42582422c05f0ad281c4de93
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri May 24 08:35:07 2019 +0200

    CAMEL-13566: IntrospectionSupport - Remove old legacy JDK PropertyEditor
---
 .../apache/camel/support/IntrospectionSupport.java | 33 ++--------------------
 .../camel/support/PropertyBindingSupport.java      |  1 -
 2 files changed, 2 insertions(+), 32 deletions(-)

diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
index 6af2cec..17d8d79 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/IntrospectionSupport.java
@@ -16,13 +16,9 @@
  */
 package org.apache.camel.support;
 
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -68,7 +64,6 @@ public final class IntrospectionSupport {
     // which could prevent classloader to unload classes if being referenced 
from this cache
     @SuppressWarnings("unchecked")
     private static final Map<Class<?>, ClassInfo> CACHE = 
LRUCacheFactory.newLRUWeakCache(1000);
-    private static final Object LOCK = new Object();
     private static final Pattern SECRETS = 
Pattern.compile(".*(passphrase|password|secretKey).*", 
Pattern.CASE_INSENSITIVE);
 
     static {
@@ -136,9 +131,6 @@ public final class IntrospectionSupport {
             LOG.debug("Clearing cache[size={}, hits={}, misses={}, 
evicted={}]", localCache.size(), localCache.getHits(), localCache.getMisses(), 
localCache.getEvicted());
         }
         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) {
@@ -610,13 +602,13 @@ public final class IntrospectionSupport {
                         return true;
                     } else {
                         // We need to convert it
-                        Object convertedValue = convert(typeConverter, 
parameterType, ref);
+                        Object convertedValue = 
typeConverter.convertTo(parameterType, ref);
                         // we may want to set options on classes that has 
package view visibility, so override the accessible
                         setter.setAccessible(true);
                         setter.invoke(target, convertedValue);
                         if (LOG.isTraceEnabled()) {
                             // hide sensitive data
-                            String val = ref != null ? ref.toString() : "";
+                            String val = ref.toString();
                             if (SECRETS.matcher(name).find()) {
                                 val = "xxxxxx";
                             }
@@ -695,27 +687,6 @@ public final class IntrospectionSupport {
         return setProperty(target, name, value, true);
     }
 
-    static Object convert(TypeConverter typeConverter, Class<?> type, Object 
value)
-        throws URISyntaxException, NoTypeConversionAvailableException {
-        if (typeConverter != null) {
-            return typeConverter.mandatoryConvertTo(type, value);
-        }
-        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 (LOCK) {
-                editor.setAsText(value.toString());
-                answer = editor.getValue();
-            }
-            return answer;
-        }
-        return null;
-    }
-
     public static Set<Method> findSetterMethods(Class<?> clazz, String name, 
boolean allowBuilderPattern) {
         Set<Method> candidates = new LinkedHashSet<>();
 
diff --git 
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
 
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
index 79916c9..cddf4fe 100644
--- 
a/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
+++ 
b/core/camel-support/src/main/java/org/apache/camel/support/PropertyBindingSupport.java
@@ -44,7 +44,6 @@ import static 
org.apache.camel.support.IntrospectionSupport.getOrElseProperty;
 public final class PropertyBindingSupport {
 
     // TODO: Add support for Map/List
-    // TODO: Add option to turn this binding on|off on component/endpoint level
 
     /**
      * To use a fluent builder style to configure this property binding 
support.

Reply via email to