diff --git a/spring-core/src/main/java/org/springframework/core/io/ModuleResource.java b/spring-core/src/main/java/org/springframework/core/io/ModuleResource.java index 2953a995c548..6835abb1a880 100644 --- a/spring-core/src/main/java/org/springframework/core/io/ModuleResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/ModuleResource.java @@ -92,6 +92,12 @@ public Resource createRelative(String relativePath) { return new ModuleResource(this.module, pathToUse); } + @Override + @Nullable + public String getFilename() { + return StringUtils.getFilename(this.path); + } + @Override public String getDescription() { return "module resource [" + this.path + "]" + diff --git a/spring-core/src/test/java/org/springframework/core/io/ModuleResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ModuleResourceTests.java index 150af1f1c223..acb15276fe1d 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ModuleResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ModuleResourceTests.java @@ -40,6 +40,7 @@ void existingResource() throws IOException { assertThat(mr.isReadable()).isTrue(); assertThat(mr.isOpen()).isFalse(); assertThat(mr.isFile()).isFalse(); + assertThat(mr.getFilename()).isEqualTo("Introspector.class"); assertThat(mr.getDescription()).contains(mr.getModule().getName()); assertThat(mr.getDescription()).contains(mr.getPath()); @@ -55,6 +56,7 @@ void nonExistingResource() { assertThat(mr.isReadable()).isFalse(); assertThat(mr.isOpen()).isFalse(); assertThat(mr.isFile()).isFalse(); + assertThat(mr.getFilename()).isEqualTo("Introspecter.class"); assertThat(mr.getDescription()).contains(mr.getModule().getName()); assertThat(mr.getDescription()).contains(mr.getPath());