diff --git a/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java b/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java index 67f0fe78eb..b77be37bca 100644 --- a/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java +++ b/byte-buddy-dep/src/main/java/net/bytebuddy/build/Plugin.java @@ -3398,7 +3398,7 @@ protected enum NoFolderMatcher implements ElementMatcher { * {@inheritDoc} */ public boolean matches(@MaybeNull Element target) { - return target == null || target.getName().endsWith("/"); + return target == null || !target.getName().endsWith("/"); } } } diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/build/PluginEngineSourceFilteringTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/build/PluginEngineSourceFilteringTest.java index c6aa6b2f59..ba75a960c8 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/build/PluginEngineSourceFilteringTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/build/PluginEngineSourceFilteringTest.java @@ -95,7 +95,7 @@ public void testMultiReleaseFilter() throws Exception { when(second.getName()).thenReturn(ClassFileLocator.META_INF_VERSIONS + "17/foo/Bar.class"); when(third.getName()).thenReturn(ClassFileLocator.META_INF_VERSIONS + "11/foo/Bar.class"); - Plugin.Engine.Source.Origin origin = Plugin.Engine.Source.Filtering.dropMultiReleaseClassFilesAbove(this.source, ClassFileVersion.JAVA_V11).read(); + Plugin.Engine.Source.Origin origin = Plugin.Engine.Source.Filtering.dropMultiReleaseClassFilesAbove(source, ClassFileVersion.JAVA_V11).read(); Iterator iterator = origin.iterator(); assertThat(iterator.hasNext(), is(true)); assertThat(iterator.next(), is(first)); @@ -103,4 +103,22 @@ public void testMultiReleaseFilter() throws Exception { assertThat(iterator.next(), is(third)); assertThat(iterator.hasNext(), is(false)); } + + @Test + public void testFolderFilter() throws Exception { + when(source.read()).thenReturn(origin); + when(origin.iterator()).thenReturn(Arrays.asList(first, second, third).iterator()); + + when(first.getName()).thenReturn("foo/"); + when(second.getName()).thenReturn("foo/Bar.class"); + when(third.getName()).thenReturn("foo/Qux.class"); + + Plugin.Engine.Source.Origin origin = Plugin.Engine.Source.Filtering.dropFolders(source).read(); + Iterator iterator = origin.iterator(); + assertThat(iterator.hasNext(), is(true)); + assertThat(iterator.next(), is(second)); + assertThat(iterator.hasNext(), is(true)); + assertThat(iterator.next(), is(third)); + assertThat(iterator.hasNext(), is(false)); + } }