Browse Source

Fix TarInputStream#read() and remove unneeded override of single-array-arg read method at the same time. PR 34097

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278020 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 20 years ago
parent
commit
79d125cc05
2 changed files with 11 additions and 20 deletions
  1. +3
    -0
      WHATSNEW
  2. +8
    -20
      src/main/org/apache/tools/tar/TarInputStream.java

+ 3
- 0
WHATSNEW View File

@@ -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
===================================



+ 8
- 20
src/main/org/apache/tools/tar/TarInputStream.java View File

@@ -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;
}

/**


Loading…
Cancel
Save