8005394: Base64.Decoder/Encoder.wrap(XStream) don't throw NPE for null args passed
To check null for dec/enc.wrap methods Reviewed-by: alanb
This commit is contained in:
parent
b3fa7187ae
commit
907f0724ce
jdk
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user