camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1454312 - in /camel/branches/camel-2.10.x: ./ camel-core/src/main/java/org/apache/camel/management/mbean/JMXNotificationTraceEventHandler.java
Date Fri, 08 Mar 2013 10:32:55 GMT
Author: davsclaus
Date: Fri Mar  8 10:32:54 2013
New Revision: 1454312

URL: http://svn.apache.org/r1454312
Log:
Use atomic counter to be thread safe

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/management/mbean/JMXNotificationTraceEventHandler.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1454311

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/management/mbean/JMXNotificationTraceEventHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/management/mbean/JMXNotificationTraceEventHandler.java?rev=1454312&r1=1454311&r2=1454312&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/management/mbean/JMXNotificationTraceEventHandler.java
(original)
+++ camel/branches/camel-2.10.x/camel-core/src/main/java/org/apache/camel/management/mbean/JMXNotificationTraceEventHandler.java
Fri Mar  8 10:32:54 2013
@@ -19,6 +19,7 @@ package org.apache.camel.management.mbea
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
 import javax.management.Notification;
 
 import org.apache.camel.Exchange;
@@ -35,9 +36,9 @@ import org.apache.camel.util.MessageHelp
 
 public final class JMXNotificationTraceEventHandler implements TraceEventHandler, NotificationSenderAware
{
     private static final int MAX_MESSAGE_LENGTH = 60;
-    private long num;
+    private final AtomicLong num = new AtomicLong();
+    private final Tracer tracer;
     private NotificationSender notificationSender;
-    private Tracer tracer;
 
     public JMXNotificationTraceEventHandler(Tracer tracer) {
         this.tracer = tracer;
@@ -60,7 +61,7 @@ public final class JMXNotificationTraceE
             String message = body.substring(0, Math.min(body.length(), MAX_MESSAGE_LENGTH));
             Map<String, Object> tm = createTraceMessage(node, exchange, body);
 
-            Notification notification = new Notification("TraceNotification", exchange.toString(),
num++, System.currentTimeMillis(), message);
+            Notification notification = new Notification("TraceNotification", exchange.toString(),
num.getAndIncrement(), System.currentTimeMillis(), message);
             notification.setUserData(tm);
 
             notificationSender.sendNotification(notification);



Mime
View raw message