Skip to content

Commit

Permalink
fix: use high timeout for query packets instead of weak values (#1500)
Browse files Browse the repository at this point in the history
### Motivation
The new implementation of query packets resulted in possible dead locks. The dead locks were caused, when the QueryPacketManager lost the reference to the stored future, because the answer to the query would never be handled as the entry in the map is lost.

### Modification
Removed the weakValues option from the backing cache and use a really high timeout of 8 hours for cache invalidation. Usually the cache should be empty so the high timeout value is not a problem.

### Result
No more deadlocks with query packets.

##### Other context
Fixes #1480
  • Loading branch information
0utplay authored Sep 6, 2024
1 parent 1ef60be commit dd7a750
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import eu.cloudnetservice.driver.network.NetworkChannel;
import eu.cloudnetservice.driver.network.protocol.Packet;
import eu.cloudnetservice.driver.network.protocol.QueryPacketManager;
import java.time.Duration;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
Expand All @@ -49,7 +50,7 @@ public class DefaultQueryPacketManager implements QueryPacketManager {
public DefaultQueryPacketManager(@NonNull NetworkChannel networkChannel) {
this.networkChannel = networkChannel;
this.waitingHandlers = Caffeine.newBuilder()
.weakValues()
.expireAfterWrite(Duration.ofHours(8))
.removalListener(this.newRemovalListener())
.build();
}
Expand Down

0 comments on commit dd7a750

Please sign in to comment.