[jira] [Commented] (COMPRESS-651) Decompress BZIP2 File Max Output is 900000 chars

2024-03-13 Thread Ahmadin Badruddin (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17826081#comment-17826081
 ] 

Ahmadin Badruddin commented on COMPRESS-651:


Thank you for the help. It works from my tests

> Decompress BZIP2 File Max Output is 90 chars
> 
>
> Key: COMPRESS-651
> URL: https://issues.apache.org/jira/browse/COMPRESS-651
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.24.0
> Environment: Plain Java in IntelliJ
>Reporter: Ahmadin Badruddin
>Priority: Major
> Attachments: my10m.tar.bz2
>
>
> I tried to uncompress a big file (a few MBs) of bz2 file using 
> BZip2CompressorInputStream, the max output I can get is 90 in size. 
> The following example
> {code:java}
> -rw-r--r--   1 ahmadin  staff   167283773 Nov  9 15:50 test.tar.bz2
> -rw-r--r--   1 ahmadin  staff      90 Nov  9 15:51 test.tar {code}
> The code I use is the example from 
> [https://commons.apache.org/proper/commons-compress/examples.html]
> {code:java}
> public class BZ2Extract {
> public static void main(String[] args) {
> int buffersize = 102400;
> InputStream fin = null;
> try {
> fin = Files.newInputStream(Paths.get("/cfm/test.tar.bz2"));
> BufferedInputStream in = new BufferedInputStream(fin);
> OutputStream out = 
> Files.newOutputStream(Paths.get("/cfm/test.tar"));
> BZip2CompressorInputStream bzIn = new 
> BZip2CompressorInputStream(in);
> final byte[] buffer = new byte[buffersize];
> int n = 0;
> while (-1 != (n = bzIn.read(buffer))) {
> out.write(buffer, 0, n);
> }
> out.close();
> bzIn.close();
> } catch (IOException e) {
> throw new RuntimeException(e);
> }
> }
> } {code}
> If I use bzip2 on my mac to uncompress, the file size is 1199749120 after 
> uncompressing



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (COMPRESS-651) Decompress BZIP2 File Max Output is 900000 chars

2024-03-09 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17824977#comment-17824977
 ] 

Gary D. Gregory commented on COMPRESS-651:
--

[~ahmadin] 

This is how to write this test to correctly decompress this kind of file:
{code:java}
@Test
public void testCompress651() throws IOException {
final int buffersize = 102_400;
final Path pathIn = 
Paths.get("src/test/resources/org/apache/commons/compress/COMPRESS-651/my10m.tar.bz2");
final Path pathOut = Paths.get("target/COMPRESS-651/test.tar");
Files.createDirectories(pathOut.getParent());
try (BZip2CompressorInputStream inputStream = new 
BZip2CompressorInputStream(new 
BufferedInputStream(Files.newInputStream(pathIn)), true);
OutputStream outputStream = Files.newOutputStream(pathOut)) {
IOUtils.copy(inputStream, outputStream, buffersize);
}
// expected size confirmed locally on macOS
assertEquals(10_496_000, Files.size(pathOut));
}
{code}

Thank you [~peterhul...@gmail.com]

Notice the use of {{BZip2CompressorInputStream(InputStream, boolean)}}



> Decompress BZIP2 File Max Output is 90 chars
> 
>
> Key: COMPRESS-651
> URL: https://issues.apache.org/jira/browse/COMPRESS-651
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.24.0
> Environment: Plain Java in IntelliJ
>Reporter: Ahmadin Badruddin
>Priority: Major
> Attachments: my10m.tar.bz2
>
>
> I tried to uncompress a big file (a few MBs) of bz2 file using 
> BZip2CompressorInputStream, the max output I can get is 90 in size. 
> The following example
> {code:java}
> -rw-r--r--   1 ahmadin  staff   167283773 Nov  9 15:50 test.tar.bz2
> -rw-r--r--   1 ahmadin  staff      90 Nov  9 15:51 test.tar {code}
> The code I use is the example from 
> [https://commons.apache.org/proper/commons-compress/examples.html]
> {code:java}
> public class BZ2Extract {
> public static void main(String[] args) {
> int buffersize = 102400;
> InputStream fin = null;
> try {
> fin = Files.newInputStream(Paths.get("/cfm/test.tar.bz2"));
> BufferedInputStream in = new BufferedInputStream(fin);
> OutputStream out = 
> Files.newOutputStream(Paths.get("/cfm/test.tar"));
> BZip2CompressorInputStream bzIn = new 
> BZip2CompressorInputStream(in);
> final byte[] buffer = new byte[buffersize];
> int n = 0;
> while (-1 != (n = bzIn.read(buffer))) {
> out.write(buffer, 0, n);
> }
> out.close();
> bzIn.close();
> } catch (IOException e) {
> throw new RuntimeException(e);
> }
> }
> } {code}
> If I use bzip2 on my mac to uncompress, the file size is 1199749120 after 
> uncompressing



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (COMPRESS-651) Decompress BZIP2 File Max Output is 900000 chars

2024-03-09 Thread Sebb (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17824955#comment-17824955
 ] 

Sebb commented on COMPRESS-651:
---

I tried halving BZip2Constants.BASEBLOCKSIZE to 50_000, and the output file 
size is 450_000; it looks like the output size is being limited to the block 
size.

> Decompress BZIP2 File Max Output is 90 chars
> 
>
> Key: COMPRESS-651
> URL: https://issues.apache.org/jira/browse/COMPRESS-651
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.24.0
> Environment: Plain Java in IntelliJ
>Reporter: Ahmadin Badruddin
>Priority: Major
> Attachments: my10m.tar.bz2
>
>
> I tried to uncompress a big file (a few MBs) of bz2 file using 
> BZip2CompressorInputStream, the max output I can get is 90 in size. 
> The following example
> {code:java}
> -rw-r--r--   1 ahmadin  staff   167283773 Nov  9 15:50 test.tar.bz2
> -rw-r--r--   1 ahmadin  staff      90 Nov  9 15:51 test.tar {code}
> The code I use is the example from 
> [https://commons.apache.org/proper/commons-compress/examples.html]
> {code:java}
> public class BZ2Extract {
> public static void main(String[] args) {
> int buffersize = 102400;
> InputStream fin = null;
> try {
> fin = Files.newInputStream(Paths.get("/cfm/test.tar.bz2"));
> BufferedInputStream in = new BufferedInputStream(fin);
> OutputStream out = 
> Files.newOutputStream(Paths.get("/cfm/test.tar"));
> BZip2CompressorInputStream bzIn = new 
> BZip2CompressorInputStream(in);
> final byte[] buffer = new byte[buffersize];
> int n = 0;
> while (-1 != (n = bzIn.read(buffer))) {
> out.write(buffer, 0, n);
> }
> out.close();
> bzIn.close();
> } catch (IOException e) {
> throw new RuntimeException(e);
> }
> }
> } {code}
> If I use bzip2 on my mac to uncompress, the file size is 1199749120 after 
> uncompressing



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (COMPRESS-651) Decompress BZIP2 File Max Output is 900000 chars

2024-03-09 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17824952#comment-17824952
 ] 

Gary D. Gregory commented on COMPRESS-651:
--

I added a simpler disabled test in 
{{org.apache.commons.compress.compressors.bzip2.BZip2Compress651Test}}.


> Decompress BZIP2 File Max Output is 90 chars
> 
>
> Key: COMPRESS-651
> URL: https://issues.apache.org/jira/browse/COMPRESS-651
> Project: Commons Compress
>  Issue Type: Bug
>  Components: Compressors
>Affects Versions: 1.24.0
> Environment: Plain Java in IntelliJ
>Reporter: Ahmadin Badruddin
>Priority: Major
> Attachments: my10m.tar.bz2
>
>
> I tried to uncompress a big file (a few MBs) of bz2 file using 
> BZip2CompressorInputStream, the max output I can get is 90 in size. 
> The following example
> {code:java}
> -rw-r--r--   1 ahmadin  staff   167283773 Nov  9 15:50 test.tar.bz2
> -rw-r--r--   1 ahmadin  staff      90 Nov  9 15:51 test.tar {code}
> The code I use is the example from 
> [https://commons.apache.org/proper/commons-compress/examples.html]
> {code:java}
> public class BZ2Extract {
> public static void main(String[] args) {
> int buffersize = 102400;
> InputStream fin = null;
> try {
> fin = Files.newInputStream(Paths.get("/cfm/test.tar.bz2"));
> BufferedInputStream in = new BufferedInputStream(fin);
> OutputStream out = 
> Files.newOutputStream(Paths.get("/cfm/test.tar"));
> BZip2CompressorInputStream bzIn = new 
> BZip2CompressorInputStream(in);
> final byte[] buffer = new byte[buffersize];
> int n = 0;
> while (-1 != (n = bzIn.read(buffer))) {
> out.write(buffer, 0, n);
> }
> out.close();
> bzIn.close();
> } catch (IOException e) {
> throw new RuntimeException(e);
> }
> }
> } {code}
> If I use bzip2 on my mac to uncompress, the file size is 1199749120 after 
> uncompressing



--
This message was sent by Atlassian Jira
(v8.20.10#820010)