hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1598053 - /httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
Date Wed, 28 May 2014 15:51:43 GMT
Author: olegk
Date: Wed May 28 15:51:42 2014
New Revision: 1598053

URL: http://svn.apache.org/r1598053
Log:
Slightly better synchronization

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java?rev=1598053&r1=1598052&r2=1598053&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor/AbstractMultiworkerIOReactor.java
Wed May 28 15:51:42 2014
@@ -117,6 +117,7 @@ public abstract class AbstractMultiworke
     private final Thread[] threads;
     private final Object statusLock;
 
+    //TODO: make final
     protected IOReactorExceptionHandler exceptionHandler;
     protected List<ExceptionEvent> auditLog;
 
@@ -151,6 +152,7 @@ public abstract class AbstractMultiworke
         } else {
             this.threadFactory = new DefaultThreadFactory();
         }
+        this.auditLog = new ArrayList<ExceptionEvent>();
         this.workerCount = this.config.getIoThreadCount();
         this.dispatchers = new BaseIOReactor[workerCount];
         this.workers = new Worker[workerCount];
@@ -217,11 +219,9 @@ public abstract class AbstractMultiworke
      *
      * @return audit log.
      */
-    public synchronized List<ExceptionEvent> getAuditLog() {
-        if (this.auditLog != null) {
+    public List<ExceptionEvent> getAuditLog() {
+        synchronized (this.auditLog) {
             return new ArrayList<ExceptionEvent>(this.auditLog);
-        } else {
-            return null;
         }
     }
 
@@ -237,10 +237,9 @@ public abstract class AbstractMultiworke
         if (ex == null) {
             return;
         }
-        if (this.auditLog == null) {
-            this.auditLog = new ArrayList<ExceptionEvent>();
+        synchronized (this.auditLog) {
+            this.auditLog.add(new ExceptionEvent(ex, timestamp != null ? timestamp : new
Date()));
         }
-        this.auditLog.add(new ExceptionEvent(ex, timestamp != null ? timestamp : new Date()));
     }
 
     /**



Mime
View raw message