*) Bugfix for ClassCastException during SessionPool.close

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@996 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 19 years ago
parent e58e85363d
commit 723e056c48

@ -520,7 +520,12 @@ public final class serverCore extends serverAbstractThread implements serverThre
* @see org.apache.commons.pool.impl.GenericObjectPool#returnObject(java.lang.Object)
*/
public void returnObject(Object obj) throws Exception {
if (obj instanceof Session) {
super.returnObject(obj);
} else {
serverLog.logSevere("SESSION-POOL","Object of wront type '" + obj.getClass().getName() +
"'returned to pool.");
}
}
public synchronized void close() throws Exception {
@ -541,9 +546,11 @@ public final class serverCore extends serverAbstractThread implements serverThre
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
Thread currentThread = threadList[currentThreadIdx];
if (currentThread.isAlive()) {
if (currentThread instanceof Session) {
((Session)currentThread).setStopped(true);
}
}
}
// waiting a frew ms for the session objects to continue processing
try { Thread.sleep(500); } catch (InterruptedException ex) {}
@ -557,20 +564,24 @@ public final class serverCore extends serverAbstractThread implements serverThre
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
Thread currentThread = threadList[currentThreadIdx];
if (currentThread.isAlive()) {
if (currentThread instanceof Session) {
serverCore.this.log.logInfo("Trying to shutdown session thread '" + currentThread.getName() + "' [" + currentThreadIdx + "].");
((Session)currentThread).close();
}
}
}
// we need to use a timeout here because of missing interruptable session threads ...
serverCore.this.log.logFine("Waiting for " + serverCore.this.theSessionThreadGroup.activeCount() + " remaining session threads to finish shutdown ...");
for ( int currentThreadIdx = 0; currentThreadIdx < threadCount; currentThreadIdx++ ) {
Thread currentThread = threadList[currentThreadIdx];
if (currentThread.isAlive()) {
if (currentThread instanceof Session) {
serverCore.this.log.logFine("Waiting for session thread '" + currentThread.getName() + "' [" + currentThreadIdx + "] to finish shutdown.");
try { currentThread.join(500); } catch (InterruptedException ex) {}
}
}
}
serverCore.this.log.logInfo("Shutdown of remaining session threads finish.");
} catch (Exception e) {
@ -616,8 +627,7 @@ public final class serverCore extends serverAbstractThread implements serverThre
* @see org.apache.commons.pool.PoolableObjectFactory#validateObject(java.lang.Object)
*/
public boolean validateObject(Object obj) {
if (obj instanceof Session)
{
if (obj instanceof Session) {
Session theSession = (Session) obj;
if (!theSession.isAlive() || theSession.isInterrupted()) return false;
if (theSession.isRunning()) return true;

Loading…
Cancel
Save