RFR 6470126 java.util.jar.Attributes#containsKey fails with Strings
Claes Redestad
claes.redestad at oracle.com
Mon May 11 11:44:32 UTC 2020
Hi Vipin,
making containsKey("key") return true without also ensuring the
other Map operations like get, put, .. work consistently and
transparently with String keys seem like a partial fix that will subtly
break operations like getOrDefault.
And why not "if (name instanceof String)"?
Thanks!
/Claes
On 2020-05-11 13:30, Vipin Mv1 wrote:
> Hi,
>
> Please review the fix for the following issue.
>
> https://bugs.openjdk.java.net/browse/JDK-6470126
>
>
> diff -r 53568400fec3 src/java.base/share/classes/java/util/jar/Attributes.java
> --- a/src/java.base/share/classes/java/util/jar/Attributes.java Thu Mar 26 15:26:51 2020 +0000
> +++ b/src/java.base/share/classes/java/util/jar/Attributes.java Mon May 11 15:00:01 2020 +0530
> @@ -205,7 +205,10 @@
> * @return true if this Map contains the specified attribute name
> */
> public boolean containsKey(Object name) {
> - return map.containsKey(name);
> + if(String.class.isInstance(name))
> + return map.containsKey(Name.of((String)name));
> + else
> + return map.containsKey(name);
> }
>
> /**
>
> Thanks & Regards
> Vipin Menon
>
More information about the core-libs-dev
mailing list