Don't log SocketExceptions. Fixes #9

This commit is contained in:
JeromSar 2016-06-18 17:25:57 +02:00
parent 2ef5146868
commit 8a6482c523
2 changed files with 13 additions and 6 deletions

View File

@ -16,6 +16,7 @@ import org.apache.logging.log4j.core.appender.AbstractAppender;
public class TelnetLogAppender extends AbstractAppender
{
private static final long serialVersionUID = 234234L;
private final Set<ClientSession> sessions;
private final SimpleDateFormat dateFormat;

View File

@ -8,6 +8,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.Socket;
import java.net.SocketException;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@ -77,7 +78,14 @@ public final class ClientSession extends Thread
syncTerminateSession();
}
writeLine("Logged in as " + username + ".");
TelnetLogger.info(clientAddress + " logged in as \"" + username + "\".");
// Start feeding data to the client.
telnet.getPlugin().appender.addSession(this);
mainLoop();
syncTerminateSession();
}
@ -356,12 +364,6 @@ public final class ClientSession extends Thread
return;
}
writeLine("Logged in as " + username + ".");
TelnetLogger.info(clientAddress + " logged in as \"" + username + "\".");
// Start feeding data to the client.
telnet.getPlugin().appender.addSession(this);
// Process commands
while (syncIsConnected())
{
@ -371,6 +373,10 @@ public final class ClientSession extends Thread
{
command = reader.readLine();
}
catch (SocketException ex)
{
break;
}
catch (IOException ex)
{
TelnetLogger.severe(ex);