aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [03/50] aries-jpa git commit: [ARIES-1533] Make sure interfaces do not cause a NPE
Date Tue, 18 Apr 2017 12:54:55 GMT
[ARIES-1533] Make sure interfaces do not cause a NPE

git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/jpa@1739703 13f79535-47bb-0310-9956-ffa450edef68


Project: http://git-wip-us.apache.org/repos/asf/aries-jpa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jpa/commit/7bd8dc54
Tree: http://git-wip-us.apache.org/repos/asf/aries-jpa/tree/7bd8dc54
Diff: http://git-wip-us.apache.org/repos/asf/aries-jpa/diff/7bd8dc54

Branch: refs/heads/master
Commit: 7bd8dc5489258950113eb7cd63068b57deca82b0
Parents: 5f03952
Author: cschneider <cschneider@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Mon Apr 18 08:01:56 2016 +0000
Committer: cschneider <cschneider@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Mon Apr 18 08:01:56 2016 +0000

----------------------------------------------------------------------
 .../apache/aries/jpa/blueprint/impl/AnnotationScanner.java  | 2 +-
 .../aries/jpa/blueprint/impl/AnnotationScannerTest.java     | 9 +++++++++
 .../org/apache/aries/jpa/blueprint/impl/TestInterface.java  | 5 +++++
 3 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/7bd8dc54/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
----------------------------------------------------------------------
diff --git a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
index 4ec46ae..8fec169 100644
--- a/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
+++ b/jpa-blueprint/src/main/java/org/apache/aries/jpa/blueprint/impl/AnnotationScanner.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/7bd8dc54/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
----------------------------------------------------------------------
diff --git a/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
b/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
index d317cee..ebd3b85 100644
--- a/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
+++ b/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/AnnotationScannerTest.java
@@ -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());
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/7bd8dc54/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
----------------------------------------------------------------------
diff --git a/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
b/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
new file mode 100644
index 0000000..87303f8
--- /dev/null
+++ b/jpa-blueprint/src/test/java/org/apache/aries/jpa/blueprint/impl/TestInterface.java
@@ -0,0 +1,5 @@
+package org.apache.aries.jpa.blueprint.impl;
+
+public interface TestInterface {
+
+}


Mime
View raw message