Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSarika Sinha2015-03-03 06:30:46 -0500
committerSarika Sinha2015-03-03 06:30:46 -0500
commit25611f0b960f8297cf41ec2a2ffe7d49c22209aa (patch)
tree87156c58215bd21bb8a456eb5ea0f607c6bebc10 /org.eclipse.debug.ui/ui/org/eclipse/debug/ui
parent9e0b67e5552fec7597bc1da9d9bc705816275409 (diff)
downloadeclipse.platform.debug-25611f0b960f8297cf41ec2a2ffe7d49c22209aa.tar.gz
eclipse.platform.debug-25611f0b960f8297cf41ec2a2ffe7d49c22209aa.tar.xz
eclipse.platform.debug-25611f0b960f8297cf41ec2a2ffe7d49c22209aa.zip
Bug 461219 - Compile warnings in official buildI20150303-0800
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java25
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java39
2 files changed, 28 insertions, 36 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java
index 4f425053e..f6c4cd455 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ExportBreakpointsOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2014 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 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
@@ -31,7 +31,6 @@ import org.eclipse.debug.internal.ui.importexport.breakpoints.IImportExportConst
import org.eclipse.debug.internal.ui.importexport.breakpoints.ImportExportMessages;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.operation.IRunnableWithProgress;
-
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
@@ -89,10 +88,9 @@ public class ExportBreakpointsOperation implements IRunnableWithProgress {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
SubMonitor localmonitor = SubMonitor.convert(monitor, ImportExportMessages.ExportOperation_0, fBreakpoints.length);
XMLMemento memento = XMLMemento.createWriteRoot(IImportExportConstants.IE_NODE_BREAKPOINTS);
- Writer writer = fWriter;
- try {
+ try (Writer writer = fWriter;) {
for (int i = 0; i < fBreakpoints.length; i++) {
- if(localmonitor.isCanceled()) {
+ if (localmonitor.isCanceled()) {
return;
}
IBreakpoint breakpoint = fBreakpoints[i];
@@ -142,9 +140,13 @@ public class ExportBreakpointsOperation implements IRunnableWithProgress {
localmonitor.worked(1);
}
if (writer == null) {
- writer = new OutputStreamWriter(new FileOutputStream(fFileName), "UTF-8"); //$NON-NLS-1$
- }
- memento.save(writer);
+ try (Writer outWriter = new OutputStreamWriter(new FileOutputStream(fFileName), "UTF-8")) { //$NON-NLS-1$
+ memento.save(outWriter);
+ }
+ } else {
+ memento.save(writer);
+ }
+
} catch (CoreException e) {
throw new InvocationTargetException(e);
} catch (IOException e) {
@@ -152,13 +154,6 @@ public class ExportBreakpointsOperation implements IRunnableWithProgress {
}
finally {
localmonitor.done();
- if(writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
}
}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java
index 06b25b443..48e809373 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/actions/ImportBreakpointsOperation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2013 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 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
@@ -160,14 +160,27 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
SubMonitor localmonitor = SubMonitor.convert(monitor, ImportExportMessages.ImportOperation_0, 1);
- Reader reader = null;
try {
+ XMLMemento memento = null;
if (fBuffer == null) {
- reader = new InputStreamReader(new FileInputStream(fFileName), "UTF-8"); //$NON-NLS-1$
+ try (Reader reader = new InputStreamReader(new FileInputStream(fFileName), "UTF-8")) { //$NON-NLS-1$
+ memento = XMLMemento.createReadRoot(reader);
+ } catch (FileNotFoundException e) {
+ throw new InvocationTargetException(e, MessageFormat.format("Breakpoint import file not found: {0}", new Object[] { //$NON-NLS-1$
+ fFileName }));
+ } catch (UnsupportedEncodingException e) {
+ throw new InvocationTargetException(e, MessageFormat.format("The import file was written in non-UTF-8 encoding.", new Object[] { //$NON-NLS-1$
+ fFileName }));
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
+ }
} else {
- reader = new StringReader(fBuffer.toString());
+ try (Reader reader = new StringReader(fBuffer.toString())) {
+ memento = XMLMemento.createReadRoot(reader);
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
+ }
}
- XMLMemento memento = XMLMemento.createReadRoot(reader);
IMemento[] nodes = memento.getChildren(IImportExportConstants.IE_NODE_BREAKPOINT);
IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot();
localmonitor.setWorkRemaining(nodes.length);
@@ -217,28 +230,12 @@ public class ImportBreakpointsOperation implements IRunnableWithProgress {
fManager.addBreakpoints(fAdded.toArray(new IBreakpoint[fAdded.size()]));
}
}
- catch(FileNotFoundException e) {
- throw new InvocationTargetException(e,
- MessageFormat.format("Breakpoint import file not found: {0}", new Object[] { fFileName })); //$NON-NLS-1$
- }
- catch (UnsupportedEncodingException e) {
- throw new InvocationTargetException(e,
- MessageFormat.format("The import file was written in non-UTF-8 encoding.", new Object[] { fFileName })); //$NON-NLS-1$
- }
catch(CoreException ce) {
throw new InvocationTargetException(ce,
MessageFormat.format("There was a problem importing breakpoints from: {0}", new Object[] { fFileName })); //$NON-NLS-1$
}
finally {
localmonitor.done();
- if(reader != null) {
- try {
- reader.close();
- }
- catch (IOException e) {
- throw new InvocationTargetException(e);
- }
- }
}
}

Back to the top