What steps will reproduce the problem?
1. Build an app that uses typica and deploy it to Glassfish
2. Invoke a method that builds an com.xerox.amazonws.common.AWSQueryConnection
3. Because Sun's EJBClassLoader (com.sun.enterprise.loader.EJBClassLoader)
wraps all streams opened with .getResourceAsStream() in a wrapper class to
warn you if you fail to close the stream, a reference to the stream stays
open until you undeploy the application, potentially causing memory leaks.
What is the expected output? What do you see instead?
N/A
What version of the product are you using? On what operating system?
Typica 1.52a
Please provide any additional information below.
Fixing the issue is fairly simple, define a variable to get the return
value of getResourceAsStream() and close the returned InputStream when you
are done with it. Example follows:
public AWSQueryConnection(String awsAccessId, String awsSecretKey,
boolean isSecure,
String server, int port) {
super(awsAccessId, awsSecretKey, isSecure, server, port);
String version = "?";
try {
Properties props = new Properties();
final InputStream versionPropertiesStream =
this.getClass().getClassLoader().getResourceAsStream("version.properties");
try {
props.load(versionPropertiesStream);
} finally {
versionPropertiesStream.close();
}
version = props.getProperty("version");
} catch (Exception ex) {
}
userAgent = userAgent + version + " (" +
System.getProperty("os.arch") + "; " + System.getProperty("os.name") + ")";
}
Original issue reported on code.google.com by mikula.j...@gmail.com on 6 Jul 2009 at 11:16
Original issue reported on code.google.com by
mikula.j...@gmail.com
on 6 Jul 2009 at 11:16