RFR(xs): 8059361: Properties.stringPropertyNames() returns a set inconsistent with the assertions from the spec
Mandy Chung
mandy.chung at oracle.com
Thu May 26 21:28:41 UTC 2016
> On May 26, 2016, at 1:57 PM, Stuart Marks <stuart.marks at oracle.com> wrote:
> :
>
> However, the existing implementation permits removal only; it already prohibits addition. Making the returned set unmodifiable would break clients that only remove elements from the returned set. I can imagine use cases that would do this, but it seems like they'd be quite rare.
>
Thanks for looking at existing usages and fixing this issue. Yup since the existing impl throws UOE at addition, I agree that the compatibility risk of changing the returned set to unmodifiable is not high.
>
> - return h.keySet();
> + return Set.of(h.keySet().toArray(new String[0]));
> }
The patch looks fine. It’d be good to add a test case.
If you use Collections.unmodifiableSet, you would not need to convert the key sets to an array. Any benefit of using Set::of instead of Collections.unmodifiableSet?
Mandy
More information about the core-libs-dev
mailing list