Skip to content

fix(java-sdk): Add Java timeout overload#927

Closed
Gujiassh wants to merge 1 commit into
alibaba:mainfrom
Gujiassh:fix/java-run-command-timeout-interop-20260521
Closed

fix(java-sdk): Add Java timeout overload#927
Gujiassh wants to merge 1 commit into
alibaba:mainfrom
Gujiassh:fix/java-run-command-timeout-interop-20260521

Conversation

@Gujiassh
Copy link
Copy Markdown
Contributor

Summary

  • Add a java.time.Duration overload for RunCommandRequest.Builder.timeout(...)
  • Convert the Java duration to Kotlin duration in milliseconds before building the request
  • Add a focused regression test for the Java-friendly overload

Fixes #849.

Verification

  • ./gradlew :sandbox:test --tests com.alibaba.opensandbox.sandbox.domain.models.execd.executions.RunCommandRequestTest
  • git diff --check

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bd3a4b47dc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

/**
* Java-friendly timeout overload using java.time.Duration.
*/
fun timeout(timeout: java.time.Duration?): Builder {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make java Duration overload non-nullable

Declaring the new overload as timeout(timeout: java.time.Duration?) introduces an overload-resolution regression for Kotlin callers that previously used builder.timeout(null) to explicitly clear timeout: null now matches both Duration? and java.time.Duration?, so the call becomes ambiguous at compile time. This is a source-compatibility break introduced by this change; making the Java overload non-nullable (or giving it a distinct JVM/Kotlin name) preserves Java ergonomics without breaking existing Kotlin call sites.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown
Contributor

⚠️ This PR has no labels. Please add one based on the changes.

Changed directories: sdks.

📋 Recommended labels (based on changed files):

  • sdks ⬅️

Other available labels:

  • bug - Something isn't working
  • dependencies - Pull requests that update a dependency file
  • documentation - Improvements or additions to documentation
  • feature - New feature or request
  • packages - Changes for package, image and configuration

💡 Tip: Use feature for new functionality or improvements, bug for fixes.

cc @Gujiassh

@ninan-nn
Copy link
Copy Markdown
Collaborator

Thanks for the contribution and for clearly identifying the Java interop issue caused by Kotlin value-class name mangling.

Considering the same problem also affects RunInSessionRequest and the timeout getter surface, we went with a slightly broader fix in #928: use java.time.Duration as the primary public timeout type, while keeping deprecated kotlin.time.Duration overloads for Kotlin callers to migrate gradually.

So #928 should cover this PR's intent plus the related API surfaces from #849. Appreciate the patch and the regression-test direction here.

@ninan-nn ninan-nn closed this May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Cannot call RunCommandRequest.Builder#timeout(Duration) from Java code due to Kotlin name mangling

2 participants