openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bergm...@apache.org
Subject svn commit: r881889 - in /incubator/openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/config/ test/java/org/apache/webbeans/test/component/pfield/broken/ test/java/org/apache/webbeans/test/unittests/pfield/
Date Wed, 18 Nov 2009 19:23:12 GMT
Author: bergmark
Date: Wed Nov 18 19:23:11 2009
New Revision: 881889

URL: http://svn.apache.org/viewvc?rev=881889&view=rev
Log:
[OWB-172] Prevent the null pointer exception so the error can be properly reported later in
the processing.  Also add a unit test for this scenario.

Added:
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/pfield/broken/TypeVariableProducerField.java
  (with props)
Modified:
    incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
    incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/pfield/ProducerFieldComponentTest.java

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java?rev=881889&r1=881888&r2=881889&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/DefinitionUtil.java
Wed Nov 18 19:23:11 2009
@@ -227,7 +227,7 @@
             
             Class<?> clazz  = ClassUtil.getClazz(type);
             
-            if (clazz.isPrimitive() || clazz.isArray())
+            if (clazz != null && (clazz.isPrimitive() || clazz.isArray()))
             {
                 types.add(clazz);
 

Added: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/pfield/broken/TypeVariableProducerField.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/pfield/broken/TypeVariableProducerField.java?rev=881889&view=auto
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/pfield/broken/TypeVariableProducerField.java
(added)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/pfield/broken/TypeVariableProducerField.java
Wed Nov 18 19:23:11 2009
@@ -0,0 +1,24 @@
+/*
+ *  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.test.component.pfield.broken;
+
+import javax.enterprise.inject.Produces;
+
+public class TypeVariableProducerField<T>
+{
+    private @Produces T xt;
+}

Propchange: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/pfield/broken/TypeVariableProducerField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/pfield/ProducerFieldComponentTest.java
URL: http://svn.apache.org/viewvc/incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/pfield/ProducerFieldComponentTest.java?rev=881889&r1=881888&r2=881889&view=diff
==============================================================================
--- incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/pfield/ProducerFieldComponentTest.java
(original)
+++ incubator/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/pfield/ProducerFieldComponentTest.java
Wed Nov 18 19:23:11 2009
@@ -27,6 +27,7 @@
 import org.apache.webbeans.test.component.pfield.ProducerFieldDefinitionParameterized;
 import org.apache.webbeans.test.component.pfield.ProducerFieldInjectedComponent;
 import org.apache.webbeans.test.component.pfield.ProducerFieldInjectedWrongType;
+import org.apache.webbeans.test.component.pfield.broken.TypeVariableProducerField;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -96,5 +97,23 @@
         Assert.assertNull(instance);
         Assert.assertTrue(expected instanceof javax.enterprise.inject.UnsatisfiedResolutionException);
     }
+    
+    @Test
+    public void testProducerFieldTypeVariable()
+    {
+        ContextFactory.initRequestContext(null);
+        
+        Exception expected = null;
+        try
+        {
+            defineManagedBean(TypeVariableProducerField.class);
+        }
+        catch(Exception caught){
+            System.out.println(caught.getMessage());
+            expected = caught;
+        }
+        Assert.assertNotNull(expected);
+        Assert.assertTrue(expected instanceof org.apache.webbeans.exception.WebBeansConfigurationException);
+    }
 
 }



Mime
View raw message