Skip to content

Fix unchecked call warnings in SourceTest.java (#2625)#2632

Closed
AyushMhaisane wants to merge 7 commits intoapache:mainfrom
AyushMhaisane:fix/2625-unchecked-warnings
Closed

Fix unchecked call warnings in SourceTest.java (#2625)#2632
AyushMhaisane wants to merge 7 commits intoapache:mainfrom
AyushMhaisane:fix/2625-unchecked-warnings

Conversation

@AyushMhaisane
Copy link
Copy Markdown

This PR fixes compiler warnings related to "unchecked call to expectNext(I)" in SourceTest.java.

The issue was caused by TestSink.create(system) returning a raw type when not explicitly typed. This change adds the necessary type witnesses (e.g., , ) to the TestSink.create calls to ensure type safety and eliminate the warnings.

Changes

Updated SourceTest.java to use explicit types in TestSink.create (e.g., TestSink.<Integer>create(system)).

Updated Source creation where necessary to match the Sink types (e.g., Source.<String>fromArray(...)).

Related Issue Fixes #2625

Verification

Ran Test/compile in stream-tests module: Success (Warnings related to SourceTest.java are gone).

Ran testOnly org.apache.pekko.stream.javadsl.SourceTest: All tests passed.

Checklist:

[x] The commit message follows the [contribution guidelines](https://github.com/apache/pekko/blob/main/CONTRIBUTING.md).

[x] Tests have been run and passed.

[x] No logic changes, only type safety improvements.

Comment thread stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java Outdated
Comment thread stream-tests/src/test/java/org/apache/pekko/stream/javadsl/SourceTest.java Outdated
@pjfanning
Copy link
Copy Markdown
Member

there are now no changes in the PR - everything including the code fixes have been removed

@pjfanning
Copy link
Copy Markdown
Member

Now all the unnecessary format changes are back.

import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
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.

the changes look good now but the import changes seem unnecessary

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks @pjfanning. I have removed the unnecessary java.util.function.Function import and updated the commit. The diff should be cleaner now.

@AyushMhaisane AyushMhaisane force-pushed the fix/2625-unchecked-warnings branch from 0f771a1 to 9a556ad Compare January 19, 2026 13:02
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import javax.xml.transform.Source;
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 is wrong too

@He-Pin
Copy link
Copy Markdown
Member

He-Pin commented Jan 19, 2026

@AyushMhaisane Thanks, the original problem is a type inference problem, so the fix should add some type parameter to the expectNext method in the testkit.

@AyushMhaisane AyushMhaisane force-pushed the fix/2625-unchecked-warnings branch from 9a556ad to ec0630a Compare January 19, 2026 13:39
@pjfanning
Copy link
Copy Markdown
Member

This doesn't compile and doesn't fix the compile warnings anyway.
This original issue is only a slight irritant so it might not be worth spending more time on it.

@He-Pin
Copy link
Copy Markdown
Member

He-Pin commented Feb 11, 2026

Thanks, I think we should close this PR, which is not what the issue is. thanks @AyushMhaisane for the effects

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.

compiler warning using Java Testkit DSL when who have 2 expectNext calls

3 participants