cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1433305 - in /cxf/trunk/api/src: main/java/org/apache/cxf/common/util/ASMHelper.java test/java/org/apache/cxf/common/util/ASMHelperTest.java
Date Tue, 15 Jan 2013 08:04:52 GMT
Author: ema
Date: Tue Jan 15 08:04:51 2013
New Revision: 1433305

URL: http://svn.apache.org/viewvc?rev=1433305&view=rev
Log:
CXF-4755- StackOverflowError when ASMHelper tries to getClassCode from a parametrized type
<E extends Enum>

Added:
    cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java   (with props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java?rev=1433305&r1=1433304&r2=1433305&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/common/util/ASMHelper.java Tue Jan 15 08:04:51
2013
@@ -192,12 +192,15 @@ public class ASMHelper {
         } else if (type instanceof ParameterizedType) {
             ParameterizedType pt = (ParameterizedType)type;
             StringBuilder a = new StringBuilder(getClassCode(pt.getRawType()));
-            a.setLength(a.length() - 1);
-            a.append('<');
-            for (java.lang.reflect.Type t : pt.getActualTypeArguments()) {
-                a.append(getClassCode(t));  
+            if (!pt.getRawType().equals(Enum.class)) {
+                a.setLength(a.length() - 1);
+                a.append('<');
+
+                for (java.lang.reflect.Type t : pt.getActualTypeArguments()) {
+                    a.append(getClassCode(t));
+                }
+                a.append(">;");
             }
-            a.append(">;");
             return a.toString();
         } else if (type instanceof WildcardType) {
             WildcardType wt = (WildcardType)type;

Added: cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java?rev=1433305&view=auto
==============================================================================
--- cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java (added)
+++ cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java Tue Jan 15 08:04:51
2013
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.common.util;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ASMHelperTest extends Assert {
+    @Test
+    public void testEnumParamType() throws Exception {
+        Method method = EnumTest.class.getMethod("test", new Class[] {
+            EnumObject.class
+        });
+        Type[] types = method.getGenericParameterTypes();
+        String classCode = ASMHelper.getClassCode(types[0]);
+        assertEquals("Lorg/apache/cxf/common/util/ASMHelperTest$EnumObject<Ljava/lang/Enum;>;",
classCode);
+    }
+
+    public class EnumObject<E extends Enum<E>> {
+        private String name;
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String param) {
+            this.name = param;
+        }
+    }
+
+    public class EnumTest {
+        public <T extends Enum<T>> EnumObject<T> test(EnumObject<T>
o) {
+            return o;
+        }
+    }
+
+}

Propchange: cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/api/src/test/java/org/apache/cxf/common/util/ASMHelperTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message