From 6922df7df34c0b082a446edda843cc799c4f3982 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Mon, 11 Jun 2007 13:56:39 +0000 Subject: [PATCH] [190803] handling of interrupted exceptions --- .../dstore/files/DStoreFileService.java | 12 +++- .../processes/DStoreProcessService.java | 10 ++- .../dstore/shells/DStoreShellService.java | 10 ++- .../dstore/AbstractDStoreService.java | 68 ++++++++++++++----- .../dstore/util/DStoreStatusMonitor.java | 8 ++- 5 files changed, 82 insertions(+), 26 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java index a10087002e9..fb986282cea 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/files/DStoreFileService.java @@ -15,6 +15,7 @@ * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API * Xuan Chen (IBM) - [189681] [dstore][linux] Refresh Folder in My Home messes up Refresh in Root * Kushal Munir (IBM) - [189352] Replace with appropriate line end character on upload + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.files; @@ -679,10 +680,15 @@ public class DStoreFileService extends AbstractDStoreService implements IFileSer } catch (InterruptedException e) { - e.printStackTrace(); + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } - - //getStatusMonitor(ds).waitForUpdate(status, monitor); } catch (Exception e) { diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java index 1e0d9b3b0d7..09e4942ab70 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/processes/DStoreProcessService.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.processes; @@ -304,7 +305,14 @@ public class DStoreProcessService extends AbstractProcessService implements IPro } catch (InterruptedException e) { - e.printStackTrace(); + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } getMinerElement(); } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java index 5ec51a485a9..ed1310ed6ba 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/internal/services/dstore/shells/DStoreShellService.java @@ -12,6 +12,7 @@ * * Contributors: * Martin Oberhuber (Wind River) - [186128] Move IProgressMonitor last in all API + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout ********************************************************************************/ package org.eclipse.rse.internal.services.dstore.shells; @@ -151,7 +152,14 @@ public class DStoreShellService extends AbstractDStoreService implements IShellS } catch (InterruptedException e) { - e.printStackTrace(); + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } getMinerElement(getEnvSystemMinerId()); } diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java index 3ef95125143..8a703f78e1a 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/AbstractDStoreService.java @@ -11,7 +11,8 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * Martin Oberhuber (Wind River) - [186128][refactoring] Move IProgressMonitor last in public base classes + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout ********************************************************************************/ package org.eclipse.rse.services.dstore; @@ -87,11 +88,7 @@ public abstract class AbstractDStoreService implements IDStoreService DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); smon.waitForUpdate(status, monitor); int resultSize = subject.getNestedSize(); - if (resultSize == 0) - { - //System.out.println("status="+status); - //System.out.println("subject="+subject); - } + checkHostJVM(); // get results List nested = subject.getNestedData(); @@ -100,15 +97,19 @@ public abstract class AbstractDStoreService implements IDStoreService return (DataElement[])nested.toArray(new DataElement[resultSize]); } } - catch (Exception e) - { - e.printStackTrace(); + catch (InterruptedException e) + { + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } } - else - { - System.out.println("no query command for "+ subject); //$NON-NLS-1$ - } + return new DataElement[0]; } @@ -125,8 +126,16 @@ public abstract class AbstractDStoreService implements IDStoreService DStoreStatusMonitor smon = getStatusMonitor(getDataStore()); smon.waitForUpdate(status, monitor); } - catch (Exception e) + catch (InterruptedException e) { + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } return status; } @@ -153,9 +162,16 @@ public abstract class AbstractDStoreService implements IDStoreService return (DataElement[])nested.toArray(new DataElement[subject.getNestedSize()]); } } - catch (Exception e) + catch (InterruptedException e) { - e.printStackTrace(); + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } } return new DataElement[0]; @@ -174,8 +190,17 @@ public abstract class AbstractDStoreService implements IDStoreService { getStatusMonitor(ds).waitForUpdate(status, monitor); } - catch (Exception e) + catch (InterruptedException e) { + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 + } return status; } @@ -252,7 +277,14 @@ public abstract class AbstractDStoreService implements IDStoreService } catch (InterruptedException e) { - e.printStackTrace(); + // cancel monitor if it's still not canceled + if (monitor != null && !monitor.isCanceled()) + { + monitor.setCanceled(true); + } + + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 } getMinerElement(); diff --git a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java index 3fa2ae1ddad..1b866f87daa 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/src/org/eclipse/rse/services/dstore/util/DStoreStatusMonitor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2007 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,7 +12,7 @@ * Emily Bruner, Mazen Faraj, Adrian Storisteanu, Li Ding, and Kent Hawley. * * Contributors: - * {Name} (company) - description of contribution. + * David McKnight (IBM) - [190803] Canceling a long-running dstore job prints "InterruptedException" to stdout *******************************************************************************/ package org.eclipse.rse.services.dstore.util; @@ -382,7 +382,9 @@ public class DStoreStatusMonitor implements IDomainListener } catch (InterruptedException e) { - e.printStackTrace(); + //InterruptedException is used to report user cancellation, so no need to log + //This should be reviewed (use OperationCanceledException) with bug #190750 + return; } }