You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Mikael Ståldal <mi...@magine.com> on 2016/03/22 11:43:37 UTC

Potential problem in PatternLayout

In PatternLayout we have:

private static final ThreadLocal<TextEncoderHelper> textEncoderHelper
=     new ThreadLocal<>();

private TextEncoderHelper getCachedTextEncoderHelper() {
    TextEncoderHelper result = textEncoderHelper.get();
    if (result == null) {
        result = new TextEncoderHelper(getCharset());
        textEncoderHelper.set(result);
    }
    return result;
}


Does this really work properly? What if we have several instance of
PatternLayout with different charsets?

-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: Potential problem in PatternLayout

Posted by Mikael Ståldal <mi...@magine.com>.
Does it work better with the current master?

On Tue, Mar 22, 2016 at 4:25 PM, Gary Gregory <ga...@gmail.com>
wrote:

> Coincidentally, I just got:
>
> 2016-03-22 07:58:19,034 main ERROR An exception occurred processing
> Appender RollingFile java.lang.IllegalArgumentException
> at java.nio.Buffer.position(Buffer.java:236)
> at sun.nio.cs.UTF_8.updatePositions(UTF_8.java:78)
> at sun.nio.cs.UTF_8$Encoder.encodeArrayLoop(UTF_8.java:564)
> at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:619)
> at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:561)
> at
> org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeAsMuchAsPossible(TextEncoderHelper.java:93)
> at
> org.apache.logging.log4j.core.layout.TextEncoderHelper.encode(TextEncoderHelper.java:79)
> at
> org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeText(TextEncoderHelper.java:66)
> at
> org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:185)
> at
> org.apache.logging.log4j.core.layout.AbstractLayout.encode(AbstractLayout.java:1)
> at
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.append(RollingRandomAccessFileAppender.java:101)
> at
> org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
> at
> org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
> at
> org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
> at
> org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:387)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:372)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:356)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:346)
> at
> org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
> at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
> at
> org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1263)
> at
> org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1244)
> at com.rs.jdbc.dv.DvLogger.throwingIOException(DvLogger.java:245)
>
> With a recent 2.6 SNAPSHOT.
>
> Gary
>
> On Tue, Mar 22, 2016 at 4:58 AM, Mikael Ståldal <mikael.staldal@magine.com
> > wrote:
>
>> I fixed it while moving the field and method to AbstractStringLayout (to
>> be able to use from GelfLayout as well).
>>
>> On Tue, Mar 22, 2016 at 12:55 PM, Mikael Ståldal <
>> mikael.staldal@magine.com> wrote:
>>
>>> I am working on a fix.
>>>
>>> On Tue, Mar 22, 2016 at 11:52 AM, Remko Popma <re...@gmail.com>
>>> wrote:
>>>
>>>> I think you're right. This should be an instance field, not a static
>>>> field. Good catch!
>>>>
>>>>
>>>> On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com>
>>>> wrote:
>>>>
>>>>> In PatternLayout we have:
>>>>>
>>>>> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>>>>>
>>>>> private TextEncoderHelper getCachedTextEncoderHelper() {
>>>>>     TextEncoderHelper result = textEncoderHelper.get();
>>>>>     if (result == null) {
>>>>>         result = new TextEncoderHelper(getCharset());
>>>>>         textEncoderHelper.set(result);
>>>>>     }
>>>>>     return result;
>>>>> }
>>>>>
>>>>>
>>>>> Does this really work properly? What if we have several instance of
>>>>> PatternLayout with different charsets?
>>>>>
>>>>> --
>>>>> [image: MagineTV]
>>>>>
>>>>> *Mikael Ståldal*
>>>>> Senior software developer
>>>>>
>>>>> *Magine TV*
>>>>> mikael.staldal@magine.com
>>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>>>
>>>>> Privileged and/or Confidential Information may be contained in this
>>>>> message. If you are not the addressee indicated in this message
>>>>> (or responsible for delivery of the message to such a person), you may
>>>>> not copy or deliver this message to anyone. In such case,
>>>>> you should destroy this message and kindly notify the sender by reply
>>>>> email.
>>>>>
>>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: Potential problem in PatternLayout

Posted by Gary Gregory <ga...@gmail.com>.
I'll an eye out for it.

G

On Tue, Mar 22, 2016 at 9:14 AM, Remko Popma <re...@gmail.com> wrote:

