You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bval.apache.org by ju...@apache.org on 2025/03/19 07:36:45 UTC
(bval) branch master updated: BVAL-223 - Fix NPE in BValExtension
This is an automated email from the ASF dual-hosted git repository.
jungm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bval.git
The following commit(s) were added to refs/heads/master by this push:
new 4366077 BVAL-223 - Fix NPE in BValExtension
4366077 is described below
commit 43660774b3ddef5c57623820c0b7f2a9d15e23c8
Author: Markus Jung <ju...@apache.org>
AuthorDate: Wed Mar 19 08:36:09 2025 +0100
BVAL-223 - Fix NPE in BValExtension
---
.../src/main/java/org/apache/bval/cdi/BValExtension.java | 2 +-
.../bval/jsr/cdi/CdiConstraintOnlyOnParentClassTest.java | 14 +++++++++++---
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java b/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java
index 20467eb..f5723b0 100644
--- a/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java
+++ b/bval-jsr/src/main/java/org/apache/bval/cdi/BValExtension.java
@@ -149,7 +149,7 @@ public class BValExtension implements Extension {
}
// Nothing found, collect superclass/interface and repeat (See BVAL-222)
- if (now.getSuperclass() != Object.class) {
+ if (now.getSuperclass() != Object.class && now.getSuperclass() != null) {
toProcess.add(now.getSuperclass());
}
diff --git a/bval-jsr/src/test/java/org/apache/bval/jsr/cdi/CdiConstraintOnlyOnParentClassTest.java b/bval-jsr/src/test/java/org/apache/bval/jsr/cdi/CdiConstraintOnlyOnParentClassTest.java
index 1713a6e..dc1c8e2 100644
--- a/bval-jsr/src/test/java/org/apache/bval/jsr/cdi/CdiConstraintOnlyOnParentClassTest.java
+++ b/bval-jsr/src/test/java/org/apache/bval/jsr/cdi/CdiConstraintOnlyOnParentClassTest.java
@@ -33,13 +33,15 @@ import org.junit.Test;
import org.junit.rules.ExternalResource;
import org.junit.runner.RunWith;
+import java.io.Serializable;
+
@RunWith(Arquillian.class)
public class CdiConstraintOnlyOnParentClassTest {
@ClassRule
public static ExternalResource allowMyServiceImplType = new ExternalResource() {
@Override
protected void before() throws Throwable {
- BValExtension.setAnnotatedTypeFilter(at -> at.getJavaClass() == GreetingServiceImpl.class);
+ BValExtension.setAnnotatedTypeFilter(at -> at.getJavaClass() == LastGreetingService.class);
}
@Override
@@ -54,7 +56,7 @@ public class CdiConstraintOnlyOnParentClassTest {
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class)
- .addClasses(GreetingService.class, GreetingServiceImpl.class);
+ .addClasses(GreetingService.class, GreetingServiceImpl.class, IntermediateGreetingService.class, LastGreetingService.class);
}
@Test
@@ -66,10 +68,16 @@ public class CdiConstraintOnlyOnParentClassTest {
void greet(@NotNull String name);
}
- @ApplicationScoped
public static class GreetingServiceImpl implements GreetingService {
@Override
public void greet(String name) {
}
}
+
+ public static class IntermediateGreetingService extends GreetingServiceImpl {
+ }
+
+ @ApplicationScoped
+ public static class LastGreetingService extends IntermediateGreetingService implements Serializable {
+ }
}