fix duplicate element creation when wrapping the bootstrap list (#1532)

closes #1530
This commit is contained in:
Pasqual Koschmieder 2022-03-10 05:17:03 +01:00 committed by GitHub
parent 073bfa2b86
commit 0d4e4c818f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -18,6 +18,9 @@ final class ListeningList implements List<Object> {
public ListeningList(List<Object> original, ChannelHandler channelHandler) {
this.original = original;
this.channelHandler = channelHandler;
// no need to copy all elements of the original list, but we need to inject them
original.forEach(this::processInsert);
}
@Override

View File

@ -204,11 +204,8 @@ public class NetworkManagerInjector implements ChannelListener {
// we need to synchronize accesses to the list ourselves, see Collections.SynchronizedCollection
//noinspection SynchronizationOnLocalVariableOrMethodParameter
synchronized (value) {
// then copy all old values into the new list
// override the list field with our list
List<Object> newList = Collections.synchronizedList(new ListeningList(value, this.pipelineInjectorHandler));
newList.addAll(value);
// rewrite the actual field
accessor.set(serverConnection, newList);
}
}