Skip to content

Commit

Permalink
Close InputStream when done parsing configuration (https://issues.red…
Browse files Browse the repository at this point in the history
  • Loading branch information
belaban committed Oct 2, 2023
1 parent 6360009 commit 2003b6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/org/jgroups/JChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ public JChannel(String props) throws Exception {

/**
* Creates a channel with a configuration based on an input stream.
* @param input An input stream, pointing to a streamed configuration
* @param input An input stream, pointing to a streamed configuration. It is the caller's resposibility to close
* the input stream after the constructor returns
*/
public JChannel(InputStream input) throws Exception {
this(ConfiguratorFactory.getStackConfigurator(input));
Expand Down
14 changes: 7 additions & 7 deletions src/org/jgroups/conf/ConfiguratorFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ public static InputStream getConfigStream(Object properties) throws IOException
*/
static XmlConfigurator getXmlConfigurator(String properties) throws IOException {
XmlConfigurator returnValue=null;
InputStream configStream=getConfigStream(properties);
if(configStream == null && properties.endsWith("xml"))
throw new FileNotFoundException(String.format(Util.getMessage("FileNotFound"), properties));
try(InputStream configStream=getConfigStream(properties)) {
if(configStream == null && properties.endsWith("xml"))
throw new FileNotFoundException(String.format(Util.getMessage("FileNotFound"), properties));

if (configStream != null) {
checkJAXPAvailability();
returnValue=XmlConfigurator.getInstance(configStream);
if(configStream != null) {
checkJAXPAvailability();
returnValue=XmlConfigurator.getInstance(configStream);
}
}

return returnValue;
}

Expand Down

0 comments on commit 2003b6f

Please sign in to comment.