From 3dc5c0a138562820c8cefa26b7f864ac4f1a2682 Mon Sep 17 00:00:00 2001 From: Alexander Kurtakov Date: Fri, 15 Apr 2016 15:03:48 +0300 Subject: autotools; Use try-with-resources. Change-Id: I424a07664a587ac65210dbe33b96e3f914a1c274 Signed-off-by: Alexander Kurtakov --- .../cdt/internal/autotools/core/ErrorParser.java | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'build/org.eclipse.cdt.autotools.core') diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java index f434247cad3..4f6041f66d2 100644 --- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java +++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/ErrorParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 Red Hat Inc. + * Copyright (c) 2010, 2016 Red Hat Inc. 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 @@ -193,15 +193,11 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { * @return */ private int getErrorConfigLineNumber(String name) { - LineNumberReader reader = null; - try { - File file = new File(buildDir + "/config.log"); - // If the log file is not present there is nothing we can do. - if (!file.exists()) - return -1; - - reader = new LineNumberReader(new FileReader(file)); - + File file = new File(buildDir + "/config.log"); + // If the log file is not present there is nothing we can do. + if (!file.exists()) + return -1; + try (LineNumberReader reader = new LineNumberReader(new FileReader(file))) { Pattern errorPattern = Pattern.compile("configure:(\\d+): checking for " + name); //$NON-NLS-1$ String line; @@ -213,14 +209,6 @@ public class ErrorParser extends MarkerGenerator implements IErrorParser { } } catch (IOException e) { return -1; - } finally { - if (reader != null) { - try { - reader.close(); - } catch (IOException e) { - // Ignore. - } - } } return -1; } -- cgit v1.2.3