kennknowles commented on code in PR #40022:
URL: https://github.com/apache/beam/pull/40022#discussion_r3990476141


##########
sdks/java/core/src/test/java/org/apache/beam/sdk/transforms/LatestFnTest.java:
##########
@@ -100,14 +100,14 @@ public void testAddInputSameTimestamp() {
 
   @Test
   public void testAddInputNullAccumulator() {
-    thrown.expect(NullPointerException.class);
+    thrown.expect(IllegalArgumentException.class);
     thrown.expectMessage("accumulator");
     fn.addInput(null, TV);
   }
 
   @Test
   public void testAddInputNullInput() {
-    thrown.expect(NullPointerException.class);
+    thrown.expect(IllegalArgumentException.class);

Review Comment:
   It is intended: it will throw `IllegalArgumentException` which is accurate. 
NPE is too generic and doesn't say _who_ did the wrong thing. It also reads 
like "segfault" to a user, indicating a bug always, but sometimes it is not a 
bug but is because of how it was passed.
   
   Basically checkNotNull should almost never be used, and NPE should be thrown 
_only_ when you actually dereference a null, aka when you wrote bad code.



-- 
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]

Reply via email to