File descriptor leaks [patch]

Hi guys,

Smack opens a new file for the trust store every time a connection is created, but it never cleans up after itself once KeyLoad.load has done its job. The fix, of course, is simple and I’'ve attached it.

Here is a simple block of code that will illustrate the problem (i.e., that the file remains open):

KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());

FileInputStream is = new FileInputStream("/etc/java-6-sun/security/cacerts");

System.out.println(is.getChannel().isOpen()); // expected true

trustStore.load(is, “changeit”.toCharArray());

System.out.println(is.getChannel().isOpen()); // expected true, desired false

I’'m also reporting this to the FindBugs team, so they can create a test for this case
patch.txt (1484 Bytes)

Thanks! I filed this as SMACK-188.

Regards,

Matt