bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1765722 - /bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
Date Wed, 19 Oct 2016 21:14:24 GMT
Author: mbenson
Date: Wed Oct 19 21:14:24 2016
New Revision: 1765722

URL: http://svn.apache.org/viewvc?rev=1765722&view=rev
Log:
[BVAL-137] Attempt to skip Weld proxy classes when discovering method validation metadata

Modified:
    bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java

Modified: bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java?rev=1765722&r1=1765721&r2=1765722&view=diff
==============================================================================
--- bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java (original)
+++ bval/trunk/bval-jsr/src/main/java/org/apache/bval/jsr/util/Proxies.java Wed Oct 19 21:14:24
2016
@@ -18,7 +18,19 @@
  */
 package org.apache.bval.jsr.util;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
 public final class Proxies {
+    private static final Set<String> KNOWN_PROXY_CLASSNAMES;
+
+    static {
+        final Set<String> s = new HashSet<String>();
+        s.add("org.jboss.weld.bean.proxy.ProxyObject");
+        KNOWN_PROXY_CLASSNAMES = Collections.unmodifiableSet(s); 
+    }
+
     // get rid of proxies which probably contains wrong annotation metamodel
     public static <T> Class<?> classFor(final Class<?> clazz) { // TODO:
do we want a SPI with impl for guice, owb, openejb, ...?
         if (isProxyClass(clazz)) {
@@ -31,7 +43,11 @@ public final class Proxies {
     }
 
     private static boolean isProxyClass(Class<?> clazz) {
-        return clazz.getSimpleName().contains("$$");// a lot of proxies use this convention
to avoid conflicts with inner/anonymous classes
+        final String simpleName = clazz.getSimpleName();
+        if (KNOWN_PROXY_CLASSNAMES.contains(simpleName)) {
+            return true;
+        }
+        return simpleName.contains("$$");// a lot of proxies use this convention to avoid
conflicts with inner/anonymous classes
     }
 
     private Proxies() {



Mime
View raw message