diff -r af28daff6b98 -r 2523496f5107 src/hotspot/share/classfile/symbolTable.cpp --- a/src/hotspot/share/classfile/symbolTable.cpp Mon May 20 09:43:46 2019 -0400 +++ b/src/hotspot/share/classfile/symbolTable.cpp Mon May 20 10:06:07 2019 -0400 @@ -481,14 +481,17 @@ Thread* THREAD = Thread::current(); do { + // Callers have looked up the symbol once, insert the symbol. + sym = allocate_symbol(name, len, heap); + if (_local_table->insert(THREAD, lookup, sym, &rehash_warning, &clean_hint)) { + break; + } + // In case another thread did a concurrent add, return value already in the table. + // This could fail if the symbol got deleted concurrently, so loop back until success. if (_local_table->get(THREAD, lookup, stg, &rehash_warning)) { sym = stg.get_res_sym(); break; } - sym = allocate_symbol(name, len, heap); - if (_local_table->insert(THREAD, lookup, sym, &rehash_warning, &clean_hint)) { - break; - } } while(true); update_needs_rehash(rehash_warning);