cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1562241 - /cxf/branches/2.7.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Date Tue, 28 Jan 2014 21:29:05 GMT
Author: dkulp
Date: Tue Jan 28 21:29:05 2014
New Revision: 1562241

URL: http://svn.apache.org/r1562241
Log:
Merged revisions 1562238 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1562238 | dkulp | 2014-01-28 16:24:38 -0500 (Tue, 28 Jan 2014) | 3 lines

  [CXF-5524] More addType fixes
  Patch from Denis Simonov, although hard to apply and may have missed something

........

Modified:
    cxf/branches/2.7.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java

Modified: cxf/branches/2.7.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1562241&r1=1562240&r2=1562241&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
Tue Jan 28 21:29:05 2014
@@ -232,10 +232,13 @@ class JAXBContextInitializer extends Ser
                 addClass((Class<?>)cls);
             }
         } else if (cls instanceof ParameterizedType) {
-            addType(((ParameterizedType)cls).getRawType());
-            if (!((ParameterizedType)cls).getRawType().equals(Enum.class)) {
-                for (Type t2 : ((ParameterizedType)cls).getActualTypeArguments()) {
-                    addType(t2);
+            final ParameterizedType parameterizedType = (ParameterizedType)cls;
+            addType(parameterizedType.getRawType());
+            if (!parameterizedType.getRawType().equals(Enum.class)) {
+                for (Type t2 : parameterizedType.getActualTypeArguments()) {
+                    if (shouldTypeBeAdded(t2, parameterizedType)) {
+                        addType(t2);
+                    }
                 }
             }
         } else if (cls instanceof GenericArrayType) {
@@ -274,7 +277,20 @@ class JAXBContextInitializer extends Ser
         }
     }
 
-
+    private boolean shouldTypeBeAdded(final Type t2, final ParameterizedType parameterizedType)
{
+        if (!(t2 instanceof TypeVariable)) {
+            return true;
+        }
+        TypeVariable<?> typeVariable = (TypeVariable<?>) t2;
+        final Type[] bounds = typeVariable.getBounds();
+        for (Type bound : bounds) {
+            if (bound instanceof ParameterizedType && bound.equals(parameterizedType))
{
+                return false;
+            }
+        }
+        return true;
+    }
+    
     void addClass(Class<?> claz) {
         if (Throwable.class.isAssignableFrom(claz)) {
             if (!Throwable.class.equals(claz)



Mime
View raw message