ctubbsii commented on code in PR #4764:
URL: https://github.com/apache/accumulo/pull/4764#discussion_r1692449651
##########
test/src/main/java/org/apache/accumulo/test/functional/IdleProcessMetricsIT.java:
##########
@@ -220,7 +221,7 @@ public void idleScanServerTest() throws Exception {
try (Scanner scanner = client.createScanner(table1,
Authorizations.EMPTY)) {
scanner.setConsistencyLevel(ScannerBase.ConsistencyLevel.EVENTUAL);
- scanner.stream().forEach(Function.identity()::apply); // iterate and
ignore
+ assertEquals(MAX_DATA, scanner.stream().count()); // Ensure that data
exists
Review Comment:
Thanks for fixing this. I modeled the previous code after commons-lang3's
`Consumers.NOP`, but I guess errorprone wasn't happy with this. I wonder if
errorprone would have been okay if I had just literally put `Consumers.NOP` in
there.
I'd really like it if there was a good universal solution to signal "trust
me, I really want to ignore this", but there doesn't seem to be. The previous
solution `var ignored = ` seems to make IntelliJ happy, but not Eclipse, and
adding `@SuppressWarnings("unused")` isn't always possible when additional
tooling says "you have an unnecessary warnings suppression here".
We almost always do this kind of thing in test code, but not in non-test
code, though, because we're trying to test for an error as a side-effect, and
really don't care about the returned value. It's always best, however, to do
something like what you did here, when we have something we can concretely test
the returned value against. But, that's not always the case. I have, in the
past, tested that some returned values were non-null. That wouldn't have worked
here, though, because the count is a primitive, so I attempted to just have it
consume and drop. For this one, I almost made it check that it was `> -1`,
which of course is impossible to fail for a stream count. So, I'm glad you
found something better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]