Author: markt Date: Tue Mar 25 22:56:23 2014 New Revision: 1581572 URL: http://svn.apache.org/r1581572 Log: Try with resources for javax.*
Modified: tomcat/trunk/java/javax/el/ExpressionFactory.java Modified: tomcat/trunk/java/javax/el/ExpressionFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/ExpressionFactory.java?rev=1581572&r1=1581571&r2=1581572&view=diff ============================================================================== --- tomcat/trunk/java/javax/el/ExpressionFactory.java (original) +++ tomcat/trunk/java/javax/el/ExpressionFactory.java Tue Mar 25 22:56:23 2014 @@ -382,11 +382,8 @@ public abstract class ExpressionFactory if (is != null) { String line = null; - BufferedReader br = null; - InputStreamReader isr = null; - try { - isr = new InputStreamReader(is, "UTF-8"); - br = new BufferedReader(isr); + try (InputStreamReader isr = new InputStreamReader(is, "UTF-8"); + BufferedReader br = new BufferedReader(isr)) { line = br.readLine(); if (line != null && line.trim().length() > 0) { return line.trim(); @@ -399,16 +396,6 @@ public abstract class ExpressionFactory e); } finally { try { - if (br != null) { - br.close(); - } - } catch (IOException ioe) {/*Ignore*/} - try { - if (isr != null) { - isr.close(); - } - } catch (IOException ioe) {/*Ignore*/} - try { is.close(); } catch (IOException ioe) {/*Ignore*/} } @@ -420,9 +407,7 @@ public abstract class ExpressionFactory private static String getClassNameJreDir() { File file = new File(PROPERTY_FILE); if (file.canRead()) { - InputStream is = null; - try { - is = new FileInputStream(file); + try (InputStream is = new FileInputStream(file)){ Properties props = new Properties(); props.load(is); String value = props.getProperty(PROPERTY_NAME); @@ -433,14 +418,6 @@ public abstract class ExpressionFactory // Should not happen - ignore it if it does } catch (IOException e) { throw new ELException("Failed to read " + PROPERTY_FILE, e); - } finally { - if (is != null) { - try { - is.close(); - } catch (IOException e) { - // Ignore - } - } } } return null; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org