Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 63AB8200B75 for ; Sat, 20 Aug 2016 10:58:14 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 60D0A160AAA; Sat, 20 Aug 2016 08:58:14 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AE326160ABB for ; Sat, 20 Aug 2016 10:58:13 +0200 (CEST) Received: (qmail 93064 invoked by uid 500); 20 Aug 2016 08:58:12 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 93047 invoked by uid 99); 20 Aug 2016 08:58:12 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Aug 2016 08:58:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id AD801DFB91; Sat, 20 Aug 2016 08:58:12 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Date: Sat, 20 Aug 2016 08:58:13 -0000 Message-Id: <56c382a11e944f82ae6269994902750a@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] camel git commit: socket write should be thread safe archived-at: Sat, 20 Aug 2016 08:58:14 -0000 socket write should be thread safe Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/89980020 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/89980020 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/89980020 Branch: refs/heads/camel-2.16.x Commit: 899800202331fc8a099370a1cc5ec1e928bea8fd Parents: 253d412 Author: Preben Asmussen Authored: Fri Aug 19 19:41:19 2016 +0200 Committer: Claus Ibsen Committed: Sat Aug 20 10:58:01 2016 +0200 ---------------------------------------------------------------------- .../apache/camel/component/splunk/support/SplunkDataWriter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/89980020/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/SplunkDataWriter.java ---------------------------------------------------------------------- diff --git a/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/SplunkDataWriter.java b/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/SplunkDataWriter.java index ee1a349..5650460 100644 --- a/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/SplunkDataWriter.java +++ b/components/camel-splunk/src/main/java/org/apache/camel/component/splunk/support/SplunkDataWriter.java @@ -21,6 +21,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.net.Socket; +import java.nio.charset.StandardCharsets; import com.splunk.Args; import com.splunk.Service; @@ -53,10 +54,10 @@ public abstract class SplunkDataWriter implements DataWriter { doWrite(event + SplunkEvent.LINEBREAK); } - protected void doWrite(String event) throws IOException { + protected synchronized void doWrite(String event) throws IOException { LOG.debug("writing event to splunk:" + event); OutputStream ostream = socket.getOutputStream(); - Writer writer = new OutputStreamWriter(ostream, "UTF-8"); + Writer writer = new OutputStreamWriter(ostream, StandardCharsets.UTF_8); writer.write(event); writer.flush(); }