Skip to content

Commit

Permalink
Made commons compress dependency explicit and switched to build in xz…
Browse files Browse the repository at this point in the history
… support of it (#1917)
  • Loading branch information
DavyLandman authored Feb 22, 2024
1 parent 7b590ff commit d4868ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,16 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency> <!-- used by the compression uri feature-->
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.26.0</version>
</dependency>
<dependency> <!-- needed by commons-compress for compressed+...://...zst -->
<groupId>com.github.luben</groupId>
<artifactId>zstd-jni</artifactId>
<version>1.5.5-11</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
12 changes: 1 addition & 11 deletions src/org/rascalmpl/uri/CompressedStreamResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorStreamFactory;

import com.github.luben.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdOutputStream;

import io.usethesource.vallang.ISourceLocation;

public class CompressedStreamResolver implements ISourceLocationInputOutput {
private static final String ZSTD_COMPRESSION = "ZSTD";
private final URIResolverRegistry registry;

public CompressedStreamResolver(URIResolverRegistry registry) {
Expand All @@ -42,9 +38,6 @@ private ISourceLocation getActualURI(ISourceLocation wrappedURI) throws IOExcept
}

private static final InputStream getInputStream(String compressionMethod, InputStream original) throws IOException, CompressorException {
if (compressionMethod == ZSTD_COMPRESSION) {
return new ZstdInputStream(original);
}
return new CompressorStreamFactory().createCompressorInputStream(compressionMethod, original);
}

Expand All @@ -68,9 +61,6 @@ public InputStream getInputStream(ISourceLocation uri) throws IOException {
}

private static final OutputStream getOutputStream(String compressionMethod, OutputStream original) throws IOException, CompressorException {
if (compressionMethod == ZSTD_COMPRESSION) {
return new ZstdOutputStream(original);
}
return new CompressorStreamFactory().createCompressorOutputStream(compressionMethod, original);
}

Expand Down Expand Up @@ -120,7 +110,7 @@ private String detectCompression(ISourceLocation uri) throws IOException {
case "lzma" : return CompressorStreamFactory.LZMA;
case "Z" : return CompressorStreamFactory.Z;
case "xz": return CompressorStreamFactory.XZ;
case "zst": return ZSTD_COMPRESSION;
case "zst": return CompressorStreamFactory.ZSTANDARD;
case "7z":
case "zip":
case "rar":
Expand Down

0 comments on commit d4868ad

Please sign in to comment.