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

GlassFishProperties throws NPE if the Properties is null. #4657

Closed
andrewhabib opened this issue May 6, 2020 · 6 comments · Fixed by #5101
Closed

GlassFishProperties throws NPE if the Properties is null. #4657

andrewhabib opened this issue May 6, 2020 · 6 comments · Fixed by #5101
Assignees
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev

Comments

@andrewhabib
Copy link

Description


The properties class org.glassfish.embeddable.GlassFishProperties could silently be corrupt if initialized with a null Properties object.

Steps to reproduce (Only for bug reports)

The following instantiation would not produce any warning...

java.util.Properties properties0 = null;
org.glassfish.embeddable.GlassFishProperties glassFishProperties1 = new org.glassfish.embeddable.GlassFishProperties(properties0);

However, when you try to use any of the GlassFishProperties, you'd get NullPointerException.
E.g.:

glassFishProperties1.setConfigFileURI("path/to/config/file");

Therefore, constructors of GlassFishProperties should check for a null Properties object
or at least document the above behavior in the documentation.

@rdebusscher rdebusscher self-assigned this May 19, 2020
@rdebusscher rdebusscher added Easy to Contribute Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev labels May 19, 2020
@rdebusscher
Copy link

Hi Andrew,

Do you want to a submit a PR for this improvement? You can find the CLA here : https://github.com/payara/Payara/blob/master/PayaraCLA.pdf.

Regards
Rudy

@andrewhabib
Copy link
Author

Yes sure. But let's discuss how a fix should handle this case.
I see two different scenarios:

(1) Describe in the documentation that properties should not be null

(2) Or, check for properties being null and produce a warning or throw an NPE

What do you think?

@rdebusscher
Copy link

Hi Andrew,

I would check the parameter and throw a IllegalArgumentException (or NullPointerException) and document it in the JavaDoc.

bhanuunrivalled pushed a commit to bhanuunrivalled/Payara that referenced this issue Sep 27, 2020
@bhanuunrivalled
Copy link

Hi ,

I update it .

Please let me know the feedback .

Thanks,

@andrewhabib
Copy link
Author

Thanks @bhanuunrivalled ! This looks good to me.
@rdebusscher I will close the issue now.

@bhanuunrivalled
Copy link

Thank you @andrewhabib . I had the similar issue :)

lprimak added a commit that referenced this issue Jan 24, 2021
* #4657 GlassFishProperties throws NPE if the Properties is null

* cleanup of NPE handling

* fixes suggested by @dmatej

Co-authored-by: Bhanu Akula <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Accepted Confirmed defect or accepted improvement to implement, issue has been escalated to Platform Dev
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants