diff --git a/WHATSNEW b/WHATSNEW index 63312ae3a..22b734ce9 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -420,6 +420,9 @@ Fixed bugs: * The VAJ tasks could fail if the project name contained characters that need to get URL encoded. Bugzilla Report 23322. +* TarInputStream#read() wasn't implemented correctly. Bugzilla Report + 34097. + Changes from Ant 1.6.1 to Ant 1.6.2 =================================== diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java index 50cc863df..7b7e9859f 100644 --- a/src/main/org/apache/tools/tar/TarInputStream.java +++ b/src/main/org/apache/tools/tar/TarInputStream.java @@ -40,12 +40,18 @@ public class TarInputStream extends FilterInputStream { protected boolean hasHitEOF; protected int entrySize; protected int entryOffset; - protected byte[] oneBuf; protected byte[] readBuf; protected TarBuffer buffer; protected TarEntry currEntry; private boolean v7Format; + /** + * This contents of this array is not used at all in this class, + * it is only here to avoid repreated object creation during calls + * to the no-arg read method. + */ + protected byte[] oneBuf; + /** * Constructor for TarInputStream. * @param is the input stream to use @@ -278,25 +284,7 @@ public class TarInputStream extends FilterInputStream { */ public int read() throws IOException { int num = this.read(this.oneBuf, 0, 1); - - if (num == -1) { - return num; - } else { - return (int) this.oneBuf[0]; - } - } - - /** - * Reads bytes from the current tar archive entry. - * - * This method simply calls read( byte[], int, int ). - * - * @param buf The buffer into which to place bytes read. - * @return The number of bytes read, or -1 at EOF. - * @throws IOException on error - */ - public int read(byte[] buf) throws IOException { - return this.read(buf, 0, buf.length); + return num == -1 ? -1 : ((int) this.oneBuf[0]) & 0xFF; } /**