mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-08 09:27:34 +01:00
fix duplicate element creation when wrapping the bootstrap list (#1532)
closes #1530
This commit is contained in:
parent
073bfa2b86
commit
0d4e4c818f
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user