diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java index 37c6c584e6f..d242c789aa1 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java @@ -285,7 +285,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen return doTask(key, new Task(TaskOption.RESTRUCTURE_BEFORE, TaskOption.RESIZE) { @Override @Nullable - protected V execute(@Nullable Reference ref, @Nullable Entry entry, @Nullable Entries entries) { + protected V execute(@Nullable Reference ref, @Nullable Entry entry, @Nullable Entries entries) { if (entry != null) { V oldValue = entry.getValue(); if (overwriteExisting) { @@ -530,15 +530,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen final Reference head = this.references[index]; Reference ref = findInChain(head, key, hash); Entry entry = (ref != null ? ref.get() : null); - Entries entries = new Entries() { - @Override - public void add(@Nullable V value) { - @SuppressWarnings("unchecked") - Entry newEntry = new Entry<>((K) key, value); - Reference newReference = Segment.this.referenceManager.createReference(newEntry, hash, head); - Segment.this.references[index] = newReference; - Segment.this.count.incrementAndGet(); - } + Entries entries = value -> { + @SuppressWarnings("unchecked") + Entry newEntry = new Entry<>((K) key, value); + Reference newReference = Segment.this.referenceManager.createReference(newEntry, hash, head); + Segment.this.references[index] = newReference; + Segment.this.count.incrementAndGet(); }; return task.execute(ref, entry, entries); } @@ -802,7 +799,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen * @see #execute(Reference, Entry) */ @Nullable - protected T execute(@Nullable Reference ref, @Nullable Entry entry, @Nullable Entries entries) { + protected T execute(@Nullable Reference ref, @Nullable Entry entry, @Nullable Entries entries) { return execute(ref, entry); } @@ -830,15 +827,15 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen /** - * Allows a task access to {@link Segment} entries. + * Allows a task access to {@link ConcurrentReferenceHashMap.Segment} entries. */ - private abstract class Entries { + private interface Entries { /** * Add a new entry with the specified value. * @param value the value to add */ - public abstract void add(@Nullable V value); + void add(@Nullable V value); }