You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2008/09/25 16:39:59 UTC
DO NOT REPLY [Bug 45044] CBZip2OutputStream does not work in
combination with ByteArrayOutputStream
https://issues.apache.org/bugzilla/show_bug.cgi?id=45044
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WORKSFORME
Target Milestone|--- |1.7.1
--- Comment #5 from Stefan Bodewig <bo...@apache.org> 2008-09-25 07:39:58 PST ---
<project>
<echo file="TestBZip.java"><![CDATA[
import org.apache.tools.bzip2.*;
import java.io.*;
public class TestBZip {
public static void main(String[] args) throws Throwable {
BufferedInputStream in = new BufferedInputStream(new
FileInputStream("bzip.xml"));
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
CBZip2OutputStream outFail = new CBZip2OutputStream(byteOut);
FileOutputStream fos = new FileOutputStream("bzip.xml.bz2");
CBZip2OutputStream outOk = new CBZip2OutputStream(fos);
byte[] bs = new byte[1024];
int l = in.read(bs);
while (l == 1024)
{
outFail.write(bs);
outOk.write(bs);
l = in.read(bs);
}
if (l > 0)
{
outFail.write(bs, 0, l);
outOk.write(bs, 0, l);
}
outFail.flush();
outOk.flush();
in.close();
// FAIL
// at this point, byteOut.toByteArray() has always length 1
outFail.close();
outOk.close();
int len = byteOut.toByteArray().length;
System.out.println("length: " + len);
if (len > 1) {
System.exit(0);
} else {
System.exit(1);
}
}
}
]]></echo>
<javac srcdir="." destdir="." includes="TestBZip.java"/>
<java classname="TestBZip" classpath=".;${java.class.path}" fork="true"/>
</project>
with Ant 1.7.1 leads to
$ ant -f ../../Temp/bzip.xml
Buildfile: ..\..\Temp\bzip.xml
[javac] Compiling 1 source file to c:\Temp
[java] length: 650
BUILD SUCCESSFUL
Total time: 0 seconds
which looks OK since the file is 650 bytes as well.
Seems to have been fixed for 1.7.1.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.