Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Replace explicit type arguments with diamond operator wherever possible across the project #17567

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Akshat-Jain
Copy link
Contributor

@Akshat-Jain Akshat-Jain commented Dec 13, 2024

Description

As pointed out in this review comment, since we aren't supporting Java 8 anymore, we can switch to diamond operators wherever possible without specifying explicit type arguments.

Examples:

// Example 1:
private ArrayList<InputRow> longRows = new ArrayList<InputRow>();
// The above can be replaced with the following:
private ArrayList<InputRow> longRows = new ArrayList<>();

// Example 2:
new TypeReference<List<DataSegmentChangeRequest>>()
      {
      };
// The above can be replaced with the following:
new TypeReference<>() {};

This PR makes this change across the project.

Note: This change was done with IntelliJ's project-wide inspection results for warnings like Explicit type argument Integer, Iterator<Integer> can be replaced with <> . With that, there were a few compilation issues, which were manually fixed.


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • a release note entry in the PR description.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added or updated version, license, or notice information in licenses.yaml
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • added integration tests.
  • been tested in a test Druid cluster.

@@ -247,7 +247,7 @@
@Override
protected OrderedSequenceNumber<String> makeSequenceNumber(String seq, boolean isExclusive)
{
return new OrderedSequenceNumber<String>(seq, isExclusive)
return new OrderedSequenceNumber<>(seq, isExclusive)

Check warning

Code scanning / CodeQL

Inconsistent compareTo Warning test

This class declares
compareTo
but inherits equals; the two could be inconsistent.
@@ -2908,7 +2908,7 @@
@Override
protected OrderedSequenceNumber<String> makeSequenceNumber(String seq, boolean isExclusive)
{
return new OrderedSequenceNumber<String>(seq, isExclusive)
return new OrderedSequenceNumber<>(seq, isExclusive)

Check warning

Code scanning / CodeQL

Inconsistent compareTo Warning test

This class declares
compareTo
but inherits equals; the two could be inconsistent.
log.warn("ScheduledExecutorService is ShutDown. Return 'Signal.STOP' and stopped rescheduling %s (delay %s)", this, delay);
log.warn(
"ScheduledExecutorService is ShutDown. Return 'Signal.STOP' and stopped rescheduling %s (delay %s)",
this,

Check notice

Code scanning / CodeQL

Use of default toString() Note

Default toString(): inherits toString() from Object, and so is not suitable for printing.
{
@Override
public Sequence<Integer> apply(final ImmutableList<Integer> input)
{
if (lastSeqFullyRead.getAndSet(false)) {
return Sequences.simple(
new Iterable<Integer>()
new Iterable<>()

Check warning

Code scanning / CodeQL

Iterable wrapping an iterator Warning test

This class implements Iterable, but does not appear to support multiple iterations, since its iterator method always returns an iterator based on the same
iterator
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant