Skip to content

Commit

Permalink
fix JENKINS-48102: CMake plugin leaks file handle on CMakeCache.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
15knots committed Nov 26, 2017
1 parent 9ab29db commit 859b362
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/hudson/plugins/cmake/BuildToolEntryParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015 Martin Weber.
* Copyright (c) 2015-2017 Martin Weber.
*
* Contributors:
* Martin Weber - Initial implementation
Expand Down Expand Up @@ -44,17 +44,19 @@ public String invoke(File cmakeCacheFile, VirtualChannel channel)
InputStreamReader isr = new InputStreamReader(
new BufferedInputStream(new FileInputStream(cmakeCacheFile)),
Charset.defaultCharset());
List<SimpleCMakeCacheEntry> result = new ArrayList<SimpleCMakeCacheEntry>(
1);
List<SimpleCMakeCacheEntry> result = new ArrayList<>(1);
final CMakeCacheFileParser parser = new CMakeCacheFileParser();
try {
parser.parse(isr, new EntryFilter() {

parser.parse(isr, new EntryFilter() {

@Override
public boolean accept(String key) {
return "CMAKE_MAKE_PROGRAM".equals(key);
}
}, result, null);
@Override
public boolean accept(String key) {
return "CMAKE_MAKE_PROGRAM".equals(key);
}
}, result, null);
} finally {
isr.close();
}
if (result.size() > 0) {
return result.get(0).getValue();
}
Expand Down

0 comments on commit 859b362

Please sign in to comment.