Skip to content

Commit 8527911

Browse files
committed
Merge branch '2.x'
Conflicts: ReleaseNotes.md pom.xml src/main/java/org/codehaus/plexus/archiver/AbstractArchiver.java src/main/java/org/codehaus/plexus/archiver/tar/TarArchiver.java src/test/java/org/codehaus/plexus/archiver/jar/SecurityFilterTest.java
2 parents b174ef5 + c055e17 commit 8527911

34 files changed

+1846
-354
lines changed

ReleaseNotes.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
Plexus Archiver and Plexus-IO combined release notes
22
========================================================================
33

4-
Note: Master is in JIRA at http://jira.codehaus.org/browse/PLXCOMP
5-
64
Since archiver depends on a given version of IO this list is cumulative,
75
any version includes *all* changes below.
86

9-
Plexus Archiver - Version 2.10
7+
Plexus Archiver - Version 3.0
108
------
119
** Improvement
1210

1311
* [PLXCOMP-282] - Add Snappy compression support
1412

13+
Plexus Components - Version plexus-archiver-2.10
14+
-----
15+
16+
* Symlink support in DirectoryArchiver
17+
* Multithreaded ZIP support
18+
* Fixed resource leak on ZIP files included in ZIP files.
19+
* Added encoding supporting overload: addArchivedFileSet( final ArchivedFileSet fileSet, Charset charset )
20+
* Fixed NPE with missing folder in TAR
21+
* Moved all "zip" support to archiver (from io).
22+
23+
24+
Plexus Components - Version plexus-io-2.5
25+
-----
26+
* Proper support for closeable on zip archives.
27+
* Removed zip supporting PlexusIoZipFileResourceCollection; which now exists in plexus-archiver. (Drop in replacement,
28+
just change/add jar file).
29+
30+
>>>>>>> 2.x
31+
1532
Plexus Components - Version plexus-archiver-2.9.1
1633
-----
1734

pom.xml

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,24 @@
44
<modelVersion>4.0.0</modelVersion>
55

66
<parent>
7+
<artifactId>plexus</artifactId>
78
<groupId>org.codehaus.plexus</groupId>
8-
<artifactId>plexus-components</artifactId>
9-
<version>1.3</version>
9+
<version>3.2</version>
1010
</parent>
1111

1212
<artifactId>plexus-archiver</artifactId>
1313
<version>3.0.1-SNAPSHOT</version>
14-
1514
<name>Plexus Archiver Component</name>
1615

1716
<scm>
18-
<connection>scm:git:git@github.com:sonatype/plexus-archiver.git</connection>
19-
<developerConnection>scm:git:git@github.com:sonatype/plexus-archiver.git</developerConnection>
20-
<url>http://github.com/sonatype/plexus-archiver</url>
17+
<connection>scm:git:git@github.com:codehaus-plexus/plexus-archiver.git</connection>
18+
<developerConnection>scm:git:git@github.com:codehaus-plexus/plexus-archiver.git</developerConnection>
19+
<url>http://github.com/codehaus-plexus/plexus-archiver</url>
2120
<tag>HEAD</tag>
2221
</scm>
2322
<issueManagement>
2423
<system>jira</system>
25-
<url>http://jira.codehaus.org/browse/PLXCOMP/component/12540</url>
24+
<url>https://github.com/codehaus-plexus/plexus-archiver/issues</url>
2625
</issueManagement>
2726

2827
<properties>
@@ -46,6 +45,7 @@
4645
<dependency>
4746
<groupId>org.codehaus.plexus</groupId>
4847
<artifactId>plexus-container-default</artifactId>
48+
<version>1.0-alpha-9-stable-1</version>
4949
<scope>provided</scope>
5050
</dependency>
5151
<dependency>
@@ -56,12 +56,12 @@
5656
<dependency>
5757
<groupId>org.codehaus.plexus</groupId>
5858
<artifactId>plexus-io</artifactId>
59-
<version>2.4.1</version>
59+
<version>2.6</version>
6060
</dependency>
6161
<dependency>
6262
<groupId>org.apache.commons</groupId>
6363
<artifactId>commons-compress</artifactId>
64-
<version>1.9</version>
64+
<version>1.10-SNAPSHOT</version>
6565
</dependency>
6666
<dependency>
6767
<groupId>org.xerial.snappy</groupId>
@@ -126,6 +126,33 @@
126126
</execution>
127127
</executions>
128128
</plugin>
129+
<plugin>
130+
<groupId>org.apache.maven.plugins</groupId>
131+
<artifactId>maven-shade-plugin</artifactId>
132+
<version>1.4</version>
133+
<executions>
134+
<execution>
135+
<phase>package</phase>
136+
<goals>
137+
<goal>shade</goal>
138+
</goals>
139+
<configuration>
140+
<minimizeJar>true</minimizeJar>
141+
<artifactSet>
142+
<includes>
143+
<include>org.apache.commons:commons-compress</include>
144+
</includes>
145+
</artifactSet>
146+
<relocations>
147+
<relocation>
148+
<pattern>org.apache.commons.compress</pattern>
149+
<shadedPattern>org.codehaus.plexus.archiver.commonscompress</shadedPattern>
150+
</relocation>
151+
</relocations>
152+
</configuration>
153+
</execution>
154+
</executions>
155+
</plugin>
129156
<plugin>
130157
<groupId>org.apache.maven.plugins</groupId>
131158
<artifactId>maven-enforcer-plugin</artifactId>

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

