Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
java adoptopenjdk-17.0.5+8
java adoptopenjdk-21.0.2+13.0.LTS
maven 3.9.9
trivy 0.54.1
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<!-- 3.0.0-M5 drags its own legacy Maven 3.0 stack (maven-artifact-transfer:0.11.0,
maven-plugin-api:3.0, …) into the surefire fork classpath, producing
non-deterministic ordering under Java 21 and intermittent
ClassNotFoundException on MavenModelMerger / ModelCacheFactory.
Not aligned on @maven-surefire-plugin.version@ (3.5.3) yet because that
release surfaces an unrelated ECJ "Unresolved compilation problems" error
on this IT — to investigate separately. -->
<version>3.2.5</version>
<executions>
<execution>
<id>integration-test</id>
Expand Down
6 changes: 0 additions & 6 deletions component-runtime-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@
<version>${log4j2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>3.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
import org.talend.sdk.component.runtime.record.SchemaImpl.BuilderImpl;
import org.talend.sdk.component.runtime.record.SchemaImpl.EntryImpl;

import nl.jqno.equalsverifier.EqualsVerifier;
import nl.jqno.equalsverifier.Warning;

class SchemaImplTest {

private final Schema.Entry data1 = new SchemaImpl.EntryImpl.BuilderImpl() //
Expand Down Expand Up @@ -85,13 +82,42 @@
final RecordBuilderFactory f = new RecordBuilderFactoryImpl("test");
final Entry first = f.newEntryBuilder().withName("First").withType(Type.STRING).build();
final Entry second = f.newEntryBuilder().withName("Second").withType(Type.STRING).build();
EqualsVerifier.simple()
.suppress(Warning.STRICT_HASHCODE) // Supress test hashcode use all fields used by equals (for legacy)
.forClass(SchemaImpl.class)
.withPrefabValues(Schema.Entry.class, first, second)
.withIgnoredFields("entriesOrder", "entryMap")
.withPrefabValues(EntriesOrder.class, EntriesOrder.of("First"), EntriesOrder.of("Second"))
.verify();

// Create two identical schemas
final Schema schema1 = new BuilderImpl()
.withType(Type.RECORD)
.withEntry(first)
.withEntry(second)
.build();

final Schema schema2 = new BuilderImpl()
.withType(Type.RECORD)
.withEntry(first)
.withEntry(second)
.build();

// Create a different schema
final Schema schema3 = new BuilderImpl()
.withType(Type.RECORD)
.withEntry(first)
.build();

// Test equals reflexivity
assertEquals(schema1, schema1);

// Test equals symmetry
assertEquals(schema1, schema2);
assertEquals(schema2, schema1);

// Test equals with different object
Assertions.assertNotEquals(schema1, schema3);
Assertions.assertNotEquals(schema3, schema1);

// Test hashCode consistency
assertEquals(schema1.hashCode(), schema2.hashCode());

// Test null
Assertions.assertNotEquals(schema1, null);

Check warning on line 120 in component-runtime-impl/src/test/java/org/talend/sdk/component/runtime/record/SchemaImplTest.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-impl/src/test/java/org/talend/sdk/component/runtime/record/SchemaImplTest.java#L120

Swap these 2 arguments so they are in the correct order: expected value, actual value.
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import static org.apache.xbean.asm9.Opcodes.RETURN;
import static org.apache.xbean.asm9.Opcodes.SIPUSH;
import static org.apache.xbean.asm9.Opcodes.V1_8;
import static org.apache.xbean.asm9.Opcodes.V21;

import java.io.InputStream;
import java.io.ObjectStreamException;
Expand Down Expand Up @@ -108,12 +109,38 @@ public ProxyGenerator() {
}

private int determineDefaultJavaVersion() {
final String javaVersionProp = System.getProperty("java.version", "1.8");
if (javaVersionProp.startsWith("1.8")) { // we don't support earlier
final String javaVersionProp = System.getProperty("java.version", "21");
// Legacy "1.x" naming (Java 8 and below)
if (javaVersionProp.startsWith("1.")) {
// anything older than 1.8 is unsupported; bump to the minimum
return V1_8;
}
// add java 9 test when upgrading asm
return V1_8; // return higher one
// Modern naming: "9", "10", ..., "17", "21", possibly followed by "." or "-"
final int sep = indexOfNonDigit(javaVersionProp);
final String majorStr = sep < 0 ? javaVersionProp : javaVersionProp.substring(0, sep);
final int major;
try {
major = Integer.parseInt(majorStr);
} catch (final NumberFormatException e) {
return V21; // safe fallback aligned with the project baseline (Java 21)
}
if (major <= 8) {
return V1_8;
}
// ASM Vxx opcodes are sequential: V1_8 = 52, V9 = 53, ... so Vmajor = 44 + major.
// Cap at V21 to stay within the project's compilation baseline and avoid
// emitting class files newer than the runtime we have validated.
final int capped = Math.min(major, 21);
return 44 + capped;
}

private static int indexOfNonDigit(final String s) {
for (int i = 0; i < s.length(); i++) {
if (!Character.isDigit(s.charAt(i))) {
return i;
}
}
return -1;
}

private void createSerialisation(final ClassWriter cw, final String pluginId, final String key) {
Expand Down
13 changes: 13 additions & 0 deletions component-runtime-testing/component-runtime-http-junit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<properties>
<netty.version>4.1.135.Final</netty.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<talend.build.name>${talend.build.name.base}.junit.http</talend.build.name>
</properties>

Expand Down Expand Up @@ -117,6 +118,18 @@
<version>${ziplock.version}</version>
<scope>test</scope>
</dependency>
<!--
Bouncy Castle is required by io.netty.handler.ssl.util.SelfSignedCertificate on JDK 17+
because the legacy OpenJdkSelfSignedCertGenerator relies on sun.security.x509 internals
that have been encapsulated/moved. Without BC on the classpath the HTTPS tests fail
with "No provider succeeded to generate a self-signed certificate".
-->
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
}), false, exception);
}

