#151 InputStream not closed 3x

v2.5.1
closed-fixed
Node (41)
5
2011-07-22
2011-07-10
No

Affected methods:
JPPFConfiguration:loadProperties()
TypedProperties::getProperties(String key, TypedProperties def)
VersionUtils::getBuildNumber()

Problem is mainly on windows where you can't edit config files when JPPF is running.
---------------------------------
JPPFConfiguration::loadProperties()
private static void loadProperties()
{
props = new TypedProperties();
InputStream is = null;
try
{
is = getStream();
if (is != null) props.load(is);
}
catch(Exception e)
{
log.error("error reading the configuration", e);
} finally {
if(is != null) is.close();
}
}

---------------------------------
TypedProperties::getProperties(String key, TypedProperties def)
...
TypedProperties res = new TypedProperties();
InputStream is = null;
try
{
is = new BufferedInputStream(new FileInputStream(file));
res.load(is);
}
catch(IOException e)
{
return def;
} finally {
if(is != null) is.close();
}
return res;

---------------------------------
VersionUtils::getBuildNumber()
public static int getBuildNumber()
{
if (buildNumber < 0)
{
InputStream is = null;
try
{
is = VersionUtils.class.getClassLoader().getResourceAsStream("build.number");
TypedProperties props = new TypedProperties();
props.load(is);
buildNumber = props.getInt("build.number");
}
catch(Exception ignored)
{
buildNumber = 0;
} finally {
if(is != null) is.close();
}
}
return buildNumber;
}

Discussion

  • Laurent Cohen

    Laurent Cohen - 2011-07-21
    • assigned_to: nobody --> lolocohen
     
  • Laurent Cohen

    Laurent Cohen - 2011-07-22

    This is now fixed. Changes committed to SVN:
    trunk: revision 1736
    branch b2.5: revision 1737

     
  • Laurent Cohen

    Laurent Cohen - 2011-07-22
    • milestone: --> v2.5.1
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks