Skip to content

Conversation

@sjhajharia
Copy link
Collaborator

@sjhajharia sjhajharia commented Jul 11, 2025

Now that Kafka support Java 17, this PR makes some changes in connect
module. The changes in this PR are limited to only some files. A future
PR(s) shall follow.

The changes mostly include:

  • Collections.emptyList(), Collections.singletonList() and Arrays.asList() are replaced with List.of()
  • Collections.emptyMap() and Collections.singletonMap() are replaced with Map.of()
  • Collections.singleton() is replaced with Set.of()

Modules target: runtime/src/test

Reviewers: Ken Huang s7133700@gmail.com, Chia-Ping Tsai chia7712@gmail.com

@github-actions github-actions bot added triage PRs from the community connect tests Test fixes (including flaky tests) labels Jul 11, 2025
Copy link
Collaborator

@m1a2st m1a2st left a comment

Choose a reason for hiding this comment

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

Thank @sjhajharia for this patch, left one comment

@github-actions github-actions bot removed the triage PRs from the community label Jul 15, 2025
@sjhajharia
Copy link
Collaborator Author

Thanks @m1a2st for the comment. I have addressed the same at all locations where it is possible. Requesting a re-review.

@sjhajharia sjhajharia requested a review from m1a2st July 16, 2025 16:44
@sjhajharia
Copy link
Collaborator Author

Adding @chia7712 to the PR as he kindly helped review a bunch of PRs in this area.
TIA!

@sjhajharia
Copy link
Collaborator Author

Gentle reminder @chia7712 @m1a2st
TIA

@sjhajharia
Copy link
Collaborator Author

Thanks @chia7712 for the initial reviews. I have addressed the same.
Re-requesting a review.

@sjhajharia sjhajharia requested a review from chia7712 August 11, 2025 05:08
public List<Map<String, String>> taskConfigs(int maxTasks) {
block.maybeBlockOn(CONNECTOR_TASK_CONFIGS);
return Collections.singletonList(Collections.emptyMap());
return List.of(Map.of());
Copy link
Member

Choose a reason for hiding this comment

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

Could you please update line#790 also?

        @Override
        public List<Map<String, String>> taskConfigs(int maxTasks) {
            return IntStream.range(0, maxTasks)
                .mapToObj(i -> new HashMap<>(props))
                .collect(Collectors.toList());
        }

Copy link
Collaborator Author

@sjhajharia sjhajharia Aug 12, 2025

Choose a reason for hiding this comment

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

Are you referencing to get rid of .collect(Collectors.toList()) in favour of .toList()? if so, then that is not possible here as we are using HashMap while the return type needs to be Map.

public void shouldValidateAllVerificationAlgorithms() {
List<String> algorithms =
new ArrayList<>(Arrays.asList("HmacSHA1", "HmacSHA256", "HmacMD5", "bad-algorithm"));
new ArrayList<>(List.of("HmacSHA1", "HmacSHA256", "HmacMD5", "bad-algorithm"));
Copy link
Member

Choose a reason for hiding this comment

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

Could we make algorithms immutable in this test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have updated the same with a different approach. Pls review if that makes sense.

@sjhajharia sjhajharia requested a review from chia7712 August 12, 2025 05:46
@chia7712
Copy link
Member

@sjhajharia could you please take a look at the failed tests?

@sjhajharia
Copy link
Collaborator Author

Thanks @chia7712
I fixed the failing test

Copy link
Member

@chia7712 chia7712 left a comment

Choose a reason for hiding this comment

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

@sjhajharia thanks for fixing the failure. I have one last comment.


when(configStore.snapshot()).thenReturn(SNAPSHOT);
assertEquals(Collections.singleton(CONN1), new HashSet<>(herder.connectors()));
assertEquals(Set.of(CONN1), new HashSet<>(herder.connectors()));
Copy link
Member

Choose a reason for hiding this comment

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

assertEquals(Set.of(CONN1), Set.copyOf(herder.connectors()));

WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Makes sense. Fixed it.

@chia7712 chia7712 merged commit 8dec45f into apache:trunk Aug 19, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved connect tests Test fixes (including flaky tests)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants