Mercurial > hg > release > icedtea8-forest-3.0 > jdk
changeset 10748:5909ec3c62e3
8068790: ZipEntry/JarEntry.setCreation/LastAccessTime(null) don't throw NPE as specified
Reviewed-by: coffeys, sherman
author | redestad |
---|---|
date | Sat, 21 Feb 2015 13:46:24 +0100 |
parents | 019f2d939ddc |
children | 790c2e6b923a |
files | src/share/classes/java/util/zip/ZipEntry.java test/java/util/zip/TestExtraTime.java |
diffstat | 2 files changed, 28 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/util/zip/ZipEntry.java Fri Jan 23 13:57:02 2015 +0300 +++ b/src/share/classes/java/util/zip/ZipEntry.java Sat Feb 21 13:46:24 2015 +0100 @@ -180,8 +180,7 @@ * @since 1.8 */ public ZipEntry setLastModifiedTime(FileTime time) { - Objects.requireNonNull(name, "time"); - this.mtime = time; + this.mtime = Objects.requireNonNull(time, "lastModifiedTime"); this.time = time.to(TimeUnit.MILLISECONDS); return this; } @@ -227,8 +226,7 @@ * @since 1.8 */ public ZipEntry setLastAccessTime(FileTime time) { - Objects.requireNonNull(name, "time"); - this.atime = time; + this.atime = Objects.requireNonNull(time, "lastAccessTime"); return this; } @@ -265,8 +263,7 @@ * @since 1.8 */ public ZipEntry setCreationTime(FileTime time) { - Objects.requireNonNull(name, "time"); - this.ctime = time; + this.ctime = Objects.requireNonNull(time, "creationTime"); return this; }
--- a/test/java/util/zip/TestExtraTime.java Fri Jan 23 13:57:02 2015 +0300 +++ b/test/java/util/zip/TestExtraTime.java Sat Feb 21 13:46:24 2015 +0100 @@ -23,7 +23,7 @@ /** * @test - * @bug 4759491 6303183 7012868 8015666 8023713 + * @bug 4759491 6303183 7012868 8015666 8023713 8068790 * @summary Test ZOS and ZIS timestamp in extra field correctly */ @@ -69,6 +69,8 @@ test(mtime, atime, ctime, tz, extra); } } + + testNullHandling(); } static void test(FileTime mtime, FileTime atime, FileTime ctime, @@ -154,4 +156,26 @@ } } } + + static void testNullHandling() { + ZipEntry ze = new ZipEntry("TestExtraTime.java"); + try { + ze.setLastAccessTime(null); + throw new RuntimeException("setLastAccessTime(null) should throw NPE"); + } catch (NullPointerException ignored) { + // pass + } + try { + ze.setCreationTime(null); + throw new RuntimeException("setCreationTime(null) should throw NPE"); + } catch (NullPointerException ignored) { + // pass + } + try { + ze.setLastModifiedTime(null); + throw new RuntimeException("setLastModifiedTime(null) should throw NPE"); + } catch (NullPointerException ignored) { + // pass + } + } }