Markus Jung created BVAL-223:
--------------------------------

             Summary: NullPointerException in BValExtension
                 Key: BVAL-223
                 URL: https://issues.apache.org/jira/browse/BVAL-223
             Project: BVal
          Issue Type: Bug
          Components: jsr303
    Affects Versions: 3.0.2
            Reporter: Markus Jung
            Assignee: Markus Jung


The fix for BVAL-222 was incomplete and introduced a regression that causes the 
BValExtension to throw NullPointerExceptions
{code:java}
INFO: OpenWebBeans Container is starting...
Mar 19, 2025 8:09:01 AM org.apache.bval.cdi.BValExtension processAnnotatedType
INFO: Cannot invoke "java.lang.Class.getMethods()" because "now" is null {code}
 

Updating the example in CdiConstraintOnlyOnParentClassTest like this also makes 
the test fail again:
{code:java}
@RunWith(Arquillian.class)
public class CdiConstraintOnlyOnParentClassTest {
    @ClassRule
    public static ExternalResource allowMyServiceImplType = new 
ExternalResource() {
        @Override
        protected void before() throws Throwable {
            BValExtension.setAnnotatedTypeFilter(at -> at.getJavaClass() == 
LastGreetingService.class);
        }

        @Override
        protected void after() {
            
BValExtension.setAnnotatedTypeFilter(BValExtension.DEFAULT_ANNOTATED_TYPE_FILTER);
        }
    };

    @Inject
    private GreetingService service;

    @Deployment
    public static JavaArchive createDeployment() {
        return ShrinkWrap.create(JavaArchive.class)
                .addClasses(GreetingService.class, GreetingServiceImpl.class, 
IntermediateGreetingService.class, LastGreetingService.class);
    }

    @Test
    public void validationFail() {
        Assert.assertThrows(ConstraintViolationException.class, () -> 
service.greet(null));
    }

    public interface GreetingService {
        void greet(@NotNull String name);
    }

    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 {
    }
} {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to