MINOR: Improve usage of LogCaptureAppender#8508
Conversation
422aae9 to
ccab82c
Compare
There was a problem hiding this comment.
This is an actual change -- in all other processor, we use the "top level class" for the logger and not the Processor class -- changing this for alignment.
There was a problem hiding this comment.
Removed because the parameter is variadic
There was a problem hiding this comment.
This method is only called once and thus its merged into the main test method
There was a problem hiding this comment.
We don't capture any debug logs and thus it's getting removed
There was a problem hiding this comment.
This method is only called once and thus its merged into the main test method
|
Did you consider using try with resources? |
vvcephei
left a comment
There was a problem hiding this comment.
Thanks, @mjsax ! This is awesome. I'm wondering if we can formalize the pattern you've adopted by implementing AutoCloseable in LogCaptureAppender, and making the close method unregister the appender, so we can convert all those try/finally blocks to try-with-resources? Of course, we'd have to move the assertions inside the block, which we have sometimes and not other times, but it doesn't seem like a big deal either way.
There was a problem hiding this comment.
Seems like this appender could also be scoped to the class that logs the message we want to capture, right?
There was a problem hiding this comment.
Unfortunately not; I tied it and it fails. The issue is, we would want to register the LogCaptureAppender only for KafkaStreams.class but at this point in the test, the corresponding logger does not exist yet: it's only created in the constructor call, that we actually test. Does this make sense?
vvcephei
left a comment
There was a problem hiding this comment.
Thanks, @mjsax ! It seems like we should look into the try-with-resources thing, unless you already rejected that option for some reason. I also registered one complaint below.
But I don't want to block on either one, if you really prefer the current code.
Other than those two issues, it's a really nice cleanup. Thanks!
There was a problem hiding this comment.
Not a huge fan of this particular "clean up". We're trading a tightly defined scope for de-duplicating the trivial line results.add(deserialization). It doesn't seem like a good trade to me.
There was a problem hiding this comment.
I don't feel "strong" about it -- it was an IntelliJ warning/suggestion to "share common code".
|
I did not consider using try-with-resource. Great idea! |
8a9d0aa to
81d042b
Compare
|
Updated this. Call for review. |
b594d46 to
4b65333
Compare
| // When executing on Jenkins, the thread name is set to an unknown value, | ||
| // hence, we need to set it explicitly to make our log-assertions pass | ||
| Thread.currentThread().setName(threadName); |
There was a problem hiding this comment.
Hmm, this might be surprising. Won't this cause the test executor thread to be called "threadName" from now until the end of the build?
Do you think we could instead get the currentThread's name and use that in the assertions? Or otherwise make the assertions agnostic to the name of the thread?
There was a problem hiding this comment.
Getting the name is much better! Should have done this for the beginning on...
|
Java 8 passed. Retest this please. |
|
Updated this PR. Will merge after Jenkins passe. |
|
Java 8: Retest this please. |
|
Java 8 and Java 11 passed. |
I started a "small" cleanup, and it ended up to become a "big" cleanup...
LogCaptureAppenderto the class under test (if possible)Call for review @vvcephei