-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
7
-
Fix Understood
-
generic
-
generic
Description:
Invoking the Deflater.setDictionary() method more than once and setting the dictionary during Inflate using Inflater.setDictionary() method, causes IllegalArgumentException to be thrown. Please find the test code as given below:
<code>
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
public class SetDictionaryInvokedTwice {
public static void main(String...args){
try {
byte[] input = "Trying to invoke setDictionary twice twice twice".getBytes();
byte[] output = new byte[100];
Deflater def = new Deflater();
def.setDictionary("twice".getBytes());
def.setDictionary("twice".getBytes()); // Invoking setDictionary twice
def.setInput(input);
def.finish();
int compressedLen = def.deflate(output);
Inflater inf = new Inflater();
inf.setInput(output, 0, compressedLen);
byte[] result = new byte[100];
if (inf.inflate(result)== 0 && inf.needsDictionary()) {
inf.setDictionary("twice".getBytes());
inf.inflate(result);
}
inf.end();
} catch (DataFormatException dex) {
dex.printStackTrace();
}
catch(IllegalArgumentException iae){
System.err.println("IllegalArgumentException thrown when Deflater.setDictionary is invoked twice");
iae.printStackTrace();
}
}
}
</code>
<output>
IllegalArgumentException thrown when Deflater.setDictionary is invoked twice
java.lang.IllegalArgumentException
at java.util.zip.Inflater.setDictionary(Native Method)
at java.util.zip.Inflater.setDictionary(Inflater.java:159)
at java.util.zip.Inflater.setDictionary(Inflater.java:173)
at SetDictionaryInvokedTwice.main(SetDictionaryInvokedTwice.java:21)
</output>
Tried in :
<version>
bash-3.00$ java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b13)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b13, mixed mode)
bash-3.00$ uname -a
SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100
</version>
*** (#1 of 1): 2007-04-05 12:17:00 IST ###@###.###
Invoking the Deflater.setDictionary() method more than once and setting the dictionary during Inflate using Inflater.setDictionary() method, causes IllegalArgumentException to be thrown. Please find the test code as given below:
<code>
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
public class SetDictionaryInvokedTwice {
public static void main(String...args){
try {
byte[] input = "Trying to invoke setDictionary twice twice twice".getBytes();
byte[] output = new byte[100];
Deflater def = new Deflater();
def.setDictionary("twice".getBytes());
def.setDictionary("twice".getBytes()); // Invoking setDictionary twice
def.setInput(input);
def.finish();
int compressedLen = def.deflate(output);
Inflater inf = new Inflater();
inf.setInput(output, 0, compressedLen);
byte[] result = new byte[100];
if (inf.inflate(result)== 0 && inf.needsDictionary()) {
inf.setDictionary("twice".getBytes());
inf.inflate(result);
}
inf.end();
} catch (DataFormatException dex) {
dex.printStackTrace();
}
catch(IllegalArgumentException iae){
System.err.println("IllegalArgumentException thrown when Deflater.setDictionary is invoked twice");
iae.printStackTrace();
}
}
}
</code>
<output>
IllegalArgumentException thrown when Deflater.setDictionary is invoked twice
java.lang.IllegalArgumentException
at java.util.zip.Inflater.setDictionary(Native Method)
at java.util.zip.Inflater.setDictionary(Inflater.java:159)
at java.util.zip.Inflater.setDictionary(Inflater.java:173)
at SetDictionaryInvokedTwice.main(SetDictionaryInvokedTwice.java:21)
</output>
Tried in :
<version>
bash-3.00$ java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b13)
Java HotSpot(TM) Client VM (build 1.7.0-ea-b13, mixed mode)
bash-3.00$ uname -a
SunOS hrajan 5.10 Generic sun4u sparc SUNW,Sun-Blade-100
</version>
*** (#1 of 1): 2007-04-05 12:17:00 IST ###@###.###