You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltaspike.apache.org by "Tobias Rettstadt (JIRA)" <ji...@apache.org> on 2015/02/06 08:42:34 UTC

[jira] [Commented] (DELTASPIKE-831) NPE in DefaultMockFilter when running JUnit and the application contains a class in the default package

    [ https://issues.apache.org/jira/browse/DELTASPIKE-831?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14308787#comment-14308787 ] 

Tobias Rettstadt commented on DELTASPIKE-831:
---------------------------------------------

Yes, it's an anti-pattern, but in my case I had to create a ValidationMessage class in the default package, because JSR-303 validation does not allow to change the location of the ValidationMessage.properties file and we wanted to use an existing resource bundle for validation messages. Of course I would not put my CDI beans in the default package. So since a non-CDI class in the default package causes this error and it's a really easy fix: Why not fix it?

> NPE in DefaultMockFilter when running JUnit and the application contains a class in the default package
> -------------------------------------------------------------------------------------------------------
>
>                 Key: DELTASPIKE-831
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-831
>             Project: DeltaSpike
>          Issue Type: Bug
>          Components: TestControl
>    Affects Versions: 1.2.1
>         Environment: JUnit+Deltaspike+OpenEJB 4.6.0 on Windows 7, Oracle JDK 7
>            Reporter: Tobias Rettstadt
>
> Running a unit test results in a NPE if the application contains a class in the default package. The problem is line 67 of {{org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter}} where
> {{isInternalPackage(origin.getPackage().getName())}} is called without checking if {{getPackage()}} returns null.
> Suggested fix: Change line 67 to
> {code}
>         return origin != null && (origin.getPackage() == null || !isInternalPackage(origin.getPackage().getName()));
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)