aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1739703 - in /aries/trunk/jpa/jpa-blueprint/src: main/java/org/apache/aries/jpa/blueprint/impl/ test/java/org/apache/aries/jpa/blueprint/impl/
Date Mon, 18 Apr 2016 08:01:56 GMT
Author: cschneider
Date: Mon Apr 18 08:01:56 2016
New Revision: 1739703

URL: http://svn.apache.org/viewvc?rev=1739703&view=rev
Log:
[ARIES-1533] Make sure interfaces do not cause a NPE

Added:
    aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
Modified:
    aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
    aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java

Modified: aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java?rev=1739703&r1=1739702&r2=1739703&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
(original)
+++ aries/trunk/jpa/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
Mon Apr 18 08:01:56 2016
@@ -29,7 +29,7 @@ public class AnnotationScanner {
 
     public List<AccessibleObject> getJpaAnnotatedMembers(Class<?> c, Class<?
extends Annotation> annotation) {
         final List<AccessibleObject> jpaAnnotated = new ArrayList<AccessibleObject>();
-        for (Class<?> cl = c; cl != Object.class; cl = cl.getSuperclass()) {  
+        for (Class<?> cl = c; cl != Object.class && cl != null; cl = cl.getSuperclass())
{
             parseClass(annotation, jpaAnnotated, cl);
         }
         return jpaAnnotated;

Modified: aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java?rev=1739703&r1=1739702&r2=1739703&view=diff
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
(original)
+++ aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
Mon Apr 18 08:01:56 2016
@@ -87,5 +87,14 @@ public class AnnotationScannerTest {
         Assert.assertEquals("setEmf", method.getName());
     }
 
+    /**
+     * When using a factory the class can be an interface. We need to make sure this does
not cause a NPE
+     */
+    @Test
+    public void getFactoryTest() {
+        AnnotationScanner scanner = new AnnotationScanner();
+        List<AccessibleObject> members = scanner.getJpaAnnotatedMembers(TestInterface.class,
PersistenceUnit.class);
+        Assert.assertEquals(0, members.size());
+    }
     
 }

Added: aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java?rev=1739703&view=auto
==============================================================================
--- aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
(added)
+++ aries/trunk/jpa/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
Mon Apr 18 08:01:56 2016
@@ -0,0 +1,5 @@
+package org.apache.aries.jpa.blueprint.impl;
+
+public interface TestInterface {
+
+}



Mime
View raw message