Skip to content

Commit 7865992

Browse files
committed
Fix setting archiver destination file to a one in the working dir causes NPE
Fixes #94
1 parent 98c3d0e commit 7865992

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ public void setDestFile( final File destFile )
669669
{
670670
this.destFile = destFile;
671671

672-
if ( destFile != null )
672+
if ( destFile != null && destFile.getParentFile() != null )
673673
{
674674
destFile.getParentFile().mkdirs();
675675
}

src/test/java/org/codehaus/plexus/archiver/AbstractArchiverTest.java

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.codehaus.plexus.archiver;
22

3+
import java.io.File;
34
import java.io.IOException;
45
import junit.framework.TestCase;
56

@@ -89,4 +90,8 @@ public void testOverridesCanBeReset()
8990
assertEquals( -1, archiver.getOverrideDirectoryMode() );
9091
}
9192

93+
public void testSetDestFileInTheWorkingDir() {
94+
archiver.setDestFile( new File( "archive" ) );
95+
}
96+
9297
}

0 commit comments

Comments
 (0)