Skip to content

Commit

Permalink
Remove explicitly initialized. (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturobernalg committed Aug 8, 2021
1 parent 33e188b commit 18f6bdd
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/apache/commons/pool2/BaseObjectPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public abstract class BaseObjectPool<T> extends BaseObject implements ObjectPool<T> {

private volatile boolean closed = false;
private volatile boolean closed;

/**
* Not supported in this base implementation. Subclasses should override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ public String toString() {
volatile boolean closed;

final Object evictionLock = new Object();
private Evictor evictor = null; // @GuardedBy("evictionLock")
EvictionIterator evictionIterator = null; // @GuardedBy("evictionLock")
private Evictor evictor; // @GuardedBy("evictionLock")
EvictionIterator evictionIterator; // @GuardedBy("evictionLock")

/*
* Class loader for evictor thread to use since, in a JavaEE or similar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private class ObjectDeque<S> {
*/
private final AtomicInteger createCount = new AtomicInteger(0);

private long makeObjectCount = 0;
private long makeObjectCount;
private final Object makeObjectCountLock = new Object();

/*
Expand Down Expand Up @@ -233,10 +233,10 @@ public String toString() {
*/
private final AtomicInteger numTotal = new AtomicInteger(0);

private Iterator<K> evictionKeyIterator = null; // @GuardedBy("evictionLock")
private Iterator<K> evictionKeyIterator; // @GuardedBy("evictionLock")


private K evictionKey = null; // @GuardedBy("evictionLock")
private K evictionKey; // @GuardedBy("evictionLock")

/**
* Constructs a new {@code GenericKeyedObjectPool} using defaults from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class GenericObjectPool<T> extends BaseGenericObjectPool<T>
private static final String ONAME_BASE =
"org.apache.commons.pool2:type=GenericObjectPool,name=";

private volatile String factoryType = null;
private volatile String factoryType;

private volatile int maxIdle = GenericObjectPoolConfig.DEFAULT_MAX_IDLE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void returnObject(final Object obj) {
}
}

private ObjectPool<String> _pool = null;
private ObjectPool<String> _pool;

/**
* @param n Ignored by this implemented. Used by sub-classes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class TestKeyedObjectPool {

protected static class FailingKeyedPooledObjectFactory implements KeyedPooledObjectFactory<Object,Object> {
private final List<MethodCall> methodCalls = new ArrayList<>();
private int count = 0;
private int count;
private boolean makeObjectFail;
private boolean activateObjectFail;
private boolean validateObjectFail;
Expand Down Expand Up @@ -173,7 +173,7 @@ public PooledObject<Object> wrap(final Object value) {

protected static final String KEY = "key";

private KeyedObjectPool<Object,Object> _pool = null;
private KeyedObjectPool<Object,Object> _pool;

// Deliberate choice to create a new object in case future unit tests check
// for a specific object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public boolean validateObject(final Integer key, final PooledObject<PooledTestOb
}
}

private GenericKeyedObjectPool<Integer,PooledTestObject> pool = null;
private GenericKeyedObjectPool<Integer,PooledTestObject> pool;

private AbandonedConfig abandonedConfig = null;
private AbandonedConfig abandonedConfig;

@SuppressWarnings("deprecation")
@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ class PooledTestObject implements TrackedUse {
private static final AtomicInteger hash = new AtomicInteger();
private static final Instant INSTANT_0 = Instant.ofEpochMilli(0);
private static final Instant INSTANT_1 = Instant.ofEpochMilli(1);
private boolean active = false;
private boolean destroyed = false;
private int _hash = 0;
private boolean _abandoned = false;
private boolean detached = false; // destroy-abandoned "detaches"
private boolean active;
private boolean destroyed;
private int _hash;
private boolean _abandoned;
private boolean detached; // destroy-abandoned "detaches"

public PooledTestObject() {
_hash = hash.incrementAndGet();
Expand Down Expand Up @@ -215,9 +215,9 @@ public boolean validateObject(final PooledObject<PooledTestObject> obj) {
}
}

private GenericObjectPool<PooledTestObject> pool = null;
private GenericObjectPool<PooledTestObject> pool;

private AbandonedConfig abandonedConfig = null;
private AbandonedConfig abandonedConfig;

@SuppressWarnings("deprecation")
@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static class InvalidateThread implements Runnable {
private final String obj;
private final KeyedObjectPool<String, String> pool;
private final String key;
private boolean done = false;
private boolean done;
public InvalidateThread(final KeyedObjectPool<String, String> pool, final String key, final String obj) {
this.obj = obj;
this.pool = pool;
Expand Down Expand Up @@ -153,24 +153,24 @@ public PooledObject<Object> wrap(final Object value) {
}
}
public static class SimpleFactory<K> implements KeyedPooledObjectFactory<K,String> {
volatile int counter = 0;
volatile int counter;
final boolean valid;
int activeCount = 0;
int validateCounter = 0;
int activeCount;
int validateCounter;
boolean evenValid = true;
boolean oddValid = true;
boolean enableValidation = false;
boolean enableValidation;

long destroyLatency = 0;
long makeLatency = 0;
long validateLatency = 0;
long destroyLatency;
long makeLatency;
long validateLatency;
volatile int maxTotalPerKey = Integer.MAX_VALUE;
boolean exceptionOnPassivate = false;
boolean exceptionOnActivate = false;
boolean exceptionOnDestroy = false;
boolean exceptionOnValidate = false;
boolean exceptionOnPassivate;
boolean exceptionOnActivate;
boolean exceptionOnDestroy;
boolean exceptionOnValidate;

boolean exceptionOnCreate = false;
boolean exceptionOnCreate;

public SimpleFactory() {
this(true);
Expand Down Expand Up @@ -363,8 +363,8 @@ static class TestThread<T> implements Runnable {
/** key used in borrow / return sequence - null means random */
private final String _key;

private volatile boolean _complete = false;
private volatile boolean _failed = false;
private volatile boolean _complete;
private volatile boolean _failed;
private volatile Exception _exception;

public TestThread(final KeyedObjectPool<String,T> pool) {
Expand Down Expand Up @@ -497,10 +497,10 @@ public void run() {
// @see https://issues.apache.org/jira/browse/SUREFIRE-121

/** setUp(): {@code new GenericKeyedObjectPool<String,String>(factory)} */
private GenericKeyedObjectPool<String,String> gkoPool = null;
private GenericKeyedObjectPool<String,String> gkoPool;

/** setUp(): {@code new SimpleFactory<String>()} */
private SimpleFactory<String> simpleFactory = null;
private SimpleFactory<String> simpleFactory;

private void checkEvictionOrder(final boolean lifo) throws Exception {
final SimpleFactory<Integer> intFactory = new SimpleFactory<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class TestSoftRefOutOfMemory {
public static class LargePoolableObjectFactory extends BasePooledObjectFactory<String> {
private final String buffer;
private int counter = 0;
private int counter;

public LargePoolableObjectFactory(final int size) {
final char[] data = new char[size];
Expand Down Expand Up @@ -106,7 +106,7 @@ private enum OomeTrigger {
}

public static class SmallPoolableObjectFactory extends BasePooledObjectFactory<String> {
private int counter = 0;
private int counter;

@Override
public String create() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
public class TestSoftReferenceObjectPool extends TestBaseObjectPool {

private static class SimpleFactory extends BasePooledObjectFactory<String> {
int counter = 0;
int counter;
@Override
public String create() {
return String.valueOf(counter++);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ public void runOnce() {
}
}
private static class TaskStats {
public int waiting = 0;
public int complete = 0;
public long totalBorrowTime = 0;
public long totalReturnTime = 0;
public int nrSamples = 0;
public int waiting;
public int complete;
public long totalBorrowTime;
public long totalReturnTime;
public int nrSamples;
}

public static void main(final String[] args) {
Expand All @@ -122,7 +122,7 @@ public static void main(final String[] args) {
// test.run(1, 400, 40, 5);
}

private int logLevel = 0;
private int logLevel;

private int nrIterations = 5;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void setData(final String data) {

private KeyedObjectPool<String,TestObject> pool;

private StringWriter log = null;
private StringWriter log;


protected abstract ProxySource<TestObject> getproxySource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public void setData(final String data) {
private static final Duration ABANDONED_TIMEOUT_SECS = Duration.ofSeconds(3);


private ObjectPool<TestObject> pool = null;
private ObjectPool<TestObject> pool;

private StringWriter log = null;
private StringWriter log;


protected abstract ProxySource<TestObject> getproxySource();
Expand Down

0 comments on commit 18f6bdd

Please sign in to comment.