inputstream close
@@ -57,18 +57,19 @@ public class ChannelConnections {
}
public InputStream getInputStream(String filePath) throws IOException {
- // if starts with "classpath:"
- if(filePath.startsWith("classpath:")){
+ if (filePath.startsWith("classpath:") || filePath.startsWith("file:")) {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Resource caResource = resolver.getResource(filePath);
- return caResource.getInputStream();
+ try (InputStream inputStream = caResource.getInputStream()) {
+ return inputStream;
}
- else{
+ } else {
File file = new File(filePath);
- InputStream inputStream = new FileInputStream(file);
+ try (InputStream inputStream = new FileInputStream(file)) {
return inputStream;
}
}
+ }
public String getClientKeystorePath() {
return clientKeystorePath;
