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

NPE protection on WebInfConfiguration.deconfigure() #5481

Merged
merged 5 commits into from Oct 20, 2020

Conversation

joakime
Copy link
Contributor

@joakime joakime commented Oct 20, 2020

  • NPE protection on IO.delete(File)
  • Fail in jetty-maven-plugin if unable to create temp directory.
  • NPE protection in WebInfConfiguration.deconfigure()
  • Removing Temp dir forced deletion in WebInfConfiguration.configureTempDirectory()

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
…ectory.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
+ Removing Temp dir deletion in configureTempDirectory()

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime linked an issue Oct 20, 2020 that may be closed by this pull request
@joakime joakime self-assigned this Oct 20, 2020
@joakime joakime added the Bug For general bugs on Jetty side label Oct 20, 2020
@joakime joakime added this to In progress in Jetty 9.4.33 via automation Oct 20, 2020
@joakime joakime moved this from In progress to Review in progress in Jetty 9.4.33 Oct 20, 2020
@@ -355,7 +355,7 @@ public void configure(WebAppContext context) throws Exception
public void deconfigure(WebAppContext context) throws Exception
{
//if we're not persisting the temp dir contents delete it
if (!context.isPersistTempDirectory())
if (!context.isPersistTempDirectory() && context.getTempDirectory() != null && context.getTempDirectory().exists())
Copy link
Contributor

Choose a reason for hiding this comment

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

assign getTempDirectory() to a variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
//if dir exists and we don't want it persisted, delete it
if (dir.exists() && !context.isPersistTempDirectory())
// if dir exists and we don't want it persisted, delete it
if (!context.isPersistTempDirectory() && dir.exists() && !IO.delete(dir))
Copy link
Contributor

Choose a reason for hiding this comment

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

how hard is it to check if it is empty or not. if it is empty, it would be good to avoid deleting it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not to terrible to check if empty.
Let me try.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been implemented and is available in this PR.

Copy link
Contributor

@janbartel janbartel left a comment

Choose a reason for hiding this comment

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

LGTM

Jetty 9.4.33 automation moved this from Review in progress to Reviewer approved Oct 20, 2020
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
@joakime joakime merged commit f4c55c6 into jetty-9.4.x Oct 20, 2020
Jetty 9.4.33 automation moved this from Reviewer approved to Done Oct 20, 2020
@joakime joakime deleted the jetty-9.4.x-5480-npe-webinfconfiguration branch October 20, 2020 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Jetty 9.4.33
  
Done
Development

Successfully merging this pull request may close these issues.

NPE from WebInfConfiguration.deconfigure during WebAppContext shutdown
3 participants