peval / owasp-esapi-java

Automatically exported from code.google.com/p/owasp-esapi-java
Other
0 stars 0 forks source link

Resource leak: This FileReader is not closed on method exit #312

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I have V2.1 sources.

BeanShellRule.java keeps a file open, the fix is as follows:

private String getFileContents(File f) throws IOException {

                                StringBuffer sb = new StringBuffer();

                                BufferedReader br = null;

                                try {

                                                br = new BufferedReader(new FileReader(f));

                                                String line;

                                                while ((line = br.readLine()) != null) {

                                                                sb.append(line + System.getProperty("line.separator"));

                                                }

                                } finally {

                                                if (br != null) {

                                                                br.close();

                                                }

                                }

                                return sb.toString();

                }

Original issue reported on code.google.com by eamonn.w...@gmail.com on 26 Nov 2013 at 7:10