You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by be...@apache.org on 2010/10/12 20:20:19 UTC

svn commit: r1021872 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/portable/ test/java/org/apache/webbeans/newtests/promethods/ test/java/org/apache/webbeans/newtests/promethods/beans/

Author: bergmark
Date: Tue Oct 12 18:20:19 2010
New Revision: 1021872

URL: http://svn.apache.org/viewvc?rev=1021872&view=rev
Log:
[OWB-471] Stop AnnotatedParameter's toString from calling toString on its callable as that may create an infinite loop and resulting StackOverflowException.

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/ProducerBean.java   (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/MethodProducer1Test.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java?rev=1021872&r1=1021871&r2=1021872&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/AnnotatedParameterImpl.java Tue Oct 12 18:20:19 2010
@@ -69,7 +69,6 @@ class AnnotatedParameterImpl<X> extends 
         builder.append("Annotated Parameter");
         builder.append(",");
         builder.append(super.toString()+ ",");
-        builder.append("Annotated Callable : [" + this.declaringCallable.toString() + "],");
         builder.append("Position : " + position);
         
         return builder.toString();

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/MethodProducer1Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/MethodProducer1Test.java?rev=1021872&r1=1021871&r2=1021872&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/MethodProducer1Test.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/MethodProducer1Test.java Tue Oct 12 18:20:19 2010
@@ -24,7 +24,9 @@ import java.util.Collection;
 import java.util.Set;
 
 import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.AnnotatedType;
 import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionTarget;
 
 import junit.framework.Assert;
 
@@ -32,6 +34,7 @@ import org.apache.webbeans.component.Man
 import org.apache.webbeans.newtests.AbstractUnitTest;
 import org.apache.webbeans.newtests.promethods.beans.InjectorofMethod1Bean;
 import org.apache.webbeans.newtests.promethods.beans.MethodTypeProduces1;
+import org.apache.webbeans.newtests.promethods.beans.ProducerBean;
 import org.junit.Test;
 
 public class MethodProducer1Test extends AbstractUnitTest
@@ -68,4 +71,26 @@ public class MethodProducer1Test extends
         
         shutDownContainer();
     }
+    
+    @Test
+    @SuppressWarnings("unchecked")
+    /**
+     * Tests the code path of adding a bean containing producer methods through 
+     * WebBeansAnnotatedTypeUtil.defineManagedBean
+     */
+    public void testProducerAddedByWebBeansAnnotatedTypeUtil()
+    {
+        Collection<URL> beanXmls = new ArrayList<URL>();
+        
+        Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+        
+        startContainer(beanClasses, beanXmls);  
+        
+        AnnotatedType<ProducerBean> at = getBeanManager().createAnnotatedType(ProducerBean.class);
+        InjectionTarget<ProducerBean> it = getBeanManager().createInjectionTarget(at);
+        
+        Assert.assertNotNull(it);
+        
+        shutDownContainer();
+    }
 }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/ProducerBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/ProducerBean.java?rev=1021872&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/ProducerBean.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/ProducerBean.java Tue Oct 12 18:20:19 2010
@@ -0,0 +1,40 @@
+/*
+ * 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.webbeans.newtests.promethods.beans;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+/**
+ * Bean with ProducerMethods to drive through the WebBeansAnnotatedTypeUtil codepath.
+ */
+
+@Named("producerBean")
+public class ProducerBean
+{
+    
+    @Produces StringBuffer createSomeStringBuffer(String content){
+        return new StringBuffer(content);
+    }
+    
+    @Produces String createMyString(){
+        return "Trying to create a loop";
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/promethods/beans/ProducerBean.java
------------------------------------------------------------------------------
    svn:eol-style = native