Lines changed: 81 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@
1717
* limitations under the License.
1818
*/
1919

20-
import java.io.Closeable;
21-
import java.io.File;
22-
import java.io.IOException;
23-
import java.lang.reflect.UndeclaredThrowableException;
24-
import java.util.ArrayList;
25-
import java.util.HashMap;
26-
import java.util.HashSet;
27-
import java.util.Iterator;
28-
import java.util.List;
29-
import java.util.Map;
30-
import java.util.NoSuchElementException;
31-
import java.util.Set;
32-
33-
import javax.annotation.Nonnull;
34-
3520
import org.codehaus.plexus.PlexusConstants;
3621
import org.codehaus.plexus.PlexusContainer;
3722
import org.codehaus.plexus.archiver.manager.ArchiverManager;
@@ -41,6 +26,7 @@
4126
import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
4227
import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier;
4328
import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResourceCollection;
29+
import org.codehaus.plexus.components.io.resources.EncodingSupported;
4430
import org.codehaus.plexus.components.io.resources.PlexusIoArchivedResourceCollection;
4531
import org.codehaus.plexus.components.io.resources.PlexusIoFileResourceCollection;
4632
import org.codehaus.plexus.components.io.resources.PlexusIoResource;
@@ -54,6 +40,21 @@
5440
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
5541
import org.codehaus.plexus.util.Os;
5642

43+
import javax.annotation.Nonnull;
44+
import java.io.Closeable;
45+
import java.io.File;
46+
import java.io.IOException;
47+
import java.lang.reflect.UndeclaredThrowableException;
48+
import java.nio.charset.Charset;
49+
import java.util.ArrayList;
50+
import java.util.HashMap;
51+
import java.util.HashSet;
52+
import java.util.Iterator;
53+
import java.util.List;
54+
import java.util.Map;
55+
import java.util.NoSuchElementException;
56+
import java.util.Set;
57+
5758
import static org.codehaus.plexus.archiver.util.DefaultArchivedFileSet.archivedFileSet;
5859
import static org.codehaus.plexus.archiver.util.DefaultFileSet.fileSet;
5960

@@ -100,6 +101,7 @@ public abstract class AbstractArchiver
100101
// On lunix-like systems, we replace windows backslashes with forward slashes
101102
private final boolean replacePathSlashesToJavaPaths = File.separatorChar == '/';
102103

