Skip to content

Commit 88d5d57

Browse files
EcljpseB0Tjukzi
authored andcommitted
Use try-with-resource
and enable explicitlyClosedAutoCloseable=warning
1 parent 4226895 commit 88d5d57

File tree

38 files changed

+71
-132
lines changed

38 files changed

+71
-132
lines changed

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/variables/VariablesView.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,10 @@ private int[] getWeights(IMemento memento) {
606606
public void partDeactivated(IWorkbenchPart part) {
607607
String id = part.getSite().getId();
608608
if (id.equals(getSite().getId())) {
609-
try (StringWriter writer = new StringWriter()) {
610-
XMLMemento memento = XMLMemento.createWriteRoot("VariablesViewMemento"); //$NON-NLS-1$
611-
saveViewerState(memento);
609+
StringWriter writer = new StringWriter();
610+
XMLMemento memento = XMLMemento.createWriteRoot("VariablesViewMemento"); //$NON-NLS-1$
611+
saveViewerState(memento);
612+
try {
612613
memento.save(writer);
613614

614615
IPreferenceStore store = DebugUIPlugin.getDefault().getPreferenceStore();

debug/org.eclipse.ui.externaltools/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
4040
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
4141
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
4242
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
43-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
43+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
4444
org.eclipse.jdt.core.compiler.problem.fallthroughCase=error
4545
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
4646
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning

platform/org.eclipse.platform/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
2929
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
3030
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
3131
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
32-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
32+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
3333
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
3434
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
3535
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore

resources/bundles/org.eclipse.core.filesystem/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=error
3737
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
3838
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
3939
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
40-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
40+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
4141
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
4242
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
4343
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning

resources/bundles/org.eclipse.core.resources.spysupport/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=error
2626
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
2727
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
2828
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
29-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
29+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
3030
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
3131
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
3232
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore

runtime/bundles/org.eclipse.core.contenttype/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=error
3939
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
4040
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
4141
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
42-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
42+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
4343
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
4444
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
4545
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore

runtime/bundles/org.eclipse.core.expressions/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=error
4949
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
5050
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
5151
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
52-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
52+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
5353
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
5454
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
5555
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning

runtime/bundles/org.eclipse.core.jobs/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
3232
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
3333
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
3434
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
35-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
35+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
3636
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
3737
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
3838
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning

runtime/bundles/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ org.eclipse.jdt.core.compiler.problem.discouragedReference=error
4040
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
4141
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
4242
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
43-
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
43+
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
4444
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
4545
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
4646
org.eclipse.jdt.core.compiler.problem.fieldHiding=warning

runtime/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/preferences/legacy/ProductPreferencesService.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,13 @@ private Properties loadProperties(URL url) {
111111
Properties result = new Properties();
112112
if (url == null)
113113
return result;
114-
InputStream input = null;
115-
try {
116-
input = url.openStream();
114+
try (InputStream input = url.openStream()) {
117115
result.load(input);
118116
} catch (IOException e) {
119117
if (InternalPlatform.DEBUG_PLUGIN_PREFERENCES) {
120118
InternalPlatform.message("Problem opening stream to preference customization file: " + url); //$NON-NLS-1$
121119
e.printStackTrace();
122120
}
123-
} finally {
124-
if (input != null)
125-
try {
126-
input.close();
127-
} catch (IOException e) {
128-
// ignore
129-
}
130121
}
131122
return result;
132123
}

0 commit comments

Comments
 (0)