Please see the source code for AsciiChannel class, length is capped at maximum 9999
/**
* @param len the packed Message len
* @exception IOException
*/
protected void sendMessageLength(int len) throws IOException {
if (len > 9999)
throw new IOException ("len exceeded");
try {
serverOut.write(
ISOUtil.zeropad(Integer.toString(len), 4).getBytes()
);
} catch (ISOException e) { }
}
Also the checkLength()
method you call isn't actually trimming the length, it only threw exception when the content is too long. if you don't want exceptions then don't call this method / capture the exception and trim it
protected void checkLength(int len, int maxLength) throws IllegalArgumentException
{
if (len > maxLength)
{
throw new IllegalArgumentException("Length " + len + " too long for " + getClass().getName());
}
}