104+
private final List<Closeable> closeables = new ArrayList<Closeable>( );
103105
/**
104106
* since 2.2 is on by default
105107
*
@@ -479,6 +481,12 @@ else if ( o instanceof PlexusIoResourceCollection )
479481
}
480482
else
481483
{
484+
// this will leak handles in the IO iterator if the iterator is not fully consumed.
485+
// alternately we'd have to make this method return a Closeable iterator back
486+
// to the client and ditch the whole issue onto the client.
487+
// this does not really make any sense either, might equally well change the
488+
// api into something that is not broken by design.
489+
addCloseable( ioResourceIter );
482490
ioResourceIter = null;
483491
}
484492
}
@@ -550,6 +558,33 @@ private String normalizedForDuplicateCheck(ArchiveEntry entry){
550558

551559
}
552560

561+
private static void closeIfCloseable( Object resource )
562+
throws IOException
563+
{
564+
if ( resource == null )
565+
{
566+
return;
567+
}
568+
if ( resource instanceof Closeable )
569+
{
570+
( (Closeable) resource ).close();
571+
}
572+
573+
}
574+
575+
private static void closeQuietlyIfCloseable( Object resource )
576+
{
577+
try
578+
{
579+
closeIfCloseable( resource );
580+
}
581+
catch ( IOException e )
582+
{
583+
throw new RuntimeException( e );
584+
}
585+
}
586+
587+
553588
public Map<String, ArchiveEntry> getFiles()
554589
{
555590
try
@@ -603,7 +638,7 @@ protected Logger getLogger()
603638
return logger;
604639
}
605640

606-
protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet fileSet )
641+
protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet fileSet, Charset charset )
607642
throws ArchiverException
608643
{
609644
final File archiveFile = fileSet.getArchive();
@@ -619,6 +654,10 @@ protected PlexusIoResourceCollection asResourceCollection( final ArchivedFileSet
619654
"Error adding archived file-set. PlexusIoResourceCollection not found for: " + archiveFile, e );
620655
}
621656

657+
if (resources instanceof EncodingSupported ) {
658+
((EncodingSupported)resources).setEncoding( charset );
659+
}
660+
622661
if ( resources instanceof PlexusIoArchivedResourceCollection )
623662
{
624663
( (PlexusIoArchivedResourceCollection) resources ).setFile( fileSet.getArchive() );
@@ -673,7 +712,14 @@ private void doAddResource(Object item){
673712
public void addArchivedFileSet( final ArchivedFileSet fileSet )
674713
throws ArchiverException
675714
{
676-
final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet );
715+
final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet, null );
716+
addResources( resourceCollection );
717+
}
718+
719+
public void addArchivedFileSet( final ArchivedFileSet fileSet, Charset charset )
720+
throws ArchiverException
721+
{
722+
final PlexusIoResourceCollection resourceCollection = asResourceCollection( fileSet, charset );
677723
addResources( resourceCollection );
678724
}
679725

@@ -921,26 +967,40 @@ protected void validate()
921967

922968
protected abstract String getArchiveType();
923969

970+
private void addCloseable(Object maybeCloseable){
971+
if (maybeCloseable instanceof Closeable)
972+
closeables.add( (Closeable) maybeCloseable );
973+
974+
}
975+
private void closeIterators()
976+
{
977+
for ( Closeable closeable : closeables )
978+
{
979+
closeQuietlyIfCloseable( closeable );
980+
}
981+
982+
}
924983
protected abstract void close()
925984
throws IOException;
926985

927986
protected void cleanUp()
928987
throws IOException
929988
{
989+
closeIterators();
990+
930991
for ( Object resource : resources )
931992
{
932993
if ( resource instanceof PlexusIoProxyResourceCollection )
933994
{
934995
resource = ( (PlexusIoProxyResourceCollection) resource ).getSrc();
935996
}
936-
if ( resource instanceof Closeable )
937-
{
938-
( (Closeable) resource ).close();
939-
}
997+
998+
closeIfCloseable( resource );
940999
}
9411000
resources.clear();
9421001
}
9431002

1003+
9441004
protected abstract void execute()
9451005
throws ArchiverException, IOException;
9461006

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,22 @@ protected boolean isSelected( final String fileName, final PlexusIoResource file
217217
{
218218
if ( fileSelectors != null )
219219
{
220-
for (FileSelector fileSelector : fileSelectors) {
221-
try {
222-
if (!fileSelector.isSelected(fileInfo)) {
223-
return false;
224-
}
225-
} catch (final IOException e) {
226-
throw new ArchiverException("Failed to check, whether " + fileInfo.getName() + " is selected: "
227-
+ e.getMessage(), e);
228-
}
229-
}
220+
for ( FileSelector fileSelector : fileSelectors )
221+
{
222+
try
223+
{
224+
225+
if ( !fileSelector.isSelected( fileInfo ) )
226+
{
227+
return false;
228+
}
229+
}
230+
catch ( final IOException e )
231+
{
232+
throw new ArchiverException(
233+
"Failed to check, whether " + fileInfo.getName() + " is selected: " + e.getMessage(), e );
234+
}
235+
}
230236
}
231237
return true;
232238
}

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.io.File;
2424
import java.io.IOException;
25+
import java.nio.charset.Charset;
2526
import java.util.HashSet;
2627
import java.util.Map;
2728
import java.util.Set;
@@ -177,6 +178,25 @@ void addArchivedFileSet( @Nonnull File archiveFile, String prefix, String[] incl
177178
void addArchivedFileSet( ArchivedFileSet fileSet )
178179
throws ArchiverException;
179180

181+
182+
/**
183+
* Adds the given archive file set to the archive. This method is basically obsoleting
184+
* {@link #addArchivedFileSet(File)}, {@link #addArchivedFileSet(File, String[], String[])}, and
185+
* {@link #addArchivedFileSet(File, String, String[], String[])}. However, as these methods are in widespread use,
186+
* they cannot easily be made deprecated.
187+
*
188+
* @param charset the encoding to use, particularly useful to specific non-standard filename encodings
189+
* for some kinds of archives (for instance zip files)
190+
*
191+
* Stream transformers are supported on this method
192+
*
193+
* @param fileSet the fileSet to add
194+
* @param charset
195+
* @since 1.0-alpha-9
196+
*/
197+
void addArchivedFileSet( ArchivedFileSet fileSet, Charset charset )
198+
throws ArchiverException;
199+
180200
/**
181201
* Adds the given resource collection to the archive.
182202
*

0 commit comments

Comments
 (0)