mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2025-01-24 01:01:59 +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) {
|
public ListeningList(List<Object> original, ChannelHandler channelHandler) {
|
||||||
this.original = original;
|
this.original = original;
|
||||||
this.channelHandler = channelHandler;
|
this.channelHandler = channelHandler;
|
||||||
|
|
||||||
|
// no need to copy all elements of the original list, but we need to inject them
|
||||||
|
original.forEach(this::processInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -204,11 +204,8 @@ public class NetworkManagerInjector implements ChannelListener {
|
|||||||
// we need to synchronize accesses to the list ourselves, see Collections.SynchronizedCollection
|
// we need to synchronize accesses to the list ourselves, see Collections.SynchronizedCollection
|
||||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||||
synchronized (value) {
|
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));
|
List<Object> newList = Collections.synchronizedList(new ListeningList(value, this.pipelineInjectorHandler));
|
||||||
newList.addAll(value);
|
|
||||||
|
|
||||||
// rewrite the actual field
|
|
||||||
accessor.set(serverConnection, newList);
|
accessor.set(serverConnection, newList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user