Skip to content

Fix generic type inference in ServerSideApply example - #4909

Open
sarveshkaushal wants to merge 1 commit into
kubernetes-client:masterfrom
sarveshkaushal:sarveshkaushal/build-failure
Open

sarveshkaushal wants to merge 1 commit into
kubernetes-client:masterfrom
sarveshkaushal:sarveshkaushal/build-failure

Conversation

@sarveshkaushal

Copy link
Copy Markdown
Contributor

Summary

Fix the ServerSideApply example by explicitly specifying the resource and list generic types. This prevents Java from inferring their upper-bound types and resolves compilation errors for V1ConfigMap class.

Testing

Ran mvn install after the fix and it worked fine on Java 11 and Java 25.

Failure

This was the failure when running mvn install on the project root:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.16.0:compile (default-compile) on project client-java-examples-release-latest: Compilation failure: Compilation failure:
[ERROR] /Users/sarveshkaushal/git/java/examples/examples-release-latest/src/main/java/io/kubernetes/client/examples/ServerSideApplyExample.java:[69,38] incompatible types: java.lang.Class<io.kubernetes.client.openapi.models.V1ConfigMap> cannot be converted to java.lang.Class<io.kubernetes.client.common.KubernetesObject>
[ERROR] /Users/sarveshkaushal/git/java/examples/examples-release-latest/src/main/java/io/kubernetes/client/examples/ServerSideApplyExample.java:[81,38] incompatible types: java.lang.Class<io.kubernetes.client.openapi.models.V1ConfigMap> cannot be converted to java.lang.Class<io.kubernetes.client.common.KubernetesObject>

@kubernetes-prow kubernetes-prow Bot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 16, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sarveshkaushal
Once this PR has been reviewed and has the lgtm label, please assign yue9944882 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sarveshkaushal

Copy link
Copy Markdown
Contributor Author

/assign @yue9944882

@brendandburns

Copy link
Copy Markdown
Contributor

I'm not opposed to this PR, but I believe that we build these examples in our CI/CD and CI/CD is passing. Can you take a look and see if we do in fact build the examples, and then also figure out if there is a difference between your environment and our build environment?

@sarveshkaushal

sarveshkaushal commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Looks like examples module is not included in the CI/CD build logic. That's why it is not failing in the CI/CD pipeline. See this here.

- name: Build
shell: bash
run: >-
bazel build --config=ci
//kubernetes:client-java-api
//proto:client-java-proto
//util:client-java
//fluent:client-java-api-fluent
//extended:client-java-extended

When we build locally with maven, it includes all the projects from the root regardless of the Bazel configurations.

Another related questions - do we want to include the example module in the CI/CD building process? I can ship a follow-up to allow that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants