camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/2] camel git commit: socket write should be thread safe
Date Sat, 20 Aug 2016 08:58:13 GMT
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 <preben.asmussen@gmail.com>
Authored: Fri Aug 19 19:41:19 2016 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
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();
     }


Mime
View raw message