{"action":"created","issue":{"url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/issues/319","labels_url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/issues/319/labels{/name}","comments_url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/issues/319/comments","events_url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/issues/319/events","html_url":"https://github.com/ESAPI/esapi-java-legacy/issues/319","id":48672713,"number":319,"title":"Resource leak: FileInputStream is not closed on method exit","user":{"login":"meg23","id":814859,"avatar_url":"https://avatars.githubusercontent.com/u/814859?v=3","gravatar_id":"","url":"https://api.github.com/users/meg23","html_url":"https://github.com/meg23","followers_url":"https://api.github.com/users/meg23/followers","following_url":"https://api.github.com/users/meg23/following{/other_user}","gists_url":"https://api.github.com/users/meg23/gists{/gist_id}","starred_url":"https://api.github.com/users/meg23/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meg23/subscriptions","organizations_url":"https://api.github.com/users/meg23/orgs","repos_url":"https://api.github.com/users/meg23/repos","events_url":"https://api.github.com/users/meg23/events{/privacy}","received_events_url":"https://api.github.com/users/meg23/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/labels/Priority-Medium","name":"Priority-Medium","color":"FFFFFF"}],"state":"closed","locked":false,"assignee":{"login":"kwwall","id":1959835,"avatar_url":"https://avatars.githubusercontent.com/u/1959835?v=3","gravatar_id":"","url":"https://api.github.com/users/kwwall","html_url":"https://github.com/kwwall","followers_url":"https://api.github.com/users/kwwall/followers","following_url":"https://api.github.com/users/kwwall/following{/other_user}","gists_url":"https://api.github.com/users/kwwall/gists{/gist_id}","starred_url":"https://api.github.com/users/kwwall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwwall/subscriptions","organizations_url":"https://api.github.com/users/kwwall/orgs","repos_url":"https://api.github.com/users/kwwall/repos","events_url":"https://api.github.com/users/kwwall/events{/privacy}","received_events_url":"https://api.github.com/users/kwwall/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2014-11-13T18:27:00Z","updated_at":"2016-01-17T20:30:34Z","closed_at":"2016-01-17T20:30:34Z","body":"_From [eamonn.w...@gmail.com](https://code.google.com/u/104114803397285871233/) on November 26, 2013 14:48:44_\n\nI have V2.1 sources.\r\n\r\n2 places in ESAPIWebApplicationFirewallFilter.java do not close file streams.\r\n\r\nThe corrected 2 methods are:\r\n\r\npublic void setConfiguration( String policyFilePath, String webRootDir ) throws FileNotFoundException {\r\n\r\n                               \r\n\r\n                                FileInputStream inputStream = null;\r\n\r\n                                try {\r\n\r\n                                                inputStream = new FileInputStream(new File(policyFilePath));\r\n\r\n                                                appGuardConfig = ConfigurationParser.readConfigurationFile(inputStream, webRootDir);\r\n\r\n                                                lastConfigReadTime = System.currentTimeMillis();\r\n\r\n                                                configurationFilename = policyFilePath;\r\n\r\n                                } catch (ConfigurationException e ) {\r\n\r\n            // TODO: It would be ideal if this method through the ConfigurationException rather than catching it and\r\n\r\n            // writing the error to the console.\r\n\r\n                                                e.printStackTrace();\r\n\r\n                                } finally {\r\n\r\n                                                if (inputStream != null) {\r\n\r\n                                                                try {\r\n\r\n                                                                                inputStream.close();\r\n\r\n                                                                } catch (IOException e) {\r\n\r\n                                                                                e.printStackTrace();\r\n\r\n                                                                }\r\n\r\n                                                }\r\n\r\n                                }\r\n\r\n                }\r\n\r\n/* and the block ... */\r\n\r\n  FileInputStream inputStream = null;\r\n\r\n                                try {\r\n\r\n \r\n\r\n                                                String webRootDir = fc.getServletContext().getRealPath(\"/\");\r\n\r\n                                                inputStream = new FileInputStream(configurationFilename);\r\n\r\n                                                appGuardConfig = ConfigurationParser.readConfigurationFile(inputStream, webRootDir);\r\n\r\n \r\n\r\n                                                DOMConfigurator.configure(realLogSettingsFilename);\r\n\r\n \r\n\r\n                                                lastConfigReadTime = System.currentTimeMillis();\r\n\r\n                                               \r\n\r\n                                } catch (FileNotFoundException e) {\r\n\r\n                                                throw new ServletException(e);\r\n\r\n                                } catch (ConfigurationException e) {\r\n\r\n                                                throw new ServletException(e);\r\n\r\n                                } finally {\r\n\r\n                                                if (inputStream != null) {\r\n\r\n                                                                try {\r\n\r\n                                                                                inputStream.close();\r\n\r\n                                                                } catch (IOException e) {\r\n\r\n                                                                                e.printStackTrace();\r\n\r\n                                                                }\r\n\r\n                                                }\r\n\r\n                                }\n\n_Original issue: http://code.google.com/p/owasp-esapi-java/issues/detail?id=314_"},"comment":{"url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/issues/comments/172378140","html_url":"https://github.com/ESAPI/esapi-java-legacy/issues/319#issuecomment-172378140","issue_url":"https://api.github.com/repos/ESAPI/esapi-java-legacy/issues/319","id":172378140,"user":{"login":"kwwall","id":1959835,"avatar_url":"https://avatars.githubusercontent.com/u/1959835?v=3","gravatar_id":"","url":"https://api.github.com/users/kwwall","html_url":"https://github.com/kwwall","followers_url":"https://api.github.com/users/kwwall/followers","following_url":"https://api.github.com/users/kwwall/following{/other_user}","gists_url":"https://api.github.com/users/kwwall/gists{/gist_id}","starred_url":"https://api.github.com/users/kwwall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kwwall/subscriptions","organizations_url":"https://api.github.com/users/kwwall/orgs","repos_url":"https://api.github.com/users/kwwall/repos","events_url":"https://api.github.com/users/kwwall/events{/privacy}","received_events_url":"https://api.github.com/users/kwwall/received_events","type":"User","site_admin":false},"created_at":"2016-01-17T20:30:34Z","updated_at":"2016-01-17T20:30:34Z","body":"Fixed with commit dffaddbb59946fb4ba46d5fb97830af277b408d7."}}