private File buildSparkHome(final Version version) {

Check failure on line 220 in component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java#L220

Refactor this method to reduce its Cognitive Complexity from 40 to the 15 allowed.
final File sparkHome = new File(getRoot(), "spark/");
Stream.of(version.libFolder(), "conf").map(n -> new File(sparkHome, n)).forEach(File::mkdirs);

Expand All @@ -243,6 +243,44 @@
}
});

// Align jackson-core with jackson-databind that Spark depends on.
// Maven dependency mediation lets avro:1.11.x (a nearer transitive) downgrade
// jackson-core to 2.14.3 while spark itself drags jackson-databind 2.15.x,
// producing NoClassDefFoundError: com/fasterxml/jackson/core/StreamReadConstraints
// at driver boot. Resolve jackson-core explicitly at the version chosen for
// jackson-databind so the right jar lands in sparkHome/jars/.
try {
final File databindJar = Stream
.of(libFolder.listFiles((d, name) -> name.startsWith("jackson-databind-")))
.filter(java.util.Objects::nonNull)
.flatMap(Stream::of)
.findFirst()
.orElse(null);
if (databindJar != null) {
final String dbName = databindJar.getName();
// jackson-databind-<version>.jar
final String dbVersion =
dbName.substring("jackson-databind-".length(), dbName.length() - ".jar".length());
final String coreCoord = "com.fasterxml.jackson.core:jackson-core:" + dbVersion;
LOGGER.info("Aligning jackson-core on " + dbVersion + " to match jackson-databind...");

Check warning on line 265 in component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java#L265

Format specifiers should be used instead of string concatenation.

Check warning on line 265 in component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java#L265

Use the built-in formatting to construct this argument.
final File coreFile = resolver.resolve(coreCoord).withoutTransitivity().asSingleFile();
Files
.copy(coreFile.toPath(), new File(libFolder, coreFile.getName()).toPath(),
StandardCopyOption.REPLACE_EXISTING);
// Drop any older jackson-core jars that may shadow the aligned one in spark/jars/*
final File[] olderCores = libFolder.listFiles((d, name) -> name.startsWith("jackson-core-")
&& !name.equals(coreFile.getName()));
if (olderCores != null) {
for (final File f : olderCores) {
LOGGER.info("Removing mismatched jackson-core: " + f.getName());

Check warning on line 275 in component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java#L275

Format specifiers should be used instead of string concatenation.
f.delete();

Check warning on line 276 in component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java#L276

Use "java.nio.file.Files#delete" here for better messages on error conditions.

Check notice on line 276 in component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-runtime-testing/component-runtime-testing-spark/src/main/java/org/talend/sdk/component/runtime/testing/spark/internal/BaseSpark.java#L276

Do something with the "boolean" value returned by "delete".
}
}
}
} catch (final Exception e) {
LOGGER.warn("Could not align jackson-core with jackson-databind: " + e.getMessage(), e);
}

// Add logging dependencies separately to ensure they are included
Stream
.of("org.apache.logging.log4j:log4j-slf4j-impl:" + log4j2Version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
import java.util.concurrent.ConcurrentMap;
import java.util.stream.Stream;

import org.jspecify.annotations.NonNull;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import lombok.NonNull;

public class MapCacheTest {

@ParameterizedTest
Expand Down
30 changes: 29 additions & 1 deletion container/nested-maven-repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<properties>
<talend.build.name>${talend.build.name.base}.container.maven</talend.build.name>
<maven-dependency-tree.version>3.1.0</maven-dependency-tree.version>
<maven-dependency-tree.version>3.3.0</maven-dependency-tree.version>
<maven-artifact-transfer.version>0.13.1</maven-artifact-transfer.version>
</properties>

Expand Down Expand Up @@ -82,6 +82,34 @@
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-artifact-transfer</artifactId>
<version>${maven-artifact-transfer.version}</version>
<exclusions>
<!-- maven-artifact-transfer is retired and drags an ancient maven-core:3.0 chain
(with maven-aether-provider:3.0 + sonatype plexus-sec-dispatcher:1.3 + old aether).
Those leak into consumers' runtime classpath and break shrinkwrap-resolver / mima
at IT runtime (split-package on org.apache.maven.repository.internal.*
hiding ModelCacheFactory; ctor mismatch on DefaultSecDispatcher). We only use
org.apache.maven.shared.transfer.artifact.resolve.* which doesn't need any of these. -->
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-aether-provider</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-sec-dispatcher</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-cipher</artifactId>
</exclusion>
<exclusion>
<groupId>org.sonatype.aether</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Loading
Loading