Skip to content

docs(stub): align setOnReadyHandler javadoc with isReady semantics - #13193

Open
wangkangmao wants to merge 1 commit into
grpc:masterfrom
wangkangmao:fix-callstreamobserver-onready-javadoc
Open

wangkangmao wants to merge 1 commit into
grpc:masterfrom
wangkangmao:fix-callstreamobserver-onready-javadoc

Conversation

@wangkangmao

Copy link
Copy Markdown

Fixes #6552.

Problem

CallStreamObserver.setOnReadyHandler()'s @param said the handler is called "when peer is ready to receive more messages". That wording conflicts with CallStreamObserver.isReady() and with ClientCall.isReady() / ServerCall.isReady(), which define readiness as the observer being able to accept more messages without excessive buffering internally. Readiness can therefore also come from spare local buffering capacity, not only from the peer requesting data.

This is the exact inconsistency a maintainer identified in the review of PR #6561 (which fixed the class-level Javadoc but left this @param open): "the explanation in isReady() is correct, the ... statement in the setOnReadyHandler() is incorrect."

Change

One file, Javadoc only, no behaviour change:

  • stub/src/main/java/io/grpc/stub/CallStreamObserver.java
    • Add a paragraph to setOnReadyHandler() stating that readiness follows isReady() semantics and that the callback does not distinguish peer-requested capacity from local spare buffering.
    • Rewrite the @param onReadyHandler description to "called when the observer becomes ready to accept more messages without excessive buffering", matching isReady().

Verification

Only the changed module was compiled (plus its required grpc-api dependency):

$ JAVA_HOME=/c/Users/12404/.jdks/jbr-21.0.11 \
  ANDROID_HOME=C:/Users/12404/AppData/Local/Android/Sdk \
  ./gradlew :grpc-stub:compileJava -PskipAndroid=true --console=plain
> Task :grpc-api:compileJava
> Task :grpc-stub:compileJava
BUILD SUCCESSFUL in 41s

Javadoc generation for the same module, to validate the new tags and links:

$ JAVA_HOME=/c/Users/12404/.jdks/jbr-21.0.11 \
  ANDROID_HOME=C:/Users/12404/AppData/Local/Android/Sdk \
  ./gradlew :grpc-stub:javadoc -PskipAndroid=true --console=plain
> Task :grpc-stub:javadoc
BUILD SUCCESSFUL in 7s

git diff --check produced no output. No open PR currently references #6552; PR #6561 was merged in 2020 and only addressed the class-level comment.

Note

Build dependencies were resolved through a Maven mirror because repo.maven.apache.org returned HTTP 403 in the build environment. The mirror configuration was local-only and is not part of this commit; the commit contains only the Javadoc change.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

@shivaspeaks

Copy link
Copy Markdown
Member

Sign the EasyCLA if you want us the review.

* <em>another</em> {@code onReadyHandler} callback.
*
* @param onReadyHandler to call when peer is ready to receive more messages.
* <p>Readiness here has the same meaning as for {@link #isReady}: the observer can accept more

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This whole paragraph is good rationale for your PR. It would make sense in the commit description but not so much here as a permanent addition to the javadoc. Readiness is already fully explained above, in the isReady() API contract and the javadoc for this class. Better to leave this API's contract defined in terms of the return value of the isReady() method.

How about just saying:

@param onReadyHandler to call when this observer's isReady() transitions from false to true 

?

This branch has not been deployed

No deployments
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.

Clarify the Javadoc for CallStreamObserver

3 participants