7029848: KeyStoreBuilderParameters((Builder)null) does not throw NullPointerException
authorxuelei
Wed, 23 Mar 2011 20:07:46 -0700
changeset 8996 81adafd58c5a
parent 8995 dc0fc82e2d88
child 8997 21fb23e5ec42
7029848: KeyStoreBuilderParameters((Builder)null) does not throw NullPointerException Summary: throws NPE for null Builder Reviewed-by: weijun
jdk/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java
--- a/jdk/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java	Wed Mar 23 15:01:09 2011 -0700
+++ b/jdk/src/share/classes/javax/net/ssl/KeyStoreBuilderParameters.java	Wed Mar 23 20:07:46 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, 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
@@ -51,7 +51,7 @@
      * @exception NullPointerException if builder is null
      */
     public KeyStoreBuilderParameters(Builder builder) {
-        parameters = Collections.singletonList(builder);
+        parameters = Collections.singletonList(Objects.requireNonNull(builder));
     }
 
     /**
@@ -64,11 +64,12 @@
      * @exception IllegalArgumentException if parameters is an empty list
      */
     public KeyStoreBuilderParameters(List<Builder> parameters) {
-        this.parameters = Collections.unmodifiableList(
-            new ArrayList<Builder>(parameters));
         if (this.parameters.isEmpty()) {
             throw new IllegalArgumentException();
         }
+
+        this.parameters = Collections.unmodifiableList(
+            new ArrayList<Builder>(parameters));
     }
 
     /**