commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1334504 - /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
Date Sat, 05 May 2012 20:59:38 GMT
Author: markt
Date: Sat May  5 20:59:38 2012
New Revision: 1334504

URL: http://svn.apache.org/viewvc?rev=1334504&view=rev
Log:
Fix POOL-221. Remove unnecessary volatile.

Modified:
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java?rev=1334504&r1=1334503&r2=1334504&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/PooledObject.java
Sat May  5 20:59:38 2012
@@ -31,7 +31,7 @@ package org.apache.commons.pool2.impl;
 public class PooledObject<T> implements Comparable<PooledObject<T>> {
 
     private final T object;
-    private volatile PooledObjectState state = PooledObjectState.IDLE; // @GuardedBy("this")
to ensure transitions are valid
+    private PooledObjectState state = PooledObjectState.IDLE; // @GuardedBy("this") to ensure
transitions are valid
     private final long createTime = System.currentTimeMillis();
     private volatile long lastBorrowTime = createTime;
     private volatile long lastReturnTime = createTime;
@@ -122,7 +122,9 @@ public class PooledObject<T> implements 
         result.append("Object: ");
         result.append(object.toString());
         result.append(", State: ");
-        result.append(state.toString());
+        synchronized (this) {
+            result.append(state.toString());
+        }
         return result.toString();
         // TODO add other attributes
     }



Mime
View raw message