From b129a7fed35137bd2bf39a8ce2d648753e875e82 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Wed, 19 Oct 2011 18:32:04 +0000 Subject: [PATCH] [358301] [DSTORE] Hang during debug source look up --- .../miners/filesystem/FileClassifier.java | 44 +++++++++++++++++-- .../miners/filesystem/FileQueryThread.java | 7 ++- .../miners/filesystem/QueryThread.java | 9 +++- .../filesystem/UniversalSearchHandler.java | 18 +++++++- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileClassifier.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileClassifier.java index 8f134e60c1f..97968ab640b 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileClassifier.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileClassifier.java @@ -22,6 +22,7 @@ * David McKnight (IBM) - [283613] [dstore] Create a Constants File for all System Properties we support * David McKnight (IBM) - [153635] [dstore-linux] dangling symbolic links are not classified properly * David McKnight (IBM) - [350581] [dstore] FileClassifier should default to English + * David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.filesystem; @@ -272,7 +273,10 @@ public class FileClassifier extends SecuredThread super.run(); if (!_systemSupportsClassify) return; - init(); + + try { + init(); + // get full path String filePath = null; @@ -337,6 +341,10 @@ public class FileClassifier extends SecuredThread } _dataStore.disconnectObject(_subject); _dataStore.refresh(_subject); + } + catch (OutOfMemoryError e){ + System.exit(-1); + } } /** @@ -656,6 +664,9 @@ public class FileClassifier extends SecuredThread } } } + catch (OutOfMemoryError e){ + System.exit(-1); + } catch (Exception e) { e.printStackTrace(); @@ -663,6 +674,9 @@ public class FileClassifier extends SecuredThread available = stream.available(); } } + catch (OutOfMemoryError e){ + System.exit(-1); + } catch (Exception e) { e.printStackTrace(); @@ -728,8 +742,14 @@ public class FileClassifier extends SecuredThread envVars = new String[] {langVar}; } - // run command with the working directory being the parent file - Process theProcess = Runtime.getRuntime().exec(args, envVars, parentFile); + // run command with the working directory being the parent file + Process theProcess = null; + try { + theProcess = Runtime.getRuntime().exec(args, envVars, parentFile); + } + catch (OutOfMemoryError e){ + System.exit(-1); + } BufferedReader reader = null; DataInputStream stream = null; @@ -755,6 +775,9 @@ public class FileClassifier extends SecuredThread else line = readLine(stream, _specialEncoding);//reader.readLine(); } + catch (OutOfMemoryError e){ + System.exit(-1); + } catch (Exception e) { } @@ -911,6 +934,9 @@ public class FileClassifier extends SecuredThread else line = readLine(stream, _specialEncoding); } + catch (OutOfMemoryError e){ + System.exit(-1); + } catch (Exception e) { e.printStackTrace(); @@ -954,6 +980,9 @@ public class FileClassifier extends SecuredThread } } } + catch (OutOfMemoryError e){ + System.exit(-1); + } catch (Exception e) { e.printStackTrace(); @@ -1069,4 +1098,13 @@ public class FileClassifier extends SecuredThread // TODO: log error } } + + public void start(){ + try { + super.start(); + } + catch (OutOfMemoryError e){ + System.exit(-1); + } + } } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileQueryThread.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileQueryThread.java index b4e6102f9da..0fa2d54b5d0 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileQueryThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/FileQueryThread.java @@ -15,6 +15,7 @@ * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients * David McKnight (IBM) - [251650] [dstore] Multiple copies of symbolic link file show in Table view * David McKnight (IBM) - [251729][dstore] problems querying symbolic link folder + * David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.filesystem; @@ -369,7 +370,11 @@ public class FileQueryThread extends QueryThread } } - } catch (Exception e) { + } + catch (OutOfMemoryError e){ + System.exit(-1); + } + catch (Exception e) { e.printStackTrace(); UniversalServerUtilities.logError(UniversalFileSystemMiner.CLASSNAME, "createDataElement failed with exception - isFile ", e, _dataStore); //$NON-NLS-1$ diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/QueryThread.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/QueryThread.java index b13c709bd8c..9b34690d450 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/QueryThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/QueryThread.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 IBM Corporation and others. + * Copyright (c) 2007, 2011 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 @@ -12,6 +12,7 @@ * Contributors: * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients * Martin Oberhuber (Wind River) - [199854][api] Improve error reporting for archive handlers + * David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.filesystem; @@ -113,6 +114,7 @@ public class QueryThread extends SecuredThread implements ICancellableHandler { else expandedSize = size; + try { buffer.append(version).append(IServiceConstants.TOKEN_SEPARATOR).append(date).append( IServiceConstants.TOKEN_SEPARATOR).append(size).append(IServiceConstants.TOKEN_SEPARATOR); buffer.append(hidden).append(IServiceConstants.TOKEN_SEPARATOR).append(canWrite).append( @@ -126,7 +128,10 @@ public class QueryThread extends SecuredThread implements ICancellableHandler { IServiceConstants.TOKEN_SEPARATOR); buffer.append(compressionRatio).append(IServiceConstants.TOKEN_SEPARATOR).append( expandedSize); - + } + catch (OutOfMemoryError e){ + System.exit(-1); + } String buf = buffer.toString(); return buf; diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalSearchHandler.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalSearchHandler.java index 89e5436498f..27be59ee89f 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalSearchHandler.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/filesystem/UniversalSearchHandler.java @@ -26,6 +26,7 @@ * David McKnight (IBM) - [299568] Remote search only shows result in the symbolic linked file * David McKnight (IBM] - [330989] [dstore] OutOfMemoryError occurs when searching for a text in a large remote file * David McKnight (IBM) - [283613] [dstore] Create a Constants File for all System Properties we support + * David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up ********************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.filesystem; @@ -35,6 +36,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.HashSet; +import java.util.Iterator; import org.eclipse.dstore.core.model.DE; import org.eclipse.dstore.core.model.DataElement; @@ -56,6 +58,7 @@ import org.eclipse.rse.services.clientserver.archiveutils.VirtualChild; import org.eclipse.rse.services.clientserver.messages.SystemMessageException; import org.eclipse.rse.services.clientserver.search.SystemSearchFileNameMatcher; import org.eclipse.rse.services.clientserver.search.SystemSearchLineMatch; +import org.eclipse.rse.services.clientserver.search.SystemSearchMatch; import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatchLocator; import org.eclipse.rse.services.clientserver.search.SystemSearchStringMatcher; @@ -504,11 +507,22 @@ public class UniversalSearchHandler extends SecuredThread implements ICancellabl for (int i = 0; i < lineMatches.length; i++) { match = lineMatches[i]; + DataElement obj = _dataStore.createObject(deObj, _deGrep, match.getLine(), absPath); - obj.setAttribute(DE.A_SOURCE, obj.getSource() + ':'+ match.getLineNumber()); - + String sourceString = obj.getSource() + ':'+ match.getLineNumber(); + + Iterator iter = match.getMatches(); + StringBuffer offsets = new StringBuffer(); + while (iter.hasNext()){ + SystemSearchMatch m = (SystemSearchMatch)iter.next(); + int start = m.getStartOffset(); + int end = m.getEndOffset(); + offsets.append("(" + start + "," + end + ")"); + } + obj.setAttribute(DE.A_SOURCE, sourceString + offsets.toString()); } _dataStore.disconnectObjects(deObj); + _dataStore.refresh(deObj); } public void checkAndClearupMemory()