# HG changeset patch # User sherman # Date 1359659376 28800 # Node ID 64b67b85e2a2d7299a2bf24a7c2f22c9f84177da # Parent 32046b0f4aa8aeaecd9322ac8c9166f29eb796e9 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 diff -r 32046b0f4aa8 -r 64b67b85e2a2 jdk/src/share/classes/java/util/Base64.java --- a/jdk/src/share/classes/java/util/Base64.java Thu Jan 31 10:55:15 2013 -0800 +++ b/jdk/src/share/classes/java/util/Base64.java Thu Jan 31 11:09:36 2013 -0800 @@ -413,6 +413,7 @@ * 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 @@ * byte stream */ public InputStream wrap(InputStream is) { + Objects.requireNonNull(is); return new DecInputStream(is, isURL ? fromBase64URL : fromBase64, isMIME); } diff -r 32046b0f4aa8 -r 64b67b85e2a2 jdk/test/java/util/Base64/TestBase64.java --- a/jdk/test/java/util/Base64/TestBase64.java Thu Jan 31 10:55:15 2013 -0800 +++ b/jdk/test/java/util/Base64/TestBase64.java Thu Jan 31 11:09:36 2013 -0800 @@ -22,7 +22,7 @@ */ /** - * @test 4235519 8004212 + * @test 4235519 8004212 8005394 * @summary tests java.util.Base64 */ @@ -295,6 +295,7 @@ 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 @@ 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 {