Skip to content

Commit

Permalink
Add Checkstyle WhitespaceAround
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Feb 11, 2025
1 parent a27754e commit 1b3c83f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/conf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@
<property name="protectedAllowed" value="true" />
</module>
<module name="WhitespaceAfter" />
<module name="WhitespaceAround" />
</module>
</module>
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/pool2/PoolUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private ErodingObjectPool(final ObjectPool<T> pool, final float factor) {
* {@inheritDoc}
*/
@Override
public void addObject() throws Exception{
public void addObject() throws Exception {
pool.addObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ public T borrowObject(final K key, final long borrowMaxWaitMillis) throws Except
}
if (blockWhenExhausted) {
if (PooledObject.isNull(p)) {
p = borrowMaxWaitMillis < 0 ? objectDeque.getIdleObjects().takeFirst():
objectDeque.getIdleObjects().pollFirst(borrowMaxWaitMillis, TimeUnit.MILLISECONDS);
p = borrowMaxWaitMillis < 0 ? objectDeque.getIdleObjects().takeFirst()
: objectDeque.getIdleObjects().pollFirst(borrowMaxWaitMillis, TimeUnit.MILLISECONDS);
}
if (PooledObject.isNull(p)) {
throw new NoSuchElementException(appendStats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,14 @@ public void testBaseClear() throws Exception {
}

@Test
public void testBaseClosePool() throws Exception{
public void testBaseClosePool() throws Exception {
try {
pool = makeEmptyPool(3);
} catch (final UnsupportedOperationException e) {
return; // skip this test if unsupported
}
final String obj = pool.borrowObject();
pool.returnObject(obj);

pool.close();
assertThrows(IllegalStateException.class, pool::borrowObject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ private static final class TestFactory extends BasePooledObjectFactory<AtomicInt
public AtomicInteger create() {
return new AtomicInteger();
}

@Override
public void destroyObject(final PooledObject<AtomicInteger> p, final DestroyMode destroyMode){
public void destroyObject(final PooledObject<AtomicInteger> p, final DestroyMode destroyMode) {
if (destroyMode.equals(DestroyMode.ABANDONED)) {
p.getObject().incrementAndGet();
}
}

@Override
public PooledObject<AtomicInteger> wrap(final AtomicInteger value) {
return new DefaultPooledObject<>(value);
Expand All @@ -48,17 +50,15 @@ public PooledObject<AtomicInteger> wrap(final AtomicInteger value) {
@Test
public void testDefaultMethods() throws Exception {
final PooledObjectFactory<AtomicInteger> factory = new TestFactory();

factory.activateObject(null); // a no-op
factory.passivateObject(null); // a no-op
factory.destroyObject(null); // a no-op
assertTrue(factory.validateObject(null)); // constant true
}

/**
* Default destroy does nothing to underlying AtomicInt, ABANDONED mode
* increments the value. Verify that destroy with no mode does default,
* destroy with ABANDONED mode increments.
* Default destroy does nothing to underlying AtomicInt, ABANDONED mode increments the value. Verify that destroy with no mode does default, destroy with
* ABANDONED mode increments.
*
* @throws RuntimeException May occur in some failure modes
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ private void checkEvictorVisiting(final boolean lifo) throws Exception {
final Random random = new Random();
random.setSeed(System.currentTimeMillis());
for (int i = 0; i < smallPrimes.length; i++) {
for (int j = 0; j < 5; j++) {// Try the tests a few times
for (int j = 0; j < 5; j++) { // Try the tests a few times
// Can't use clear as some objects are still active so create
// a new pool
trackerFactory = new VisitTrackerFactory<>();
Expand Down

0 comments on commit 1b3c83f

Please sign in to comment.