-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Description
Several files across the codebase import classes from third-party libraries' internal, shaded, or relocated packages. These imports are fragile and can break when the upstream dependency changes its shading/relocation strategy. They should be replaced with standard Java APIs or proper public dependency APIs.
This was originally spotted in PR fabric8io#7426 (io.sundr.deps.org.apache.commons.lang.RandomStringUtils used in tests), but a broader search revealed additional instances.
Affected Files
1. Sundrio shaded Apache Commons (io.sundr.deps.*)
File: kubernetes-model-generator/kubernetes-model-core/src/test/java/io/fabric8/kubernetes/api/model/HasMetadataTest.java
import io.sundr.deps.org.apache.commons.lang.RandomStringUtils;- Usage: Generating random strings for test data
- Replacement: Use
java.util.UUID.randomUUID().toString()orjava.util.concurrent.ThreadLocalRandomfor random test values
2. Sundrio internal API (io.sundr.builder.internal.*)
File: crd-generator/api/src/main/java/io/fabric8/crd/generator/AbstractJsonSchema.java
import io.sundr.builder.internal.functions.TypeAs;- Usage: Unwrapping collection/map/optional types (
TypeAs.UNWRAP_ARRAY_OF,TypeAs.UNWRAP_COLLECTION_OF,TypeAs.UNWRAP_MAP_KEY_OF,TypeAs.UNWRAP_MAP_VALUE_OF,TypeAs.UNWRAP_OPTIONAL_OF) - Replacement: Check if Sundrio exposes equivalent functionality in its public API (
io.sundr.modelorio.sundr.model.functions). If not, consider creating local wrapper utilities or requesting public API from Sundrio maintainers. This is the highest priority item since it's in production code (CRD generator).
File: java-generator/core/src/test/java/io/fabric8/java/generator/CompilationTest.java
import io.sundr.builder.internal.processor.BuildableProcessor;- Usage: Configuring annotation processor for compilation test (
javac().withProcessors(new BuildableProcessor())) - Replacement: Use Sundrio's documented/public testing support, or check if the processor can be discovered via standard
ServiceLoader/META-INF/servicesmechanism
3. Pax Exam internal API (org.ops4j.pax.exam.*.internal.*)
File: platforms/karaf/itests/src/test/java/io/fabric8/kubernetes/karaf/itests/TestBase.java
import org.ops4j.pax.exam.karaf.container.internal.JavaVersionUtil;- Usage:
JavaVersionUtil.getMajorVersion() >= 9to check Java version - Replacement: Use
Runtime.version().major()(Java 9+) or parseSystem.getProperty("java.version")
Out of Scope
The following internal package usages are the project's own internal packages (not third-party shaded classes). They represent a separate API design concern (encapsulation within the project) and are not covered by this issue:
io.fabric8.mockwebserver.internal.*— used across ~14 files injunit/kubernetes-server-mock,kubernetes-client-apitests, andkubernetes-testsio.fabric8.zjsonpatch.internal.collections4.ListUtils— used within thezjsonpatchmodule itself
Checklist
- Replace
RandomStringUtilsinHasMetadataTest.java - Replace or wrap
TypeAsinAbstractJsonSchema.java - Replace
BuildableProcessorinCompilationTest.java - Replace
JavaVersionUtilinTestBase.java - Verify no regressions (run affected module tests)