if (busy.contains(con))
continue;
long time = con.getTimestamp();
- if (((now - time) > con.getReleaseTime()) && (getSize()>getPoolProperties().getMinIdle())) {
+ if ((con.getReleaseTime()>0) && ((now - time) > con.getReleaseTime()) && (getSize()>getPoolProperties().getMinIdle())) {
release(con);
idle.remove(con);
setToNull = true;
protected final static String PROP_FAIR_QUEUE = "fairQueue";
protected static final String PROP_USE_EQUALS = "useEquals";
+ protected static final String PROP_USE_CON_LOCK = "useLock";
public static final int UNKNOWN_TRANSACTIONISOLATION = -1;
PROP_USE_EQUALS,
OBJECT_NAME,
PROP_ABANDONWHENPERCENTAGEFULL,
- PROP_MAXAGE
+ PROP_MAXAGE,
+ PROP_USE_CON_LOCK
};
// -------------------------------------------------- ObjectFactory Methods
poolProperties.setMaxAge(Long.parseLong(value));
}
+ value = properties.getProperty(PROP_USE_CON_LOCK);
+ if (value != null) {
+ poolProperties.setUseLock(Boolean.parseBoolean(value));
+ }
+
return poolProperties;
}
this.getPoolProperties().setFairQueue(fairQueue);
}
+ public void setUseLock(boolean useLock) {
+ this.getPoolProperties().setUseLock(useLock);
+ }
+
public void setDefaultCatalog(String catalog) {
this.getPoolProperties().setDefaultCatalog(catalog);
}
protected boolean useEquals = false;
protected int abandonWhenPercentageFull = 0;
protected long maxAge = 0;
- protected boolean useLock = true;
+ protected boolean useLock = false;
private InterceptorDefinition[] interceptors = null;
public void setAbandonWhenPercentageFull(int percentage) {
/**
* Timestamp the connection was last 'touched' by the pool
*/
- private long timestamp;
+ private volatile long timestamp;
/**
* Lock for this connection only
*/
public void testBrutal() throws Exception {
ds.getPoolProperties().setRemoveAbandoned(false);
- ds.getPoolProperties().setMinEvictableIdleTimeMillis(-1);
+ ds.getPoolProperties().setMinEvictableIdleTimeMillis(10);
ds.getPoolProperties().setTimeBetweenEvictionRunsMillis(-1);
ds.getConnection().close();
- final int iter = 1000 * 10;
+ final int iter = 100000 * 10;
final AtomicInteger loopcount = new AtomicInteger(0);
final Runnable run = new Runnable() {
public void run() {
try {
while (loopcount.incrementAndGet() < iter) {
Connection con = ds.getConnection();
- Thread.sleep(10);
con.close();
}
}catch (Exception x) {
assertEquals("Size comparison:",10, ds.getPool().getSize());
assertEquals("Idle comparison:",10, ds.getPool().getIdle());
assertEquals("Used comparison:",0, ds.getPool().getActive());
- assertEquals("Connect count",10,Driver.connectCount.get());
+ assertEquals("Connect count",10,Driver.connectCount.get()-Driver.disconnectCount.get());
}