He-Pin opened a new pull request, #2725:
URL: https://github.com/apache/pekko/pull/2725

   ## Motivation
   
   Java compiler produces "unchecked call" warnings when using 
`TestSink.create(system)` and `TestSource.create(system)` in Java test code. 
The root cause is that Java cannot infer the type parameter `T` from the 
`system` parameter alone, causing the returned `Probe<T>` to be treated as a 
raw type. All chained method calls (`.request()`, `.expectNext()`, etc.) then 
trigger warnings like:
   
   ```
   unchecked call to expectNext(I) as a member of the raw type
   org.apache.pekko.stream.testkit.TestSubscriber.ManualProbe
   ```
   
   Closes #2625
   
   ## Modification
   
   ### API Additions
   - Added `create[T](clazz: Class[T], system: ClassicActorSystemProvider)` 
overloads to both `TestSink` and `TestSource` in the Java DSL. These accept a 
`Class<T>` parameter as a type witness, enabling Java's type inference to 
resolve `T` without explicit type parameters at the call site.
   - Fixed ScalaDoc links from `TestSubscriber`/`TestPublisher` to 
`TestSubscriber.Probe`/`TestPublisher.Probe`.
   
   ### Call-Site Fixes (11 files, ~70 instances)
   - Added explicit type witnesses at all raw `TestSink.create(system)` and 
`TestSource.create(system)` call sites:
     - `stream-tests/`: FlowTest (23), SourceTest (23), SinkTest (2), 
RetryFlowTest (4)
     - `docs/`: StreamTestKitDocTest (1), RecipeHold (4), RecipeManualTrigger 
(4), RecipeAdhocSourceTest (5), RecipeGlobalRateLimit (1), RecipeMissedTicks 
(2), RecipeSimpleDrop (1)
   - Retained `@SuppressWarnings("unchecked")` only where needed for unrelated 
varargs generic array creation warnings.
   
   ## Result
   
   - All "unchecked call" warnings from TestSink/TestSource usage are 
eliminated.
   - New `Class<T>` overloads provide a cleaner API for Java users going 
forward.
   - Binary compatibility preserved — existing `create(system)` methods remain 
unchanged.
   - All 3163 stream tests pass locally.
   
   ## References
   
   - Issue: https://github.com/apache/pekko/issues/2625
   - Related (closed): https://github.com/apache/pekko/pull/2632


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to