Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds null protection in case of classes have no package. #12

Merged
merged 2 commits into from
Feb 29, 2016

Conversation

lordofthejars
Copy link
Contributor

@reviewbybees

@ghost
Copy link

ghost commented Feb 26, 2016

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.


final String name = aPackage.getName();

if (name == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impossible.

@jglick
Copy link
Member

jglick commented Feb 26, 2016

🐛 forgot null protection in several other places, such as permitsConstructor.

Recommend adding a regression test. Should be easy.

@lordofthejars
Copy link
Contributor Author

I know that there are other places, in fact I try to touch as less lines as possible and I fixes the problem I had now. But now that you mention this I will fix as well.

@lordofthejars
Copy link
Contributor Author

@jglick now I am not sure what you mean by doing a regression test for checking nulls, it comes to my mind a unit test but nothing more

@jglick
Copy link
Member

jglick commented Feb 26, 2016

I am not sure what you mean by doing a regression test for checking nulls

Well, you hit an NPE somehow, obviously. So you use JenkinsRule to create a WorkflowJob that does that same thing, and make sure it builds successfully.

@@ -163,7 +171,17 @@ public boolean permitsMethod(Method method, Object receiver, Object[] args) {

@Override
public boolean permitsConstructor(@Nonnull Constructor<?> constructor, @Nonnull Object[] args) {
return constructor.getDeclaringClass().getPackage().getName().equals(ORG_APACHE_MAVEN_MODEL);
if (constructor == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐜 obviously not possible, given the annotation.

@jglick
Copy link
Member

jglick commented Feb 26, 2016

🐝

@rsandell
Copy link
Member

Looks good, just needs a test or two.

@lordofthejars
Copy link
Contributor Author

The problem is that I dont know why the NPE was thrown with a simple read,
I mean it happens but don t know why exactly my simple readManifest fails
El 26 feb. 2016 7:32 p. m., "Robert Sandell" notifications@github.com
escribió:

Looks good, just needs a test or two.


Reply to this email directly or view it on GitHub
#12 (comment)
.

@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@lordofthejars
Copy link
Contributor Author

@rsandell I am trying to reproduce in a simple test the error that a package is null, but it is not possible,I have tried several things like executing code from external groovy script, using text or file attributes so I don't know exactly when the permitsMethod is called with a method without package.

@rsandell
Copy link
Member

ok, thank you for trying. But as Jesse said, you did get the exception somehow in your own pipeline scripts, so it should be reproducible :).

rsandell added a commit that referenced this pull request Feb 29, 2016
adds null protection in case of classes have no package.
@rsandell rsandell merged commit 6e60299 into jenkinsci:master Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants