From 9328b48dc33cbb7c1b2bd3dc9395f7c17e5bbc23 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Sun, 2 Jun 2024 16:29:20 -0700 Subject: [PATCH] Add missing override annotations --- src/main/java/stormpot/BSlot.java | 3 ++- src/main/java/stormpot/LatchCompletion.java | 3 ++- src/test/java/blackbox/slow/DefaultPoolIT.java | 1 + src/test/java/docs/MyAllocator.java | 2 ++ src/test/java/examples/DaoPoolExample.java | 6 ++++-- src/test/java/examples/Examples.java | 1 + src/test/java/stormpot/GenericPoolable.java | 1 + 7 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/stormpot/BSlot.java b/src/main/java/stormpot/BSlot.java index b4a9cce0..678e1941 100644 --- a/src/main/java/stormpot/BSlot.java +++ b/src/main/java/stormpot/BSlot.java @@ -39,7 +39,8 @@ final class BSlot // threads observe the pointer to this object. super(DEAD, live, poisonedSlots); } - + + @Override public void release(Poolable obj) { if (poison == BlazePool.EXPLICIT_EXPIRE_POISON) { poisonedSlots.getAndIncrement(); diff --git a/src/main/java/stormpot/LatchCompletion.java b/src/main/java/stormpot/LatchCompletion.java index a960df3d..5990cf97 100644 --- a/src/main/java/stormpot/LatchCompletion.java +++ b/src/main/java/stormpot/LatchCompletion.java @@ -24,7 +24,8 @@ final class LatchCompletion implements Completion { LatchCompletion(CountDownLatch completionLatch) { this.completionLatch = completionLatch; } - + + @Override public boolean await(Timeout timeout) throws InterruptedException { Objects.requireNonNull(timeout, "Timeout cannot be null."); return completionLatch.await(timeout.getTimeout(), timeout.getUnit()); diff --git a/src/test/java/blackbox/slow/DefaultPoolIT.java b/src/test/java/blackbox/slow/DefaultPoolIT.java index a255a547..a3b12b5c 100644 --- a/src/test/java/blackbox/slow/DefaultPoolIT.java +++ b/src/test/java/blackbox/slow/DefaultPoolIT.java @@ -21,6 +21,7 @@ import stormpot.PoolBuilder; class DefaultPoolIT extends ThreadBasedPoolIT { + @Override protected PoolBuilder createPoolBuilder(AlloKit.CountingAllocator allocator) { return Pool.from(allocator); } diff --git a/src/test/java/docs/MyAllocator.java b/src/test/java/docs/MyAllocator.java index 18b5b2f9..820c74fe 100644 --- a/src/test/java/docs/MyAllocator.java +++ b/src/test/java/docs/MyAllocator.java @@ -21,10 +21,12 @@ import stormpot.Slot; public class MyAllocator implements Allocator { + @Override public MyPoolable allocate(Slot slot) throws Exception { return new MyPoolable(slot); } + @Override public void deallocate(MyPoolable poolable) throws Exception { // Nothing to do here // But it's a perfect place to close sockets, files, etc. diff --git a/src/test/java/examples/DaoPoolExample.java b/src/test/java/examples/DaoPoolExample.java index 7bae14d3..734432d5 100644 --- a/src/test/java/examples/DaoPoolExample.java +++ b/src/test/java/examples/DaoPoolExample.java @@ -30,8 +30,7 @@ import java.sql.Statement; import java.util.concurrent.TimeUnit; -@SuppressWarnings({"WeakerAccess","unused", - "SynchronizationOnLocalVariableOrMethodParameter"}) +@SuppressWarnings({"WeakerAccess","unused"}) // tag::defineClass[] public class DaoPoolExample { // end::defineClass[] @@ -46,6 +45,7 @@ private MyDao(Slot slot, Connection connection) { } // end::mydaoStart[] // tag::mydaoRelease[] + @Override public void release() { slot.release(this); } @@ -79,6 +79,7 @@ public MyDaoAllocator(DataSource dataSource) { // end::allocatorStart[] // tag::allocatorAllocate[] + @Override public MyDao allocate(Slot slot) throws Exception { synchronized (dataSource) { return new MyDao(slot, dataSource.getConnection()); @@ -87,6 +88,7 @@ public MyDao allocate(Slot slot) throws Exception { // end::allocatorAllocate[] // tag::allocatorClose[] + @Override public void deallocate(MyDao poolable) throws Exception { poolable.close(); } diff --git a/src/test/java/examples/Examples.java b/src/test/java/examples/Examples.java index 8782a9d7..75822630 100644 --- a/src/test/java/examples/Examples.java +++ b/src/test/java/examples/Examples.java @@ -134,6 +134,7 @@ public GenericPoolable(Slot slot) { this.slot = slot; } + @Override public void release() { slot.release(this); } diff --git a/src/test/java/stormpot/GenericPoolable.java b/src/test/java/stormpot/GenericPoolable.java index 14c95a55..38cb36ab 100644 --- a/src/test/java/stormpot/GenericPoolable.java +++ b/src/test/java/stormpot/GenericPoolable.java @@ -23,6 +23,7 @@ public GenericPoolable(Slot slot) { super(slot); } + @Override public void release() { lastReleaseBy = Thread.currentThread(); super.release();