This post originated from an RSS feed registered with Java Buzz
by Anthony Eden.
Original Post: Leaky Streams
Feed Title: All Things
Feed URL: http://allthings.mp/
Feed Description: Blogging about Java, Python, technology and generally anything which is of interest to me.
Leaky streams can be a serious problem to long-running or heavily loaded applications. After a JPublish user notified me of issues he found during load testing, I spent some time looking through the code for JPublish and EdenLib trying to find streams which were opened and not closed. Lo and behold I found some and fixed them. Attempt number 2 ended with similar results: Too Many Files Open errors. Back to the code. I found a couple more leaks and committed the changes. Next day I recevied a message stating that the problem was still there. Darn, I thought...ok, one more time. Naturally at this point I was thinking to myself that there must be a tool somewhere for locating and elimiting streams which are not properly closed (and if there is please leave a comment with a URL, thanks). Anyhow, I found one more potential problem spot and updated the code. This morning a got a nice email stating that the problems appear to be fixed.
So the rule here is to be very careful when you open streams, especially when you are returning those streams as part of a method. This is the problem which caused me problems.