Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource leak: FileInputStream is not closed on method exit #314

Open
GoogleCodeExporter opened this issue May 5, 2015 · 1 comment
Open

Comments

@GoogleCodeExporter
Copy link

I have V2.1 sources.

2 places in ESAPIWebApplicationFirewallFilter.java do not close file streams.

The corrected 2 methods are:

public void setConfiguration( String policyFilePath, String webRootDir ) throws 
FileNotFoundException {



                                FileInputStream inputStream = null;

                                try {

                                                inputStream = new FileInputStream(new File(policyFilePath));

                                                appGuardConfig = ConfigurationParser.readConfigurationFile(inputStream, webRootDir);

                                                lastConfigReadTime = System.currentTimeMillis();

                                                configurationFilename = policyFilePath;

                                } catch (ConfigurationException e ) {

            // TODO: It would be ideal if this method through the ConfigurationException rather than catching it and

            // writing the error to the console.

                                                e.printStackTrace();

                                } finally {

                                                if (inputStream != null) {

                                                                try {

                                                                                inputStream.close();

                                                                } catch (IOException e) {

                                                                                e.printStackTrace();

                                                                }

                                                }

                                }

                }

/* and the block ... */

  FileInputStream inputStream = null;

                                try {



                                                String webRootDir = fc.getServletContext().getRealPath("/");

                                                inputStream = new FileInputStream(configurationFilename);

                                                appGuardConfig = ConfigurationParser.readConfigurationFile(inputStream, webRootDir);



                                                DOMConfigurator.configure(realLogSettingsFilename);



                                                lastConfigReadTime = System.currentTimeMillis();



                                } catch (FileNotFoundException e) {

                                                throw new ServletException(e);

                                } catch (ConfigurationException e) {

                                                throw new ServletException(e);

                                } finally {

                                                if (inputStream != null) {

                                                                try {

                                                                                inputStream.close();

                                                                } catch (IOException e) {

                                                                                e.printStackTrace();

                                                                }

                                                }

                                }

Original issue reported on code.google.com by [email protected] on 26 Nov 2013 at 7:48

@GoogleCodeExporter
Copy link
Author

Eamonn,
Would you like this work to be considered for the ESAPI hackathon contest? If 
so, please email me ASAP. Thanks.
-kevin wall <[email protected]>

Original comment by [email protected] on 23 Jan 2014 at 6:56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant