Skip to content

KAFKA-7612: Fix javac warnings and enable warnings as errors#5900

Merged
ijuma merged 34 commits intoapache:trunkfrom
ijuma:kafka-7612-fix-javac-warnings
Nov 13, 2018
Merged

KAFKA-7612: Fix javac warnings and enable warnings as errors#5900
ijuma merged 34 commits intoapache:trunkfrom
ijuma:kafka-7612-fix-javac-warnings

Conversation

@ijuma
Copy link
Copy Markdown
Member

@ijuma ijuma commented Nov 11, 2018

  • Use Xlint:all with 3 exclusions (filed KAFKA-7613 to remove the exclusions)
  • Use the same javac options when compiling tests (seems accidental that
    we didn't do this before)
  • Replaced several deprecated method calls with non-deprecated ones:
    • KafkaConsumer.poll(long) and KafkaConsumer.close(long)
    • Class.newInstance and new Integer/Long (deprecated since Java 9)
    • scala.Console (deprecated in Scala 2.11)
    • PartitionData taking a timestamp (one of them seemingly a bug)
    • JsonMappingException single parameter constructor
  • Fix unnecessary usage of raw types in several places.
  • Add @SuppressWarnings for deprecations, unchecked and switch fallthrough in
    several places.
  • Scala clean-ups (var -> val, ETA expansion warnings, avoid reflective calls)
  • Use lambdas to simplify code in a few places
  • Add @SafeVarargs, fix varargs usage and remove unnecessary Utils.mkList method

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@ijuma ijuma changed the title KAFKA-7612: Fix javac warnings and enable warnings as errors KAFKA-7612: Fix javac warnings and enable warnings as errors [WIP] Nov 11, 2018
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@rhauch Can you please review the Connect changes that start from this point?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mjsax @guozhangwang Can you please review the Streams changes that start from this point.

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.

\cc @bbejeck Can you have a look here? You know the optimizer code best.

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.

@ijuma I looked into this in more detail. We don't need a new type R -- instead, we should update to

public class KTableKTableJoinNode<K, V1, V2, VR> extends BaseJoinProcessorNode<K, Change<V1>, Change<V2>, Change<VR>>

and use private final MaterializedInternal<K, VR, KeyValueStore<Bytes, byte[]>> materializedInternal; (ie, VR instead of R. (Note, the you always pass <..., Change<X>, X> in the current PR, what is redundant and can be avoided.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mjsax That doesn't work, it's what I tried first. As far as I can tell, the existing code was wrong but it doesn't matter due to the way generics are used here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Synced offline, I had misunderstood the suggestion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mjsax Good suggestion, I've added a commit. Let me know what you think.

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 to the optimizer code LGTM

Copy link
Copy Markdown
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

As far as I can tell, LGTM.

Not sure about the Scala change and why we need to additional generic type though.

@ijuma ijuma force-pushed the kafka-7612-fix-javac-warnings branch 2 times, most recently from a8e6887 to be7b014 Compare November 12, 2018 02:29
@ijuma ijuma force-pushed the kafka-7612-fix-javac-warnings branch from 870081c to 797ec97 Compare November 12, 2018 08:30
@ijuma ijuma changed the title KAFKA-7612: Fix javac warnings and enable warnings as errors [WIP] KAFKA-7612: Fix javac warnings and enable warnings as errors Nov 12, 2018
@ijuma
Copy link
Copy Markdown
Member Author

ijuma commented Nov 12, 2018

@omkreddy Do you have time to review this?

Copy link
Copy Markdown
Contributor

@omkreddy omkreddy left a comment

Choose a reason for hiding this comment

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

core and clients module changes are looks good to me.

@ijuma
Copy link
Copy Markdown
Member Author

ijuma commented Nov 12, 2018

JDK 11 build passed and JDK 8 failures are unrelated. @mjsax, can you please take a look at the Connect changes? They're pretty trivial and that would give us enough committer coverage to get this merged before it goes stale. :)

private val uncleanablePartitions = mutable.HashMap[String, mutable.Set[TopicPartition]]()

/* the set of directories marked as uncleanable and therefore offline */
private val uncleanableDirs = mutable.HashSet[String]()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks good. thanks

// Visible for testing
private[server] def getFetcher(topicPartition: TopicPartition): Option[T] = {
lock synchronized {
val fetcherId = getFetcherId(topicPartition)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@rhauch rhauch left a comment

Choose a reason for hiding this comment

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

Connect changes look good to me, tho I'm not a committer.

@ijuma ijuma force-pushed the kafka-7612-fix-javac-warnings branch from 7aa0320 to 7d2c25b Compare November 12, 2018 21:38
@ijuma
Copy link
Copy Markdown
Member Author

ijuma commented Nov 13, 2018

Only testCoordinatorFailover failed and it's unrelated (there's a separate PR to fix that). I'll go ahead and merge this. If there are any additional comments, I'll follow-up in a subsequent PR.

@ijuma ijuma merged commit 12f310d into apache:trunk Nov 13, 2018
@ijuma ijuma deleted the kafka-7612-fix-javac-warnings branch November 13, 2018 06:19
Copy link
Copy Markdown
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

Made a pass over streams part. LGTM except one question (above).

I've also made a minor PR for replacing some deprecated functions, maybe better merging this one and rebase:

#5911

return viewByRegion;
})
.map((user, viewRegion) -> new KeyValue<>(viewRegion.region, viewRegion))
.groupByKey(Serialized.with(Serdes.String(), new JSONSerde<>()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can replace Serialized with Grouped, ditto below.

cc @bbejeck

@Deprecated
public <KR> KGroupedStream<KR, V> groupBy(final KeyValueMapper<? super K, ? super V, KR> selector,
final Serialized<KR, V> serialized) {
final org.apache.kafka.streams.kstream.Serialized<KR, V> serialized) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm.

* Too much specific information to generalize so the KTable-KTable join requires a specific node.
*/
public class KTableKTableJoinNode<K, V1, V2, VR> extends BaseJoinProcessorNode<K, V1, V2, VR> {
public class KTableKTableJoinNode<K, V1, V2, VR> extends BaseJoinProcessorNode<K, Change<V1>, Change<V2>, Change<VR>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the purpose of moving Change<V> inside this class instead of on the callers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That was @mjsax suggestion to avoid adding an additional type parameter for Materialized. See the last commit in the PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ack.

.groupBy(
mapper,
Serialized.with(Serdes.String(), Serdes.String()));
org.apache.kafka.streams.kstream.Serialized.with(Serdes.String(), Serdes.String()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto here and below: use Grouped instead of Serialized.

.groupBy(
mapper,
Serialized.with(Serdes.String(), Serdes.String()));
org.apache.kafka.streams.kstream.Serialized.with(Serdes.String(), Serdes.String()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ditto here and below.

import static org.junit.Assert.fail;


@SuppressWarnings("deprecation")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should replace until with grace here, cc @vvcephei

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

@SuppressWarnings("deprecation")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We should replace of with the other overloaded function. cc @vvcephei

@ijuma
Copy link
Copy Markdown
Member Author

ijuma commented Nov 14, 2018

@guozhangwang Thanks for the review. I responded to the question about the type parameters. All the comments about removing deprecated usage with the undeprecated alternative seem to be addressed in your follow-up PR so we can just discuss it there. This one was already merged

@guozhangwang
Copy link
Copy Markdown
Contributor

Yeah I guess it was merged while I was preparing the PR, and I did not notice it after rebasing trunk :) Sounds good.

pengxiaolong pushed a commit to pengxiaolong/kafka that referenced this pull request Jun 14, 2019
…5900)

- Use Xlint:all with 3 exclusions (filed KAFKA-7613 to remove the exclusions)
- Use the same javac options when compiling tests (seems accidental that
we didn't do this before)
- Replaced several deprecated method calls with non-deprecated ones:
  - `KafkaConsumer.poll(long)` and `KafkaConsumer.close(long)`
  - `Class.newInstance` and `new Integer/Long` (deprecated since Java 9)
  - `scala.Console` (deprecated in Scala 2.11)
  - `PartitionData` taking a timestamp (one of them seemingly a bug)
  - `JsonMappingException` single parameter constructor
- Fix unnecessary usage of raw types in several places.
- Add @SuppressWarnings for deprecations, unchecked and switch fallthrough in
several places.
- Scala clean-ups (var -> val, ETA expansion warnings, avoid reflective calls)
- Use lambdas to simplify code in a few places
- Add @SafeVarargs, fix varargs usage and remove unnecessary `Utils.mkList` method

Reviewers: Matthias J. Sax <mjsax@apache.org>, Manikumar Reddy <manikumar.reddy@gmail.com>, Randall Hauch <rhauch@gmail.com>, Bill Bejeck <bill@confluent.io>, Stanislav Kozlovski <stanislav_kozlovski@outlook.com>
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.

7 participants