Return-Path: X-Original-To: apmail-logging-log4j-dev-archive@www.apache.org Delivered-To: apmail-logging-log4j-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A71919D13 for ; Tue, 22 Mar 2016 10:52:54 +0000 (UTC) Received: (qmail 69304 invoked by uid 500); 22 Mar 2016 10:52:54 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 69256 invoked by uid 500); 22 Mar 2016 10:52:54 -0000 Mailing-List: contact log4j-dev-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@logging.apache.org Received: (qmail 69246 invoked by uid 99); 22 Mar 2016 10:52:53 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Mar 2016 10:52:53 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 5864DC6B70 for ; Tue, 22 Mar 2016 10:52:53 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.179 X-Spam-Level: * X-Spam-Status: No, score=1.179 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Cov3yzmU8-O5 for ; Tue, 22 Mar 2016 10:52:51 +0000 (UTC) Received: from mail-ig0-f178.google.com (mail-ig0-f178.google.com [209.85.213.178]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 854C05FB0F for ; Tue, 22 Mar 2016 10:52:50 +0000 (UTC) Received: by mail-ig0-f178.google.com with SMTP id cl4so52288822igb.0 for ; Tue, 22 Mar 2016 03:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to; bh=wKzbkJ4uxbueEyisndCRo0XFa3zp6QYI+vKY/lv+FXk=; b=PvdlhfBcH1b5ota5WaBZd0vqEJKGbCB69mZQqUZYxznfve0G0KGn7i4Z3LbS0As6GW 3PLOQNbPkyImpgVkah5lI/QoM86s/Op9UMVdoLoQaaXmjxRCaMcBd7yEYChkG8wK0i+R YJebzIF5Z6uu+oIajl4q9hYNWzzZnY3XZb7IS4iaD9Ucta6X9peLKw0DqPuYCpoUpp3+ eRSCh4NFM2I1ikME6YU6wM0oOGMX5fu9KD0egxJw9WFuY+vQdnwMJA4ftoULQMlrdbC4 WP+8+i7fUymGCEY2fcdm7E27GjciJxq888DVi+7e/XBFqID5SbcYb6ADqaPBFVtGMU+V LOrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to; bh=wKzbkJ4uxbueEyisndCRo0XFa3zp6QYI+vKY/lv+FXk=; b=aJF/MKQuztnyEQiymXQT7XPDVxXRF22SMtMmULOr/ez+M4VYmBvvooIEX+llZbTwEV DlFMcANmypK4Un8qOcIXxsMQo1q4DOpK5QceWK4MfDLAcYDegDFLMmj6uxdS97S5jU68 PkMV0yYWo9ml8oWTtxl518M2RnDw1b5p3EbykUAqOleWMRhlhX/rwvec7SqdL1EoEmii SVv/qLcoVm1CaTTHH6ndny2GZnu7Yq+CbYerT7O9BVcvtDK+WR8D2jmT4dTmmTUxSv/R 2f7cyRKsneiXvqxhbZTTI9y8NbKZliEktlwUnuata7AVEdAqgXfH475JKQJYmsPKyOB7 8oFg== X-Gm-Message-State: AD7BkJJt+cZYtffu/w/PLZpnjrlkGLLjFcWp+0e+jUpW3kzErKSKF/JhQwonSi8uF3uxyiwDzF9Mzss4LtPPlA== MIME-Version: 1.0 X-Received: by 10.50.85.103 with SMTP id g7mr16930105igz.29.1458643969432; Tue, 22 Mar 2016 03:52:49 -0700 (PDT) Received: by 10.64.69.105 with HTTP; Tue, 22 Mar 2016 03:52:49 -0700 (PDT) In-Reply-To: References: Date: Tue, 22 Mar 2016 21:52:49 +1100 Message-ID: Subject: Re: Potential problem in PatternLayout From: Remko Popma To: Log4J Developers List Content-Type: multipart/alternative; boundary=089e0149bd6ca72834052ea1032b --089e0149bd6ca72834052ea1032b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think you're right. This should be an instance field, not a static field. Good catch! On Tuesday, 22 March 2016, Mikael St=C3=A5ldal = wrote: > In PatternLayout we have: > > private static final ThreadLocal textEncoderHelper =3D= new ThreadLocal<>(); > > private TextEncoderHelper getCachedTextEncoderHelper() { > TextEncoderHelper result =3D textEncoderHelper.get(); > if (result =3D=3D null) { > result =3D 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=C3=A5ldal* > 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 no= t > copy or deliver this message to anyone. In such case, > you should destroy this message and kindly notify the sender by reply > email. > --089e0149bd6ca72834052ea1032b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think you're right. This should be an instance field, not a static fi= eld. Good catch!

On Tuesday, 22 March 2016, Mikael St= =C3=A5ldal <mikael.staldal@= magine.com> wrote:
In PatternLayout we have:

private static final Thread=
Local<TextEncoderHelper> textEncoderHelper =3D=C2=A0
    new <=
/span>ThreadLocal<>();=
private=
 TextEncoderHelper getCachedTextEncoderHelper() {
TextEncoder= Helper result =3D textEncoderHelper.get();
if (result =3D=3D null) {
result =3D new TextEncoderHelpe= r(getCharset());
textEncoderHelper.set(result);
} return resu= lt;
}

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

--
3D"MagineTV"

Mikael St=C3=A5ldal
Senior software developer

Magine TV
mikael.staldal@magine.com=C2=A0 =C2=A0= =C2=A0
Grev Turegatan 3 =C2=A0|=C2=A0114 46 St= ockholm, Sweden=C2=A0 | =C2=A0 www.magine.com

Privilege= d and/or Confidential Information may be contained in this message. If=20 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,=C2=A0
you should destroy this message and kindly notify the sender by reply ema= il. =C2=A0=C2=A0
--089e0149bd6ca72834052ea1032b--