Skip to content

Commit

Permalink
Issue #5480 - NPE Check in WebInfConfiguration.deconfigure()
Browse files Browse the repository at this point in the history
+ Removing Temp dir deletion in configureTempDirectory()

Signed-off-by: Joakim Erdfelt <[email protected]>
  • Loading branch information
joakime committed Oct 20, 2020
1 parent 227dd47 commit 6be6fae
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
IO.delete(context.getTempDirectory());
}
Expand Down Expand Up @@ -522,21 +522,16 @@ public void configureTempDirectory(File dir, WebAppContext context)
if (dir == null)
throw new IllegalArgumentException("Null temp dir");

//if dir exists and we don't want it persisted, delete it
if (dir.exists() && !context.isPersistTempDirectory())
// if it doesn't exist make it
if (!dir.exists())
{
if (!IO.delete(dir))
throw new IllegalStateException("Failed to delete temp dir " + dir);
if (!dir.mkdirs())
{
throw new IllegalStateException("Unable to create temp dir " + dir);
}
}

//if it doesn't exist make it
if (!dir.exists())
dir.mkdirs();

if (!context.isPersistTempDirectory())
dir.deleteOnExit();

//is it useable
// is it useable
if (!dir.canWrite() || !dir.isDirectory())
throw new IllegalStateException("Temp dir " + dir + " not useable: writeable=" + dir.canWrite() + ", dir=" + dir.isDirectory());
}
Expand Down

0 comments on commit 6be6fae

Please sign in to comment.