> Ouch, scary!
> Would it be possible to reproduce this? I wonder why this is happening...
>
> I updated TextEncoderHelper with a fallback mechanism to String.getBytes()
> in case an error occurs.
> That will also log the text that could not be encoded to the StatusLogger
> at ERROR level.
>
> If it happens again, can you post the text that causes the problem?
> Thanks!
>
>
> On Wed, Mar 23, 2016 at 2:25 AM, Gary Gregory <ga...@gmail.com>
> wrote:
>
>> Coincidentally, I just got:
>>
>> 2016-03-22 07:58:19,034 main ERROR An exception occurred processing
>> Appender RollingFile java.lang.IllegalArgumentException
>> at java.nio.Buffer.position(Buffer.java:236)
>> at sun.nio.cs.UTF_8.updatePositions(UTF_8.java:78)
>> at sun.nio.cs.UTF_8$Encoder.encodeArrayLoop(UTF_8.java:564)
>> at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:619)
>> at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:561)
>> at
>> org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeAsMuchAsPossible(TextEncoderHelper.java:93)
>> at
>> org.apache.logging.log4j.core.layout.TextEncoderHelper.encode(TextEncoderHelper.java:79)
>> at
>> org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeText(TextEncoderHelper.java:66)
>> at
>> org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:185)
>> at
>> org.apache.logging.log4j.core.layout.AbstractLayout.encode(AbstractLayout.java:1)
>> at
>> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.append(RollingRandomAccessFileAppender.java:101)
>> at
>> org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
>> at
>> org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
>> at
>> org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
>> at
>> org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
>> at
>> org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:387)
>> at
>> org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:372)
>> at
>> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:356)
>> at
>> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:346)
>> at
>> org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
>> at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
>> at
>> org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1263)
>> at
>> org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1244)
>> at com.rs.jdbc.dv.DvLogger.throwingIOException(DvLogger.java:245)
>>
>> With a recent 2.6 SNAPSHOT.
>>
>> Gary
>>
>> On Tue, Mar 22, 2016 at 4:58 AM, Mikael Ståldal <
>> mikael.staldal@magine.com> wrote:
>>
>>> I fixed it while moving the field and method to AbstractStringLayout (to
>>> be able to use from GelfLayout as well).
>>>
>>> On Tue, Mar 22, 2016 at 12:55 PM, Mikael Ståldal <
>>> mikael.staldal@magine.com> wrote:
>>>
>>>> I am working on a fix.
>>>>
>>>> On Tue, Mar 22, 2016 at 11:52 AM, Remko Popma <re...@gmail.com>
>>>> wrote:
>>>>
>>>>> I think you're right. This should be an instance field, not a static
>>>>> field. Good catch!
>>>>>
>>>>>
>>>>> On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com>
>>>>> wrote:
>>>>>
>>>>>> In PatternLayout we have:
>>>>>>
>>>>>> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>>>>>>
>>>>>> private TextEncoderHelper getCachedTextEncoderHelper() {
>>>>>>     TextEncoderHelper result = textEncoderHelper.get();
>>>>>>     if (result == null) {
>>>>>>         result = new TextEncoderHelper(getCharset());
>>>>>>         textEncoderHelper.set(result);
>>>>>>     }
>>>>>>     return result;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Does this really work properly? What if we have several instance of
>>>>>> PatternLayout with different charsets?
>>>>>>
>>>>>> --
>>>>>> [image: MagineTV]
>>>>>>
>>>>>> *Mikael Ståldal*
>>>>>> Senior software developer
>>>>>>
>>>>>> *Magine TV*
>>>>>> mikael.staldal@magine.com
>>>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>>>>
>>>>>> Privileged and/or Confidential Information may be contained in this
>>>>>> message. If you are not the addressee indicated in this message
>>>>>> (or responsible for delivery of the message to such a person), you
>>>>>> may not copy or deliver this message to anyone. In such case,
>>>>>> you should destroy this message and kindly notify the sender by reply
>>>>>> email.
>>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> [image: MagineTV]
>>>>
>>>> *Mikael Ståldal*
>>>> Senior software developer
>>>>
>>>> *Magine TV*
>>>> mikael.staldal@magine.com
>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>>
>>>> Privileged and/or Confidential Information may be contained in this
>>>> message. If you are not the addressee indicated in this message
>>>> (or responsible for delivery of the message to such a person), you may
>>>> not copy or deliver this message to anyone. In such case,
>>>> you should destroy this message and kindly notify the sender by reply
>>>> email.
>>>>
>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>>
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> 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: garydgregory@gmail.com | ggregory@apache.org
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

Re: Potential problem in PatternLayout

Posted by Remko Popma <re...@gmail.com>.
Ouch, scary!
Would it be possible to reproduce this? I wonder why this is happening...

I updated TextEncoderHelper with a fallback mechanism to String.getBytes()
in case an error occurs.
That will also log the text that could not be encoded to the StatusLogger
at ERROR level.

If it happens again, can you post the text that causes the problem?
Thanks!


On Wed, Mar 23, 2016 at 2:25 AM, Gary Gregory <ga...@gmail.com>
wrote:

> Coincidentally, I just got:
>
> 2016-03-22 07:58:19,034 main ERROR An exception occurred processing
> Appender RollingFile java.lang.IllegalArgumentException
> at java.nio.Buffer.position(Buffer.java:236)
> at sun.nio.cs.UTF_8.updatePositions(UTF_8.java:78)
> at sun.nio.cs.UTF_8$Encoder.encodeArrayLoop(UTF_8.java:564)
> at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:619)
> at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:561)
> at
> org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeAsMuchAsPossible(TextEncoderHelper.java:93)
> at
> org.apache.logging.log4j.core.layout.TextEncoderHelper.encode(TextEncoderHelper.java:79)
> at
> org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeText(TextEncoderHelper.java:66)
> at
> org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:185)
> at
> org.apache.logging.log4j.core.layout.AbstractLayout.encode(AbstractLayout.java:1)
> at
> org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.append(RollingRandomAccessFileAppender.java:101)
> at
> org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
> at
> org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
> at
> org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
> at
> org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:387)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:372)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:356)
> at
> org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:346)
> at
> org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
> at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
> at
> org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1263)
> at
> org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1244)
> at com.rs.jdbc.dv.DvLogger.throwingIOException(DvLogger.java:245)
>
> With a recent 2.6 SNAPSHOT.
>
> Gary
>
> On Tue, Mar 22, 2016 at 4:58 AM, Mikael Ståldal <mikael.staldal@magine.com
> > wrote:
>
>> I fixed it while moving the field and method to AbstractStringLayout (to
>> be able to use from GelfLayout as well).
>>
>> On Tue, Mar 22, 2016 at 12:55 PM, Mikael Ståldal <
>> mikael.staldal@magine.com> wrote:
>>
>>> I am working on a fix.
>>>
>>> On Tue, Mar 22, 2016 at 11:52 AM, Remko Popma <re...@gmail.com>
>>> wrote:
>>>
>>>> I think you're right. This should be an instance field, not a static
>>>> field. Good catch!
>>>>
>>>>
>>>> On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com>
>>>> wrote:
>>>>
>>>>> In PatternLayout we have:
>>>>>
>>>>> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>>>>>
>>>>> private TextEncoderHelper getCachedTextEncoderHelper() {
>>>>>     TextEncoderHelper result = textEncoderHelper.get();
>>>>>     if (result == null) {
>>>>>         result = new TextEncoderHelper(getCharset());
>>>>>         textEncoderHelper.set(result);
>>>>>     }
>>>>>     return result;
>>>>> }
>>>>>
>>>>>
>>>>> Does this really work properly? What if we have several instance of
>>>>> PatternLayout with different charsets?
>>>>>
>>>>> --
>>>>> [image: MagineTV]
>>>>>
>>>>> *Mikael Ståldal*
>>>>> Senior software developer
>>>>>
>>>>> *Magine TV*
>>>>> mikael.staldal@magine.com
>>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>>>
>>>>> Privileged and/or Confidential Information may be contained in this
>>>>> message. If you are not the addressee indicated in this message
>>>>> (or responsible for delivery of the message to such a person), you may
>>>>> not copy or deliver this message to anyone. In such case,
>>>>> you should destroy this message and kindly notify the sender by reply
>>>>> email.
>>>>>
>>>>
>>>
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> 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
>

