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 4C07A18CD7 for ; Wed, 17 Feb 2016 07:55:40 +0000 (UTC) Received: (qmail 69948 invoked by uid 500); 17 Feb 2016 07:55:18 -0000 Delivered-To: apmail-logging-log4j-dev-archive@logging.apache.org Received: (qmail 69903 invoked by uid 500); 17 Feb 2016 07:55:18 -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 69884 invoked by uid 99); 17 Feb 2016 07:55:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Feb 2016 07:55:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 0D9282C14F0 for ; Wed, 17 Feb 2016 07:55:18 +0000 (UTC) Date: Wed, 17 Feb 2016 07:55:18 +0000 (UTC) From: "Remko Popma (JIRA)" To: log4j-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (LOG4J2-1271) ParameterizedMessage optimization MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4J2-1271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15149988#comment-15149988 ] Remko Popma edited comment on LOG4J2-1271 at 2/17/16 7:54 AM: -------------------------------------------------------------- * postpone creating the formatted message until hand-off to other thread - makes sense * saving reference to the Throwable if any - makes sense * calling toString() on the parameters - *why do we need this?* I claim this becomes unnecessary once the formatted message has been created. was (Author: remkop@yahoo.com): * postpone creating the formatted message until hand-off to other thread - okay * saving reference to the Throwable if any - okay * calling toString() on the parameters - *not okay*: why do we need this? I claim this becomes unnecessary once the formatted message has been created. > ParameterizedMessage optimization > --------------------------------- > > Key: LOG4J2-1271 > URL: https://issues.apache.org/jira/browse/LOG4J2-1271 > Project: Log4j 2 > Issue Type: Improvement > Components: API > Affects Versions: 2.5 > Reporter: Remko Popma > Assignee: Remko Popma > > ParameterizedMessage creates unnecessary objects and does other unnecessary work in its constructor. > On the other hand, it does not create the full formatted string it will eventually need to return from {{getFormattedMessage()}}. > I propose the following changes: > * Don't call {{argumentsToStrings}} in the constructor. Converting the parameter Object[] array to a String[] array should only be done when necessary: when this ParameterizedMessage is serialized. > * Don't copy the parameter Object[] array to a new array. Instead clone the array when the {{getParameters()}} method is called. > * In the constructor, build the fully formatted message. This combines the work done by {{formatStringArgs(String, String[])}} and {{argumentsToStrings(Object[])}} and avoids the issue mentioned in LOG4J2-763. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-dev-help@logging.apache.org