1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.commons.compress.harmony.unpack200;
18
19 import java.io.ByteArrayInputStream;
20 import java.io.IOException;
21 import java.io.InputStream;
22
23 import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
24 import org.apache.commons.compress.compressors.pack200.Pack200Strategy;
25 import org.junit.jupiter.api.Disabled;
26 import org.junit.jupiter.api.Test;
27
28 /**
29 * Tests https://issues.apache.org/jira/browse/COMPRESS-599.
30 *
31 * <pre>{@code
32 * java.lang.OutOfMemoryError: Java heap space
33 at org.apache.commons.compress.harmony.unpack200.CpBands.parseCpUtf8(CpBands.java:365)
34 at org.apache.commons.compress.harmony.unpack200.CpBands.read(CpBands.java:111)
35 at org.apache.commons.compress.harmony.unpack200.Segment.readSegment(Segment.java:351)
36 at org.apache.commons.compress.harmony.unpack200.Segment.unpackRead(Segment.java:459)
37 at org.apache.commons.compress.harmony.unpack200.Segment.unpack(Segment.java:436)
38 at org.apache.commons.compress.harmony.unpack200.Archive.unpack(Archive.java:155)
39 at org.apache.commons.compress.harmony.unpack200.Pack200UnpackerAdapter.unpack(Pack200UnpackerAdapter.java:49)
40 at org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream.<init>(Pack200CompressorInputStream.java:183)
41 at org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream.<init>(Pack200CompressorInputStream.java:77)
42 at org.apache.commons.compress.harmony.unpack200.tests.Codec_decodeInts_OutOfMemoryErrorTest.test(Codec_decodeInts_OutOfMemoryErrorTest.java:36)
43 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
44 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
45 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
46 at java.lang.reflect.Method.invoke(Method.java:498)
47 at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
48 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
49 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
50 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
51 at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
52 at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
53 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
54 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
55 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
56 at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
57 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
58 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
59 at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
60 at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
61 at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
62 at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
63 at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:93)
64 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)}
65 * </pre>
66 */
67 @Disabled
68 public class Codec_decodeInts_OutOfMemoryErrorTest {
69
70 // @formatter:off
71 private static final String BASE64_BYTES =
72 "yv7QDQeW0ABgfwDuwOn8QwIGAAIBAQAAd9zc3Nzc3Nzc3Nzc3Nzc3NxuZXR3YXJl3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3GluZG93cwAAAwMUAxUDZmVzdA0K";
73 // @formatter:on
74
75 @Test
76 public void test() throws IOException {
77 final byte[] input = java.util.Base64.getDecoder().decode(BASE64_BYTES);
78 try (InputStream is = new Pack200CompressorInputStream(new ByteArrayInputStream(input), Pack200Strategy.TEMP_FILE)) {
79 // do nothing
80 }
81
82 }
83 }