Re: Potential problem in PatternLayout

Posted by Gary Gregory <ga...@gmail.com>.
Coincidentally, I just got:

2016-03-22 07:58:19,034 main ERROR An exception occurred processing
Appender RollingFile java.lang.IllegalArgumentException
at java.nio.Buffer.position(Buffer.java:236)
at sun.nio.cs.UTF_8.updatePositions(UTF_8.java:78)
at sun.nio.cs.UTF_8$Encoder.encodeArrayLoop(UTF_8.java:564)
at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:619)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:561)
at
org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeAsMuchAsPossible(TextEncoderHelper.java:93)
at
org.apache.logging.log4j.core.layout.TextEncoderHelper.encode(TextEncoderHelper.java:79)
at
org.apache.logging.log4j.core.layout.TextEncoderHelper.encodeText(TextEncoderHelper.java:66)
at
org.apache.logging.log4j.core.layout.PatternLayout.encode(PatternLayout.java:185)
at
org.apache.logging.log4j.core.layout.AbstractLayout.encode(AbstractLayout.java:1)
at
org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender.append(RollingRandomAccessFileAppender.java:101)
at
org.apache.logging.log4j.core.config.AppenderControl.tryCallAppender(AppenderControl.java:155)
at
org.apache.logging.log4j.core.config.AppenderControl.callAppender0(AppenderControl.java:128)
at
org.apache.logging.log4j.core.config.AppenderControl.callAppenderPreventRecursion(AppenderControl.java:119)
at
org.apache.logging.log4j.core.config.AppenderControl.callAppender(AppenderControl.java:84)
at
org.apache.logging.log4j.core.config.LoggerConfig.callAppenders(LoggerConfig.java:387)
at
org.apache.logging.log4j.core.config.LoggerConfig.processLogEvent(LoggerConfig.java:372)
at
org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:356)
at
org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:346)
at
org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:63)
at org.apache.logging.log4j.core.Logger.logMessage(Logger.java:146)
at
org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1263)
at
org.apache.logging.log4j.spi.AbstractLogger.throwing(AbstractLogger.java:1244)
at com.rs.jdbc.dv.DvLogger.throwingIOException(DvLogger.java:245)

