From 45a28e5d366606486c7a6bead76c34638455a7c1 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 27 Jan 2012 15:44:05 +0000 Subject: [PATCH] [dstore] cancelable threads not removed fast enough from Hashmap, resulting in OOM --- .../miners/UniversalFileSystemMiner.java | 9 ++++--- .../filesystem/UniversalDownloadHandler.java | 27 +++++++++++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java index 8db5cb6e70b..c46623e951e 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/dstore/universal/miners/UniversalFileSystemMiner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -41,6 +41,7 @@ * David McKnight (IBM) - [251729][dstore] problems querying symbolic link folder * David McKnight (IBM) - [243495] [api] New: Allow file name search in Remote Search to not be case sensitive * David McKnight (IBM) - [283617] [dstore] UniversalFileSystemMiner.handleQueryGetRemoteObject does not return correct result when the queried file does not exist. + * David McKnight (IBM) - [dstore] cancelable threads not removed fast enough from Hashmap, resulting in OOM *******************************************************************************/ package org.eclipse.rse.dstore.universal.miners; @@ -470,7 +471,9 @@ public class UniversalFileSystemMiner extends Miner { _dataStore.trace(e); } // save find thread in hashmap for retrieval during cancel - _cancellableThreads.put(command, thread); + if (!thread.isDone() && !thread.isCancelled()){ + _cancellableThreads.put(command, thread); + } } @@ -1352,7 +1355,7 @@ public class UniversalFileSystemMiner extends Miner { } public void finish() { - //_archiveHandlerManager.dispose(); + _cancellableThreads.clear(); super.finish(); } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalDownloadHandler.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalDownloadHandler.java index d33bf47d936..b4d5c98bc65 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalDownloadHandler.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalDownloadHandler.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2008 IBM Corporation and others. + * Copyright (c) 2006, 2012 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -14,6 +14,7 @@ * Contributors: * Xuan Chen (IBM) - [160775] [api] rename (at least within a zip) blocks UI thread * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients + * David McKnight (IBM) - [dstore] cancelable threads not removed fast enough from Hashmap, resulting in OOM *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.filesystem; @@ -24,6 +25,7 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.UnsupportedEncodingException; +import java.lang.reflect.Method; import org.eclipse.dstore.core.model.DE; import org.eclipse.dstore.core.model.DataElement; @@ -62,8 +64,29 @@ public class UniversalDownloadHandler extends SecuredThread implements ICancella { super.run(); - handleDownload(_cmdElement, _status); + handleDownload(_cmdElement, _status); _isDone = true; + removeFromCancellableList(); + } + + private void removeFromCancellableList(){ + Class clazz = _miner.getClass(); + + try { + Method[] methods = clazz.getDeclaredMethods(); + for (int i = 0; i < methods.length; i++){ + Method method = methods[i]; + if (method.getName().equals("updateCancellableThreads")){ //$NON-NLS-1$ + method.setAccessible(true); + Object[] args = { _status.getParent(), this }; + method.invoke(_miner, args); + return; + } + } + + } catch (Exception e) { + _dataStore.trace(e); + } } public boolean isDone()