Commit 933c2de
committed
Fix resource leak in ThingFactory class
Change ThingFactory class to use try-with-resource statement to manage
the InputStream used to read the file "thing.properties", so that it's
(always) closed.
The issue manifested while exercising, a lot, the OWASP Benchmark
application with OWASP ZAP (for zaproxy/zaproxy#1890).
After many requests sent Benchmark started to fail to fulfil ZAP's
requests. In the output of Tomcat there were many entries like:
[INFO] [talledLocalContainer] Can't find thing.properties
and also:
[INFO] [talledLocalContainer] SEVERE: Socket accept failed
[INFO] [talledLocalContainer] java.io.IOException: Too many open files
the reason why ZAP's requests were no longer fulfilled.
Other attempts to read other files also led to same issue, for example:
...webapps/benchmark/WEB-INF/classes/employees.xml (Too many open files)
Looking at the list of Benchmark's open files it was evident that the
leak was related to read of "thing.properties" file, given how many
open "thing.properties" files there were.
After the change OWASP Benchmark was able to withstand more than twice
the requests without exhibiting the aforementioned issue.1 parent 0ed220b commit 933c2de
1 file changed
Lines changed: 1 addition & 2 deletions
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
0 commit comments