With a recent 2.6 SNAPSHOT.

Gary

On Tue, Mar 22, 2016 at 4:58 AM, Mikael Ståldal <mi...@magine.com>
wrote:

> I fixed it while moving the field and method to AbstractStringLayout (to
> be able to use from GelfLayout as well).
>
> On Tue, Mar 22, 2016 at 12:55 PM, Mikael Ståldal <
> mikael.staldal@magine.com> wrote:
>
>> I am working on a fix.
>>
>> On Tue, Mar 22, 2016 at 11:52 AM, Remko Popma <re...@gmail.com>
>> wrote:
>>
>>> I think you're right. This should be an instance field, not a static
>>> field. Good catch!
>>>
>>>
>>> On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com>
>>> wrote:
>>>
>>>> In PatternLayout we have:
>>>>
>>>> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>>>>
>>>> private TextEncoderHelper getCachedTextEncoderHelper() {
>>>>     TextEncoderHelper result = textEncoderHelper.get();
>>>>     if (result == null) {
>>>>         result = new TextEncoderHelper(getCharset());
>>>>         textEncoderHelper.set(result);
>>>>     }
>>>>     return result;
>>>> }
>>>>
>>>>
>>>> Does this really work properly? What if we have several instance of
>>>> PatternLayout with different charsets?
>>>>
>>>> --
>>>> [image: MagineTV]
>>>>
>>>> *Mikael Ståldal*
>>>> Senior software developer
>>>>
>>>> *Magine TV*
>>>> mikael.staldal@magine.com
>>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>>
>>>> Privileged and/or Confidential Information may be contained in this
>>>> message. If you are not the addressee indicated in this message
>>>> (or responsible for delivery of the message to such a person), you may
>>>> not copy or deliver this message to anyone. In such case,
>>>> you should destroy this message and kindly notify the sender by reply
>>>> email.
>>>>
>>>
>>
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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

Re: Potential problem in PatternLayout

Posted by Mikael Ståldal <mi...@magine.com>.
I fixed it while moving the field and method to AbstractStringLayout (to be
able to use from GelfLayout as well).

On Tue, Mar 22, 2016 at 12:55 PM, Mikael Ståldal <mi...@magine.com>
wrote:

