1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
From: Ole Streicher <olebole@debian.org>
Date: Wed, 15 Feb 2017 16:13:30 +0100
Subject: Use commons-compress instead of apache ant
---
build.xml | 2 ++
src/main/uk/ac/starlink/util/Compression.java | 10 ++--------
src/testcases/uk/ac/starlink/util/DataSourceTest.java | 7 ++-----
3 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/build.xml b/build.xml
index e6ae451..f99fa7e 100644
--- a/build.xml
+++ b/build.xml
@@ -190,9 +190,11 @@
!-->
<path id="installed.classpath">
<pathelement location="${star.jar.dir}/junit.jar"/>
+ <pathelement location="${star.jar.dir}/commons-compress.jar"/>
</path>
<path id="jar.classpath">
+ <pathelement location="${dist.lib.pkg}/commons-compress.jar"/>
</path>
<!-- Generate the local build classpath. This is the most difficult
diff --git a/src/main/uk/ac/starlink/util/Compression.java b/src/main/uk/ac/starlink/util/Compression.java
index 8591f70..a64c558 100644
--- a/src/main/uk/ac/starlink/util/Compression.java
+++ b/src/main/uk/ac/starlink/util/Compression.java
@@ -4,7 +4,7 @@ import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.GZIPInputStream;
-import org.apache.tools.bzip2.CBZip2InputStream;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
/**
* Characterises the compression status of a stream, and provides methods
@@ -154,13 +154,7 @@ public abstract class Compression {
*/
public static final Compression BZIP2 = new Compression( "bzip2" ) {
public InputStream decompress( InputStream raw ) throws IOException {
-
- /* Eat the first two bytes. */
- if ( raw.read() != 'B' || raw.read() != 'Z' ) {
- throw new IllegalArgumentException(
- "Wrong magic number for bzip2 encoding" );
- }
- return new CBZip2InputStream( raw );
+ return new BZip2CompressorInputStream( raw );
}
};
diff --git a/src/testcases/uk/ac/starlink/util/DataSourceTest.java b/src/testcases/uk/ac/starlink/util/DataSourceTest.java
index 242b7a9..69ad4bd 100644
--- a/src/testcases/uk/ac/starlink/util/DataSourceTest.java
+++ b/src/testcases/uk/ac/starlink/util/DataSourceTest.java
@@ -10,8 +10,7 @@ import java.io.OutputStream;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
-import org.apache.tools.bzip2.CBZip2InputStream;
-import org.apache.tools.bzip2.CBZip2OutputStream;
+import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
import uk.ac.starlink.util.TestCase;
public class DataSourceTest extends TestCase {
@@ -193,9 +192,7 @@ public class DataSourceTest extends TestCase {
private Bzip2DataSource( int introLimit ) throws IOException {
super( introLimit );
ByteArrayOutputStream bstrm = new ByteArrayOutputStream();
- bstrm.write( (byte) 'B' );
- bstrm.write( (byte) 'Z' );
- OutputStream zstrm = new CBZip2OutputStream( bstrm );
+ OutputStream zstrm = new BZip2CompressorOutputStream( bstrm );
InputStream istrm = getPlainStream();
byte[] buf = new byte[ MAXBUF ];
|