rajatdt / typica

Automatically exported from code.google.com/p/typica
Apache License 2.0
0 stars 0 forks source link

AWSQueryConnection causes problem in Sun Glassfish #55

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
Thanks for this. Fixed in SVN r280

Original comment by dkavan...@gmail.com on 16 Aug 2009 at 2:10