提交 5baf30d7 编写于 作者: S sherman

8005394: Base64.Decoder/Encoder.wrap(XStream) don't throw NPE for null args passed

Summary: to check null for dec/enc.wrap methods
Reviewed-by: alanb
上级 983cec6d
......@@ -413,6 +413,7 @@ public class Base64 {
* specified Base64 encoded format
*/
public OutputStream wrap(OutputStream os) {
Objects.requireNonNull(os);
return new EncOutputStream(os, isURL ? toBase64URL : toBase64,
newline, linemax);
}
......@@ -866,6 +867,7 @@ public class Base64 {
* byte stream
*/
public InputStream wrap(InputStream is) {
Objects.requireNonNull(is);
return new DecInputStream(is, isURL ? fromBase64URL : fromBase64, isMIME);
}
......
......@@ -22,7 +22,7 @@
*/
/**
* @test 4235519 8004212
* @test 4235519 8004212 8005394
* @summary tests java.util.Base64
*/
......@@ -295,6 +295,7 @@ public class TestBase64 {
checkNull(new Runnable() { public void run() { enc.encode(bb_null); }});
checkNull(new Runnable() { public void run() { enc.encode(bb_null, ByteBuffer.allocate(10), 0); }});
checkNull(new Runnable() { public void run() { enc.encode(ByteBuffer.allocate(10), bb_null, 0); }});
checkNull(new Runnable() { public void run() { enc.wrap(null); }});
}
private static void testNull(final Base64.Decoder dec) {
......@@ -305,6 +306,7 @@ public class TestBase64 {
checkNull(new Runnable() { public void run() { dec.decode(bb_null); }});
checkNull(new Runnable() { public void run() { dec.decode(bb_null, ByteBuffer.allocate(10)); }});
checkNull(new Runnable() { public void run() { dec.decode(ByteBuffer.allocate(10), bb_null); }});
checkNull(new Runnable() { public void run() { dec.wrap(null); }});
}
private static interface Testable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册