diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/nio/file/NestedFileSystemProviderTests.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/nio/file/NestedFileSystemProviderTests.java index 2a52f5e436d..6a7ebe6a9d3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/nio/file/NestedFileSystemProviderTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/nio/file/NestedFileSystemProviderTests.java @@ -137,8 +137,9 @@ class NestedFileSystemProviderTests { void newByteChannelReturnsByteChannel() throws Exception { URI uri = new URI(this.uriPrefix + "nested.jar"); Path path = this.provider.getPath(uri); - SeekableByteChannel byteChannel = this.provider.newByteChannel(path, Set.of(StandardOpenOption.READ)); - assertThat(byteChannel).isInstanceOf(NestedByteChannel.class); + try (SeekableByteChannel byteChannel = this.provider.newByteChannel(path, Set.of(StandardOpenOption.READ))) { + assertThat(byteChannel).isInstanceOf(NestedByteChannel.class); + } } @Test