Skip to content
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

Made commons compress dependency explicit #1917

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading