mirror of
https://github.com/PaperMC/Waterfall.git
synced 2024-12-31 21:18:10 +01:00
Cache session exception
The concept behind this patch will be expanded in due time as health permits, however; This is one of the more common/troublesome exceptions that is thrown and causes issues for the proxies performance
This commit is contained in:
parent
cbb038fcc2
commit
e94c0b96ca
55
BungeeCord-Patches/0054-Cache-session-exceptions.patch
Normal file
55
BungeeCord-Patches/0054-Cache-session-exceptions.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From 27c57c63c6994cd6f8985946b83540a8195ab37a Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Mon, 25 Nov 2019 19:54:06 +0000
|
||||
Subject: [PATCH] Cache session exceptions
|
||||
|
||||
|
||||
diff --git a/api/src/main/java/io/github/waterfallmc/waterfall/utils/FastException.java b/api/src/main/java/io/github/waterfallmc/waterfall/utils/FastException.java
|
||||
new file mode 100644
|
||||
index 00000000..11e103cb
|
||||
--- /dev/null
|
||||
+++ b/api/src/main/java/io/github/waterfallmc/waterfall/utils/FastException.java
|
||||
@@ -0,0 +1,19 @@
|
||||
+package io.github.waterfallmc.waterfall.utils;
|
||||
+
|
||||
+// This is basically a copy of QuietException
|
||||
+public class FastException extends RuntimeException {
|
||||
+
|
||||
+ public FastException(String message) {
|
||||
+ super(message);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public synchronized Throwable initCause(Throwable cause) {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public synchronized Throwable fillInStackTrace() {
|
||||
+ return this;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
|
||||
index ac99d02c..0c1ecfb8 100644
|
||||
--- a/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
|
||||
+++ b/query/src/main/java/net/md_5/bungee/query/QueryHandler.java
|
||||
@@ -32,6 +32,7 @@ public class QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
/*========================================================================*/
|
||||
private final Random random = new Random();
|
||||
private final Cache<InetAddress, QuerySession> sessions = CacheBuilder.newBuilder().expireAfterWrite( 30, TimeUnit.SECONDS ).build();
|
||||
+ private static io.github.waterfallmc.waterfall.utils.FastException cachedNoSessionException = new io.github.waterfallmc.waterfall.utils.FastException("No Session!");
|
||||
|
||||
private void writeShort(ByteBuf buf, int s)
|
||||
{
|
||||
@@ -96,7 +97,7 @@ public class QueryHandler extends SimpleChannelInboundHandler<DatagramPacket>
|
||||
QuerySession session = sessions.getIfPresent( msg.sender().getAddress() );
|
||||
if ( session == null || session.getToken() != challengeToken )
|
||||
{
|
||||
- throw new IllegalStateException( "No session!" );
|
||||
+ throw cachedNoSessionException; // Waterfall
|
||||
}
|
||||
|
||||
// Waterfall start
|
||||
--
|
||||
2.24.0
|
||||
|
Loading…
Reference in New Issue
Block a user