Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion paimon-filesystems/paimon-azure-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@
<fileset dir="${project.build.directory}/temporary">
<include name="*"/>
</fileset>
<patternset>
<!-- exclude the jar's own META-INF, otherwise multi-release
metadata gets nested under META-INF/versions/11 and tools
like JaCoCo fail on duplicate class names -->
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
Expand Down Expand Up @@ -177,7 +183,6 @@
<exclude>mime.types</exclude>
<exclude>mozilla/**</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/versions/11/META-INF/maven/**</exclude>
<exclude>META-INF/LICENSE.txt</exclude>
</excludes>
</filter>
Expand Down
7 changes: 6 additions & 1 deletion paimon-filesystems/paimon-cosn-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@
<fileset dir="${project.build.directory}/temporary">
<include name="*"/>
</fileset>
<patternset>
<!-- exclude the jar's own META-INF, otherwise multi-release
metadata gets nested under META-INF/versions/11 and tools
like JaCoCo fail on duplicate class names -->
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
Expand Down Expand Up @@ -187,7 +193,6 @@
<exclude>mime.types</exclude>
<exclude>mozilla/**</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/versions/11/META-INF/maven/**</exclude>
<exclude>META-INF/LICENSE.txt</exclude>
</excludes>
</filter>
Expand Down
7 changes: 6 additions & 1 deletion paimon-filesystems/paimon-gs-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@
<fileset dir="${project.build.directory}/temporary">
<include name="*"/>
</fileset>
<patternset>
<!-- exclude the jar's own META-INF, otherwise multi-release
metadata gets nested under META-INF/versions/11 and tools
like JaCoCo fail on duplicate class names -->
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
Expand Down Expand Up @@ -303,7 +309,6 @@
<exclude>mime.types</exclude>
<exclude>mozilla/**</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/versions/11/META-INF/maven/**</exclude>
<exclude>META-INF/LICENSE.txt</exclude>
</excludes>
</filter>
Expand Down
7 changes: 6 additions & 1 deletion paimon-filesystems/paimon-oss-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@
<fileset dir="${project.build.directory}/temporary">
<include name="*"/>
</fileset>
<patternset>
<!-- exclude the jar's own META-INF, otherwise multi-release
metadata gets nested under META-INF/versions/11 and tools
like JaCoCo fail on duplicate class names -->
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
Expand Down Expand Up @@ -194,7 +200,6 @@
<exclude>mime.types</exclude>
<exclude>mozilla/**</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/versions/11/META-INF/maven/**</exclude>
<exclude>META-INF/LICENSE.txt</exclude>
</excludes>
</filter>
Expand Down
7 changes: 6 additions & 1 deletion paimon-filesystems/paimon-s3-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@
<fileset dir="${project.build.directory}/temporary">
<include name="*"/>
</fileset>
<patternset>
<!-- exclude the jar's own META-INF, otherwise multi-release
metadata gets nested under META-INF/versions/11 and tools
like JaCoCo fail on duplicate class names -->
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
Expand Down Expand Up @@ -291,7 +297,6 @@
<exclude>mime.types</exclude>
<exclude>mozilla/**</exclude>
<exclude>META-INF/maven/**</exclude>
<exclude>META-INF/versions/11/META-INF/maven/**</exclude>
<exclude>META-INF/LICENSE.txt</exclude>
</excludes>
</filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ static int checkJar(Path file) throws Exception {
getNumLicenseFilesOutsideMetaInfDirectory(file, fileSystem.getPath("/"));

numSevereIssues += getFilesWithIncompatibleLicenses(file, fileSystem.getPath("/"));

numSevereIssues += getNumNestedMetaInfDirectories(file, fileSystem.getPath("/"));
}
return numSevereIssues;
}
Expand Down Expand Up @@ -215,7 +217,6 @@ private static int findNonBinaryFilesContainingText(
path ->
!pathStartsWith(
path, "/META-INF/maven/javax.xml.bind/jaxb-api"))
.filter(path -> !isJavaxManifest(jar, path))
// dual-licensed under GPL 2 and EPL 2.0
// contained in sql-avro-confluent-registry
.filter(path -> !pathStartsWith(path, "/org/glassfish/jersey/internal"))
Expand Down Expand Up @@ -306,6 +307,27 @@ private static int getNumLicenseFilesOutsideMetaInfDirectory(Path jar, Path jarR
}
}

private static int getNumNestedMetaInfDirectories(Path jar, Path jarRoot) throws IOException {
// a nested META-INF below META-INF/versions indicates that another jar was
// unpacked/shaded as-is into the multi-release directory; the nested multi-release
// metadata is not resolvable at runtime and breaks tools scanning the unpacked
// classes (e.g., JaCoCo fails on duplicate class names)
final Pattern nestedMetaInf = Pattern.compile("^/?META-INF/versions/[^/]+/META-INF/?$");
try (Stream<Path> files = Files.walk(jarRoot)) {
final List<String> filesWithIssues =
files.map(Path::toString)
.filter(path -> nestedMetaInf.matcher(path).matches())
.collect(Collectors.toList());
for (String fileWithIssue : filesWithIssues) {
LOG.error(
"Jar file {} contains a nested META-INF directory in a multi-release directory: {}",
jar,
fileWithIssue);
}
return filesWithIssues.size();
}
}

private static String getFileName(Path path) {
return path.getFileName().toString().toLowerCase();
}
Expand All @@ -314,26 +336,10 @@ private static boolean pathStartsWith(Path file, String path) {
return file.startsWith(file.getFileSystem().getPath(path));
}

private static boolean equals(Path file, String path) {
return file.equals(file.getFileSystem().getPath(path));
}

private static boolean isNoClassFile(Path file) {
return !getFileName(file).endsWith(".class");
}

private static boolean isJavaxManifest(Path jar, Path potentialManifestFile) {
try {
return equals(potentialManifestFile, "/META-INF/versions/11/META-INF/MANIFEST.MF")
&& readFile(potentialManifestFile).contains("Specification-Title: jaxb-api");
} catch (IOException e) {
throw new RuntimeException(
String.format(
"Error while reading file %s from jar %s.", potentialManifestFile, jar),
e);
}
}

private static String readFile(Path file) throws IOException {
return new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,47 @@ void testIgnoreDualLicensedJavaxFiles(@TempDir Path tempDir) throws Exception {
.isEqualTo(0);
}

@Test
void testRejectedOnNestedMetaInfInMultiReleaseDirectory(@TempDir Path tempDir)
throws Exception {
assertThat(
JarFileChecker.checkJar(
createJar(
tempDir,
Entry.fileEntry(VALID_NOTICE_CONTENTS, VALID_NOTICE_PATH),
Entry.fileEntry(VALID_LICENSE_CONTENTS, VALID_LICENSE_PATH),
Entry.fileEntry(
"Manifest-Version: 1.0",
Arrays.asList(
"META-INF",
"versions",
"11",
"META-INF",
"MANIFEST.MF")))))
.isEqualTo(1);
}

@Test
void testAcceptedOnRegularMultiReleaseContent(@TempDir Path tempDir) throws Exception {
assertThat(
JarFileChecker.checkJar(
createJar(
tempDir,
Entry.fileEntry(VALID_NOTICE_CONTENTS, VALID_NOTICE_PATH),
Entry.fileEntry(VALID_LICENSE_CONTENTS, VALID_LICENSE_PATH),
Entry.fileEntry(
"some java 11 resource",
Arrays.asList(
"META-INF",
"versions",
"11",
"javax",
"xml",
"bind",
"Messages.properties")))))
.isEqualTo(0);
}

private static class Entry {
final String contents;
final List<String> path;
Expand Down
Loading