I'm also wondering if the Layout should really be a String layout.
This is smelly in TlsSyslogFrame:
@Override
public String toString() {
final String length = Integer.toString(messageLengthInBytes);
return length + Chars.SPACE + message;
}
combined with this in the Rfc5424 layout toSerializable(logEvent):
if (useTlsMessageFormat) {
return new TlsSyslogFrame(buf.toString()).toString();
}
Which means that the size header is of variable length. Can that be right?
Gary
On Wed, Jan 20, 2016 at 6:04 PM, Gary Gregory <[email protected]>
wrote:
> Hm, shouldn't we be using UTF-8 instead of Charset.defaultCharset() in:
>
> public byte[] getBytes() {
> final String frame = toString();
> return frame.getBytes(Charset.defaultCharset());
> }
>
> ?
>
> Gary
>
> On Wed, Jan 20, 2016 at 4:58 PM, Blake Day <[email protected]> wrote:
>
>> TlsSyslogFrame appears to be miscalculating the message length.
>> According to RFC5425, the message length must be the octet count of the
>> SYSLOG-MSG in the frame. Though the variable below is aptly named
>> messageLengthInBytes, it is assigned the value from message.length() (where
>> message is a String) rather than the bytes.
>>
>> See below for relevant portions of code:
>>
>> private String message;
>> private int messageLengthInBytes;
>>
>> private void setLengthInBytes() {
>> messageLengthInBytes = message.length();
>> }
>>
>> @Override
>> public String toString() {
>> final String length = Integer.toString(messageLengthInBytes);
>> return length + Chars.SPACE + message;
>> }
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>>
>
>
> --
> E-Mail: [email protected] | [email protected]
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
--
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory