-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.0
-
generic
-
generic
with b70 - java.util.zip.ZipOutputStream.setComment(String comment) doesn't throw NullPointerException when ' null ' is passed as comment.
Test program
----------------------------------------------
import java.io.*;
import java.util.*;
import java.util.zip.*;
public class setCommentTests {
public static void main(String[] args) throws Exception {
setCommentTests test=new setCommentTests();
test.Test01();
} // end main
/**
* Test Test01: comment = null, test should throw NullPointerException
*/
public void Test01() {
boolean exceptionThrown = false;
String sComment = null;
try {
ZipOutputStream zos = new ZipOutputStream(System.out);
zos.setComment(sComment);
} catch (Exception e) {
exceptionThrown = true;
if ( e instanceof NullPointerException ) {
System.out.println ("Expected NullPointerException thrown");
} else {
System.out.println ("Exception thrown, but not the expected NullPointerException");
}
e.printStackTrace();
}
if ( ! (exceptionThrown) ) {
System.out.println ("No Exception thrown");
}
}
}
-------------------------------------------------------
TestResult with b70
-------------------------------------------------
No Exception thrown
TestResult with b69
-----------------------------------------------------
Expected NullPointerException thrown
java.lang.NullPointerException
at java.util.zip.ZipOutputStream.setComment(ZipOutputStream.java:74)
at setCommentTests.Test01(setCommentTests.java:25)
at setCommentTests.main(setCommentTests.java:11)
--------------------------------------
Test program
----------------------------------------------
import java.io.*;
import java.util.*;
import java.util.zip.*;
public class setCommentTests {
public static void main(String[] args) throws Exception {
setCommentTests test=new setCommentTests();
test.Test01();
} // end main
/**
* Test Test01: comment = null, test should throw NullPointerException
*/
public void Test01() {
boolean exceptionThrown = false;
String sComment = null;
try {
ZipOutputStream zos = new ZipOutputStream(System.out);
zos.setComment(sComment);
} catch (Exception e) {
exceptionThrown = true;
if ( e instanceof NullPointerException ) {
System.out.println ("Expected NullPointerException thrown");
} else {
System.out.println ("Exception thrown, but not the expected NullPointerException");
}
e.printStackTrace();
}
if ( ! (exceptionThrown) ) {
System.out.println ("No Exception thrown");
}
}
}
-------------------------------------------------------
TestResult with b70
-------------------------------------------------
No Exception thrown
TestResult with b69
-----------------------------------------------------
Expected NullPointerException thrown
java.lang.NullPointerException
at java.util.zip.ZipOutputStream.setComment(ZipOutputStream.java:74)
at setCommentTests.Test01(setCommentTests.java:25)
at setCommentTests.main(setCommentTests.java:11)
--------------------------------------
- relates to
-
JDK-4408447 ZipOutputStream.setComment parameter validation is incorrect
-
- Closed
-