changeset 45377:13a0c766d059

8176853: Locale.Builder.removeUnicodeLocaleAttribute(null) should throw NullPointerException Reviewed-by: martin
author naoto
date Thu, 01 Jun 2017 12:43:46 -0700
parents 86022ba55981
children 190ee25b6bef
files jdk/src/java.base/share/classes/java/util/Locale.java jdk/test/java/util/Locale/LocaleEnhanceTest.java
diffstat 2 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/util/Locale.java	Thu Jun 01 12:43:11 2017 -0700
+++ b/jdk/src/java.base/share/classes/java/util/Locale.java	Thu Jun 01 12:43:46 2017 -0700
@@ -2702,6 +2702,7 @@
          * @see #setExtension(char, String)
          */
         public Builder removeUnicodeLocaleAttribute(String attribute) {
+            Objects.requireNonNull(attribute);
             try {
                 localeBuilder.removeUnicodeLocaleAttribute(attribute);
             } catch (LocaleSyntaxException e) {
--- a/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Thu Jun 01 12:43:11 2017 -0700
+++ b/jdk/test/java/util/Locale/LocaleEnhanceTest.java	Thu Jun 01 12:43:46 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2017, 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
@@ -44,7 +44,7 @@
 /**
  * @test
  * @bug 6875847 6992272 7002320 7015500 7023613 7032820 7033504 7004603
- *    7044019 8008577
+ *    7044019 8008577 8176853
  * @summary test API changes to Locale
  * @library /java/text/testlib
  * @modules jdk.localedata
@@ -1032,6 +1032,7 @@
 
         // null attribute throws NPE
         new BuilderNPE("null attribute") { public void call() { b.addUnicodeLocaleAttribute(null); }};
+        new BuilderNPE("null attribute removal") { public void call() { b.removeUnicodeLocaleAttribute(null); }};
 
         // illformed attribute throws IllformedLocaleException
         new BuilderILE("invalid attribute") { public void call() { b.addUnicodeLocaleAttribute("ca"); }};