Close streams in tests
This commit ensures that file streams are properly closed in tests. This seems to cause issues on Windows as the OS cannot delete temp folders. This is similar to spring-io/initializr#862 See gh-23507
This commit is contained in:
@@ -244,18 +244,19 @@ class CandidateComponentsIndexerTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CandidateComponentsMetadata readGeneratedMetadata(File outputLocation) {
|
private CandidateComponentsMetadata readGeneratedMetadata(File outputLocation) {
|
||||||
try {
|
|
||||||
File metadataFile = new File(outputLocation, MetadataStore.METADATA_PATH);
|
File metadataFile = new File(outputLocation, MetadataStore.METADATA_PATH);
|
||||||
if (metadataFile.isFile()) {
|
if (metadataFile.isFile()) {
|
||||||
return PropertiesMarshaller.read(new FileInputStream(metadataFile));
|
try (FileInputStream fileInputStream = new FileInputStream(metadataFile)) {
|
||||||
}
|
CandidateComponentsMetadata metadata = PropertiesMarshaller.read(fileInputStream);
|
||||||
else {
|
return metadata;
|
||||||
return new CandidateComponentsMetadata();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new IllegalStateException("Failed to read metadata from disk", ex);
|
throw new IllegalStateException("Failed to read metadata from disk", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return new CandidateComponentsMetadata();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user