| Issue 203: | Memory leak in PropertiesPreferences | |
| 1 person starred this issue and may be notified of changes. | Back to list |
I found a memory leak using jmesa on Glassfish v2.1.
After generate a lot of tables along the day the system memory runs out.
The problem is at PropertiesPreferences.java, where the ImputStream is
never closed after the properties load.
Here is the fix:
Public final class PropertiesPreferences implements Preferences {
.
.
.
public PropertiesPreferences(String preferencesLocation, WebContext
webContext) {
try {
InputStream resourceAsStream = getInputStream(JMESA_PROPERTIES,
webContext);
properties.load(resourceAsStream);
resourceAsStream.close();
if (StringUtils.isNotBlank(preferencesLocation)) {
InputStream input = getInputStream(preferencesLocation,
webContext);
if (input != null) {
properties.load(input);
input.close();
}
}
} catch (IOException e) {
logger.error("Could not load the JMesa preferences.", e);
}
}
.
.
.
}
Jul 3, 2009
Project Member
#1
jeff.johnston.mn@gmail.com
Status:
Fixed
Jul 27, 2009
A little security patch: close the input streams in a finally block. Not closing the input streams in a finally block may result in resource leaks (and in editing the file being denied) if loading the preferences file fails.
Jul 28, 2009
Good catch! I will put this in.
Status:
Accepted
Jul 29, 2009
It is on the trunk!
Status:
Fixed
|