changeset 16616:f6af8273cffa

8059361: Properties.stringPropertyNames() returns a set inconsistent with the assertions from the spec Reviewed-by: mchung
author smarks
date Wed, 01 Jun 2016 13:47:55 -0700
parents 0bd06ec69c5b
children 1e655ccc99f3
files src/java.base/share/classes/java/util/Properties.java
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/Properties.java	Wed Jun 01 11:22:06 2016 -0700
+++ b/src/java.base/share/classes/java/util/Properties.java	Wed Jun 01 13:47:55 2016 -0700
@@ -1037,18 +1037,18 @@
     }
 
     /**
-     * Returns a set of keys in this property list where
-     * the key and its corresponding value are strings,
+     * Returns an unmodifiable set of keys from this property list
+     * where the key and its corresponding value are strings,
      * including distinct keys in the default property list if a key
      * of the same name has not already been found from the main
      * properties list.  Properties whose key or value is not
      * of type {@code String} are omitted.
      * <p>
-     * The returned set is not backed by the {@code Properties} object.
-     * Changes to this {@code Properties} are not reflected in the set,
-     * or vice versa.
+     * The returned set is not backed by this {@code Properties} object.
+     * Changes to this {@code Properties} object are not reflected in the
+     * returned set.
      *
-     * @return  a set of keys in this property list where
+     * @return  an unmodifiable set of keys in this property list where
      *          the key and its corresponding value are strings,
      *          including the keys in the default property list.
      * @see     java.util.Properties#defaults
@@ -1057,7 +1057,7 @@
     public Set<String> stringPropertyNames() {
         Map<String, String> h = new HashMap<>();
         enumerateStringProperties(h);
-        return h.keySet();
+        return Collections.unmodifiableSet(h.keySet());
     }
 
     /**