mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
Close file stream
This commit is contained in:
@@ -11,6 +11,7 @@ import javax.inject.Inject;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class JAXBPropertyFileAccess implements PropertyFileAccess {
|
public class JAXBPropertyFileAccess implements PropertyFileAccess {
|
||||||
|
|
||||||
@@ -43,14 +44,16 @@ public class JAXBPropertyFileAccess implements PropertyFileAccess {
|
|||||||
public void forStoreFiles(FileConsumer storeFileConsumer) throws IOException {
|
public void forStoreFiles(FileConsumer storeFileConsumer) throws IOException {
|
||||||
Path v1storeDir = computeV1StoreDir();
|
Path v1storeDir = computeV1StoreDir();
|
||||||
if (Files.exists(v1storeDir) && Files.isDirectory(v1storeDir)) {
|
if (Files.exists(v1storeDir) && Files.isDirectory(v1storeDir)) {
|
||||||
Files.list(v1storeDir).filter(p -> p.toString().endsWith(XML_FILENAME_SUFFIX)).forEach(p -> {
|
try (Stream<Path> fileStream = Files.list(v1storeDir)) {
|
||||||
try {
|
fileStream.filter(p -> p.toString().endsWith(XML_FILENAME_SUFFIX)).forEach(p -> {
|
||||||
String storeName = extractStoreName(p);
|
try {
|
||||||
storeFileConsumer.accept(p, storeName);
|
String storeName = extractStoreName(p);
|
||||||
} catch (IOException e) {
|
storeFileConsumer.accept(p, storeName);
|
||||||
throw new RuntimeException("could not call consumer for store file " + p + " with name " + storeName, e);
|
} catch (IOException e) {
|
||||||
}
|
throw new RuntimeException("could not call consumer for store file " + p + " with name " + storeName, e);
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user