> I am working on a fix.
>
> On Tue, Mar 22, 2016 at 11:52 AM, Remko Popma <re...@gmail.com>
> wrote:
>
>> I think you're right. This should be an instance field, not a static
>> field. Good catch!
>>
>>
>> On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com>
>> wrote:
>>
>>> In PatternLayout we have:
>>>
>>> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>>>
>>> private TextEncoderHelper getCachedTextEncoderHelper() {
>>>     TextEncoderHelper result = textEncoderHelper.get();
>>>     if (result == null) {
>>>         result = new TextEncoderHelper(getCharset());
>>>         textEncoderHelper.set(result);
>>>     }
>>>     return result;
>>> }
>>>
>>>
>>> Does this really work properly? What if we have several instance of
>>> PatternLayout with different charsets?
>>>
>>> --
>>> [image: MagineTV]
>>>
>>> *Mikael Ståldal*
>>> Senior software developer
>>>
>>> *Magine TV*
>>> mikael.staldal@magine.com
>>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>>
>>> Privileged and/or Confidential Information may be contained in this
>>> message. If you are not the addressee indicated in this message
>>> (or responsible for delivery of the message to such a person), you may
>>> not copy or deliver this message to anyone. In such case,
>>> you should destroy this message and kindly notify the sender by reply
>>> email.
>>>
>>
>
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>



-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: Potential problem in PatternLayout

Posted by Mikael Ståldal <mi...@magine.com>.
I am working on a fix.

On Tue, Mar 22, 2016 at 11:52 AM, Remko Popma <re...@gmail.com> wrote:

> I think you're right. This should be an instance field, not a static
> field. Good catch!
>
>
> On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com>
> wrote:
>
>> In PatternLayout we have:
>>
>> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>>
>> private TextEncoderHelper getCachedTextEncoderHelper() {
>>     TextEncoderHelper result = textEncoderHelper.get();
>>     if (result == null) {
>>         result = new TextEncoderHelper(getCharset());
>>         textEncoderHelper.set(result);
>>     }
>>     return result;
>> }
>>
>>
>> Does this really work properly? What if we have several instance of
>> PatternLayout with different charsets?
>>
>> --
>> [image: MagineTV]
>>
>> *Mikael Ståldal*
>> Senior software developer
>>
>> *Magine TV*
>> mikael.staldal@magine.com
>> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>>
>> Privileged and/or Confidential Information may be contained in this
>> message. If you are not the addressee indicated in this message
>> (or responsible for delivery of the message to such a person), you may
>> not copy or deliver this message to anyone. In such case,
>> you should destroy this message and kindly notify the sender by reply
>> email.
>>
>


-- 
[image: MagineTV]

*Mikael Ståldal*
Senior software developer

*Magine TV*
mikael.staldal@magine.com
Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com

Privileged and/or Confidential Information may be contained in this
message. If you are not the addressee indicated in this message
(or responsible for delivery of the message to such a person), you may not
copy or deliver this message to anyone. In such case,
you should destroy this message and kindly notify the sender by reply
email.

Re: Potential problem in PatternLayout

Posted by Remko Popma <re...@gmail.com>.
I think you're right. This should be an instance field, not a static field.
Good catch!

On Tuesday, 22 March 2016, Mikael Ståldal <mi...@magine.com> wrote:

> In PatternLayout we have:
>
> private static final ThreadLocal<TextEncoderHelper> textEncoderHelper =     new ThreadLocal<>();
>
> private TextEncoderHelper getCachedTextEncoderHelper() {
>     TextEncoderHelper result = textEncoderHelper.get();
>     if (result == null) {
>         result = new TextEncoderHelper(getCharset());
>         textEncoderHelper.set(result);
>     }
>     return result;
> }
>
>
> Does this really work properly? What if we have several instance of
> PatternLayout with different charsets?
>
> --
> [image: MagineTV]
>
> *Mikael Ståldal*
> Senior software developer
>
> *Magine TV*
> mikael.staldal@magine.com
> <javascript:_e(%7B%7D,'cvml','mikael.staldal@magine.com');>
> Grev Turegatan 3  | 114 46 Stockholm, Sweden  |   www.magine.com
>
> Privileged and/or Confidential Information may be contained in this
> message. If you are not the addressee indicated in this message
> (or responsible for delivery of the message to such a person), you may not
> copy or deliver this message to anyone. In such case,
> you should destroy this message and kindly notify the sender by reply
> email.
>