More use of StringUtil.truncate

This commit is contained in:
Joakim Erdfelt 2012-10-31 13:27:21 -07:00
parent 01c9e650fb
commit 171fa2db67
2 changed files with 2 additions and 13 deletions

View File

@ -302,11 +302,7 @@ public class Muxer implements IncomingFrames, MuxParser.Listener
} }
String reason = "Mux " + drop.toString(); String reason = "Mux " + drop.toString();
if (reason.length() > (WebSocketFrame.MAX_CONTROL_PAYLOAD - 2)) reason = StringUtil.truncate(reason,(WebSocketFrame.MAX_CONTROL_PAYLOAD - 2));
{
reason = reason.substring(0,WebSocketFrame.MAX_CONTROL_PAYLOAD - 2);
}
channel.close(StatusCode.PROTOCOL,reason); channel.close(StatusCode.PROTOCOL,reason);
// TODO: set channel to inactive? // TODO: set channel to inactive?
} }

View File

@ -180,14 +180,7 @@ public abstract class EventDriver implements IncomingFrames
protected void terminateConnection(int statusCode, String rawreason) protected void terminateConnection(int statusCode, String rawreason)
{ {
String reason = rawreason; String reason = rawreason;
if (StringUtil.isNotBlank(reason)) reason = StringUtil.truncate(reason,(WebSocketFrame.MAX_CONTROL_PAYLOAD - 2));
{
// Trim big exception messages here.
if (reason.length() > (WebSocketFrame.MAX_CONTROL_PAYLOAD - 2))
{
reason = reason.substring(0,WebSocketFrame.MAX_CONTROL_PAYLOAD - 2);
}
}
LOG.debug("terminateConnection({},{})",statusCode,rawreason); LOG.debug("terminateConnection({},{})",statusCode,rawreason);
session.close(statusCode,reason); session.close(statusCode,reason);
} }