chore: add @Blocking and @NonBlocking annotations#1192
Conversation
WalkthroughThe changes add JetBrains Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/src/main/java/io/ably/lib/rest/Auth.java (1)
1019-1024:⚠️ Potential issue | 🟠 Major
@NonBlockingonrenew()is incorrect — the method blocks on HTTP I/O.
renew()synchronously callsassertValidToken(...)(line 1021), which internally callsrequestToken(...)— a method you've annotated@Blockingbecause it performs HTTP requests. This makesrenew()a blocking method.The same issue applies to
renewAuth()on line 1034–1038: it also synchronously callsassertValidToken(...)before dispatching the async part.Both should be
@Blocking.Proposed fix
`@Deprecated` - `@NonBlocking` + `@Blocking` public TokenDetails renew() throws AblyException {- `@NonBlocking` + `@Blocking` public void renewAuth(RenewAuthResult result) throws AblyException {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/src/main/java/io/ably/lib/rest/Auth.java` around lines 1019 - 1024, The `@NonBlocking` annotation on renew() (and likewise on renewAuth()) is incorrect because renew() calls assertValidToken(...), which invokes requestToken(...) and performs HTTP I/O; change the annotation to `@Blocking` for renew() and renewAuth() so their declared blocking behavior matches the synchronous HTTP calls — update the annotations on the methods renew() and renewAuth() (and any related javadoc/comments) to `@Blocking` and ensure no `@NonBlocking` remains on those methods that call assertValidToken(...) / requestToken(...).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@lib/src/main/java/io/ably/lib/rest/Auth.java`:
- Around line 1019-1024: The `@NonBlocking` annotation on renew() (and likewise on
renewAuth()) is incorrect because renew() calls assertValidToken(...), which
invokes requestToken(...) and performs HTTP I/O; change the annotation to
`@Blocking` for renew() and renewAuth() so their declared blocking behavior
matches the synchronous HTTP calls — update the annotations on the methods
renew() and renewAuth() (and any related javadoc/comments) to `@Blocking` and
ensure no `@NonBlocking` remains on those methods that call assertValidToken(...)
/ requestToken(...).
Added
@Blockingand@NonBlockingannotations for better documentationSummary by CodeRabbit