MINOR: improve Streams checkstyle and code cleanup#5954
Conversation
There was a problem hiding this comment.
This might be controversial. I change it, to reuse the return type of ApiUtils.validateMillisecondDuration. (Similar in other XxxWindows classes).
Thoughts?
|
Call for review @guozhangwang @bbejeck @vvcephei |
guozhangwang
left a comment
There was a problem hiding this comment.
Feel free to merge after addressed / replied the comments.
There was a problem hiding this comment.
Is this intentional? I'm concerned someone out there in the wild may have extended this class for their customized needs.
There was a problem hiding this comment.
There was a warning. Note that Stores has only static methods, thus it does not make sense to inherit from it. I can still revert it. Don't feel strong about it.
There was a problem hiding this comment.
Is this intentional? If they are retained as comments just for context information I'd suggest use /**/ as a nit comment.
There was a problem hiding this comment.
I'd prefer keep it as general so that the same function can be reused in the future potentially rather than explicitly restrict is usage scope.
There was a problem hiding this comment.
I think validateXXX method shouldn't return value.
That's why I made it void in the first place.
Maybe we need a more convenient name for it?
There was a problem hiding this comment.
That's why I made it void in the first place.
It's not void -- and this PR does not change it. I think it makes sense to let it return for this case though. To validate the given Duration, we need to call #toMillis() within validateMillisecondDuration() and thus, there is no reason to call it twice (even if this is not on the critical code path).
We can still rename it. Maybe something like, getMillisecondDurationOrFailIfInvalid ?
There was a problem hiding this comment.
Because we call deprecated method close(DEFAULT_CLOSE_TIMEOUT, TimeUnit.SECONDS); -- this method will stay though, ie, we will make it private when we "remove" it from public API and than we can remove this annotation, too.
There was a problem hiding this comment.
Again, why are we adding calls to deprecated code?
There was a problem hiding this comment.
We don't add calls -- this call was always there and we need to keep it for backward compatibility until we remove those methods (by making them private).
There was a problem hiding this comment.
It's a real shame that we have this inconsistency. And it only makes the code worse, this PR being a good example.
There was a problem hiding this comment.
I am happy to enable this check style for the whole code base (similar to final requirement). But not sure if we get some push back -- thus, it seems to be better to introduce those things step by step?
There was a problem hiding this comment.
I was suggesting the opposite. What's the justification for this rule? At least for final, there is the mutability argument. The truth is that Java is becoming a more modern language and redundant verbosity is being eliminated (an extreme example that has been proposed http://openjdk.java.net/jeps/8209434). Requiring braces in every situation perhaps made sense for the old Java. :)
There was a problem hiding this comment.
For me personally, it's readability question -- I think, it improves readability.
Also, this rule only required braces for if/else and loop-blocks. Not for every situation.
There was a problem hiding this comment.
Hmm, what other situation is there where braces are optional?
There was a problem hiding this comment.
bbejeck
left a comment
There was a problem hiding this comment.
Just one minor question, otherwise LGTM modulo other comments
There was a problem hiding this comment.
I don't have strong opinion -- might be nice to keep for documentation (ie, the benchmark describes those fields, but we just don't use them?) Thoughts?
There was a problem hiding this comment.
That makes sense. Maybe we could add a couple of words in the comment?
But it's not a big deal, so it could just stay as is.
There was a problem hiding this comment.
We translate old default of zero to Long.MAX_VALUE within deprecated close(final long timeout, final TimeUnit timeUnit) -- we can call private close() directly instead.
There was a problem hiding this comment.
Hmm, what other situation is there where braces are optional?
c397804 to
0040a8b
Compare
|
Rebased this. Also added some JavaDoc fixes. @ijuma Do you still have objections about the enforced use of braces in streams module? |
|
@mjsax I'm not going to block it, but this doesn't make sense to me. The Apache Kafka project is a single project and it should use the same code style across the board for a given programming language, in my opinion. Imagine if we had a different code style per module: clients, connect, streams, tools. Do you think that would work OK? Why is streams special? |
|
I think I'd agree with @ijuma 's concern that, it is not for arguing if which coding style should be preferred, but about maintaining the coding style consistency of modules under AK repo. Personally I also prefer unambiguous syntax and I see the merits of, for example, posing strict reviews on proper markups / javadocs on public APIs etc in practice, but enforcing checkstyle rules only for Streams may have potential side-effect to the integral community in long run (I've seen other projects leading to this direction that resulted in separated sub-projects). So I'd suggest we remove the checkstyle rule while merging this PR, and moving forward we would still encourage reviewers to use their own best judgement to determine if some places would be vulnerable to future bugs or really bad for readability that worth a nitpick comment. |
|
Removed checkstyle rule. Merged all other cleanups. Thanks for your comments and the discussion about it! Merged to |
Reviewers: Guozhang Wang <guozhang@confluent.io>, Nikolay Izhikov <nIzhikov@gmail.com>, Ismael Juma <ismael@confluent.io>, Bill Bejeck <bill@confluent.io>
While fixing the code to meet the new checkstyle rule, I updated all touched classed for Java8 and removed other warnings.