7 ms·
> “Resource leaks, where resources like files, database connections, or streams aren’t properly released after use, are a persistent issue in Java applications”
by stevoski 1y ago
> “Resource leaks, where resources like files, database connections, or streams aren’t properly released after use, are a persistent issue in Java applications”
This was true maybe back in 2005. Java has had try-with-resources for a loooong time. As I see it this has been the dominant idiom for ages, for handling resources that might leak.
- okr 1y agoPeople tend to forget. Stream-API is a good candidate, that people like to not consider for leakage. If you don't own your stream, if you do not definitly know, that your stream comes from a collection, then ya better close it with a try-block.