RFR 8071667 : HashMap.computeIfAbsent() adds entry that HashMap.get() does not find.

Chris Hegarty chris.hegarty at oracle.com
Mon Mar 23 11:16:09 UTC 2015


I wonder if we, optionally, pass the exception type, either CME or IAE, 
could we add CHM to the DataProvider?

On 21/03/15 13:43, Paul Sandoz wrote:
>
> On Mar 20, 2015, at 10:23 PM, Brent Christian <brent.christian at oracle.com> wrote:
>
>> Here's the latest:
>>
>> http://cr.openjdk.java.net/~bchristi/8071667/webrev.4/
>>
>> That should have everything.
>>
>
> Looks good (i assumed all but the test code has remained unchanged).
>
> I like the test. A minor comment:
>
>   125     private static void checkCME(Consumer code, boolean expectCME) {
>   126         try {
>   127             code.accept(null);
>   128         } catch (ConcurrentModificationException cme) {
>   129             if (expectCME) { return; } else { throw cme; }
>   130         }
>   131         if (expectCME) {
>   132             throw new RuntimeException("Expected CME, but wasn't thrown");
>   133         }
>   134     }
>   135
>   136     private static BiFunction<String,String,String> mkBiFunc(Map map) {
>   137         return (k,v) -> {
>   138             putToForceRehash(map);
>   139             return "computedValue";
>   140         };
>   141     }
>
> Can you avoid using raw types?

Yes, all test code should be lint free ;-) Or at least all new test code 
( where practicable ).

-Chris.

>
> Paul.
>



More information about the core-libs-dev mailing list