-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
NPE protection on WebInfConfiguration.deconfigure() #5481
Conversation
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 <[email protected]>
…ectory. Signed-off-by: Joakim Erdfelt <[email protected]>
+ Removing Temp dir deletion in configureTempDirectory() Signed-off-by: Joakim Erdfelt <[email protected]>
jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java
Show resolved
Hide resolved
jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java
Show resolved
Hide resolved
jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java
Show resolved
Hide resolved
@@ -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()) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 <[email protected]>
jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java
Show resolved
Hide resolved
jetty-webapp/src/main/java/org/eclipse/jetty/webapp/WebInfConfiguration.java
Show resolved
Hide resolved
//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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Joakim Erdfelt <[email protected]>