You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2010/04/03 04:20:04 UTC
svn commit: r930460 - in /openejb/trunk/openejb3/container/openejb-core/src:
main/java/org/apache/openejb/util/Pool.java
test/java/org/apache/openejb/util/PoolTest.java
Author: dblevins
Date: Sat Apr 3 02:20:04 2010
New Revision: 930460
URL: http://svn.apache.org/viewvc?rev=930460&view=rev
Log:
Was still getting the occasional null on discard() callbacks.
Modified:
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/PoolTest.java
Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java?rev=930460&r1=930459&r2=930460&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Pool.java Sat Apr 3 02:20:04 2010
@@ -61,8 +61,7 @@ public class Pool<T> {
private final AtomicReference<Timer> timer = new AtomicReference<Timer>();
private Pool<T>.Eviction evictor;
private long interval;
- private final boolean debug = false;
-
+
public static class Builder<T> {
private int max = 10;
@@ -339,6 +338,7 @@ public class Pool<T> {
// Don't release the lock, this
// entry will be directly replaced
release = false;
+ entry.active.set(obj);
executor.execute(new Replace(entry));
}
} else {
@@ -364,7 +364,7 @@ public class Pool<T> {
// if the caller is the PoolEviction thread, we do not
// want to be calling discard() directly and should just
// queue it up instead.
- executor.execute(new Discard(entry));
+ executor.execute(new Discard(obj));
} else {
supplier.discard(obj);
}
@@ -630,7 +630,7 @@ public class Pool<T> {
// we need to queue up creation of a replacement
for (Expired expired : expiredList) {
- executor.execute(new Discard(expired.entry));
+ executor.execute(new Discard(expired.entry.get()));
if (expired.entry.hasHardReference()) {
executor.execute(new Replace(expired.entry));
@@ -697,10 +697,9 @@ public class Pool<T> {
private class Discard implements Runnable {
private final T expired;
- private Discard(Entry<T> expired) {
- this.expired = expired.get();
-
- if (expired == null) throw new NullPointerException("entry.get() cannot be null");
+ private Discard(T expired) {
+ if (expired == null) throw new NullPointerException("expired object cannot be null");
+ this.expired = expired;
}
public void run() {
Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/PoolTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/PoolTest.java?rev=930460&r1=930459&r2=930460&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/PoolTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/PoolTest.java Sat Apr 3 02:20:04 2010
@@ -1233,14 +1233,14 @@ public class PoolTest extends TestCase {
private void await(CountDownLatch latch, int timeout, TimeUnit seconds) throws InterruptedException {
if (!latch.await(timeout, seconds)) {
- String path = "<dump-failed>";
- try {
- File tmp = File.createTempFile(PoolTest.class.getSimpleName(), "-dump.txt");
- path = HeapDump.to(tmp.getAbsolutePath());
- } catch (IOException e) {
- e.printStackTrace();
- }
- fail("latch.await timed out: heap dumped here: "+ path);
+// String path = "<dump-failed>";
+// try {
+// File tmp = File.createTempFile(PoolTest.class.getSimpleName(), "-dump.txt");
+// path = HeapDump.to(tmp.getAbsolutePath());
+// } catch (IOException e) {
+// e.printStackTrace();
+// }
+ fail("latch.await timed out: "+ latch);
}
}