Skip to content

Commit

Permalink
Fix memory leak caused by BungeeLogger queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Leymooo committed Sep 18, 2020
1 parent 4b34c16 commit c4dd63b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Expand Up @@ -326,15 +326,15 @@ public void handle(Handshake handshake) throws Exception
// Ping
if ( bungee.getConfig().isLogPings() )
{
bungee.getLogger().log( Level.INFO, "{0} has pinged", this );
bungee.getLogger().log( Level.INFO, "{0} has pinged", this.toString() ); // BotFilter, use toString()
}
thisState = State.STATUS;
ch.setProtocol( Protocol.STATUS );
bungee.getBotFilter().getServerPingUtils().add( getAddress().getAddress() ); //BotFilter
break;
case 2:
// Login
bungee.getLogger().log( Level.INFO, "{0} has connected", this );
bungee.getLogger().log( Level.INFO, "{0} has connected", this.toString() ); // BotFilter, use toString()
thisState = State.USERNAME;
ch.setProtocol( Protocol.LOGIN );

Expand All @@ -359,11 +359,6 @@ public void handle(Handshake handshake) throws Exception
public void handle(LoginRequest loginRequest) throws Exception
{
checkState( thisState == State.USERNAME, "Not expecting USERNAME" ); //BotFilter
if ( loginRequest.getData().length() > 32 ) //BotFilter https://pastebin.com/qWX1FUnf
{
disconnect( bungee.getTranslation( "name_too_long" ) );
return;
}
this.loginRequest = loginRequest;

bungee.getBotFilter().checkAsyncIfNeeded( this );
Expand Down
18 changes: 9 additions & 9 deletions proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
Expand Up @@ -49,7 +49,7 @@ public void channelActive(ChannelHandlerContext ctx) throws Exception

if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler );
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has connected", handler.toString() ); // BotFilter, use toString() instead of object
}
}
}
Expand All @@ -64,7 +64,7 @@ public void channelInactive(ChannelHandlerContext ctx) throws Exception

if ( !( handler instanceof InitialHandler || handler instanceof PingHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler );
ProxyServer.getInstance().getLogger().log( Level.INFO, "{0} has disconnected", handler.toString() ); // BotFilter, use toString() instead of object
}
}
}
Expand Down Expand Up @@ -136,43 +136,43 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
{
if ( cause instanceof ReadTimeoutException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - read timed out", handler );
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - read timed out", handler.toString() ); // BotFilter, use toString() instead of object
} else if ( cause instanceof DecoderException )
{
if ( cause instanceof CorruptedFrameException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - corrupted frame: {1}", new Object[]
{
handler, cause.getMessage()
handler.toString(), cause.getMessage() // BotFilter, use toString() instead of object
} );
} else if ( cause.getCause() instanceof BadPacketException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - bad packet ID, are mods in use!? {1}", new Object[]
{
handler, cause.getCause().getMessage()
handler.toString(), cause.getCause().getMessage() // BotFilter, use toString() instead of object
} );
} else if ( cause.getCause() instanceof OverflowPacketException )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - overflow in packet detected! {1}", new Object[]
{
handler, cause.getCause().getMessage()
handler.toString(), cause.getCause().getMessage() // BotFilter, use toString() instead of object
} );
}
} else if ( cause instanceof IOException || ( cause instanceof IllegalStateException && handler instanceof InitialHandler ) )
{
ProxyServer.getInstance().getLogger().log( Level.WARNING, "{0} - {1}: {2}", new Object[]
{
handler, cause.getClass().getSimpleName(), cause.getMessage()
handler.toString(), cause.getClass().getSimpleName(), cause.getMessage() // BotFilter, use toString() instead of object
} );
} else if ( cause instanceof QuietException )
{
ProxyServer.getInstance().getLogger().log( Level.SEVERE, "{0} - encountered exception: {1}", new Object[]
{
handler, cause
handler.toString(), cause // BotFilter, use toString() instead of object
} );
} else
{
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler + " - encountered exception", cause );
ProxyServer.getInstance().getLogger().log( Level.SEVERE, handler.toString() + " - encountered exception", cause ); // BotFilter, use toString() instead of object
}
}

Expand Down

0 comments on commit c4dd63b

Please sign in to comment.