changeset 55737:45133b603c21

8228338: tools/pack200/TimeStamp.java fails with NullPointerException Reviewed-by: lancea
author bpb
date Thu, 18 Jul 2019 07:54:21 -0700
parents 2660d47140da
children aeb124322000
files src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java src/java.base/share/classes/sun/net/www/content/text/plain.java
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Thu Jul 18 21:25:41 2019 +0900
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/PackageReader.java	Thu Jul 18 07:54:21 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,6 +75,8 @@
      */
     static
     class LimitedBuffer extends BufferedInputStream {
+        static final InputStream NULL_STREAM = InputStream.nullInputStream();
+
         long served;     // total number of charburgers served
         int  servedPos;  // ...as of this value of super.pos
         long limit;      // current declared limit
@@ -123,7 +125,7 @@
             throw new RuntimeException("no skipping");
         }
         LimitedBuffer(InputStream originalIn) {
-            super(null, 1<<14);
+            super(NULL_STREAM, 1<<14);
             servedPos = pos;
             super.in = new FilterInputStream(originalIn) {
                 public int read() throws IOException {
--- a/src/java.base/share/classes/sun/net/www/content/text/plain.java	Thu Jul 18 21:25:41 2019 +0900
+++ b/src/java.base/share/classes/sun/net/www/content/text/plain.java	Thu Jul 18 07:54:21 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 1996, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,10 @@
     public Object getContent(URLConnection uc) {
         try {
             InputStream is = uc.getInputStream();
-            return new PlainTextInputStream(uc.getInputStream());
+            if (is == null) {
+                is = InputStream.nullInputStream();
+            }
+            return new PlainTextInputStream(is);
         } catch (IOException e) {
             return "Error reading document:\n" + e.toString();
         }