sjvanrossum commented on code in PR #32060:
URL: https://github.com/apache/beam/pull/32060#discussion_r1838044572


##########
sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/write/UnboundedSolaceWriter.java:
##########
@@ -165,16 +173,27 @@ public void publishResults(BeamContextWrapper context) {
           maxFailed = Math.max(maxFailed, latency);
         }
       }
-
       if (result.getPublished()) {
         context.output(
-            SUCCESSFUL_PUBLISH_TAG, result, getCurrentBundleTimestamp(), 
getCurrentBundleWindow());
+            SUCCESSFUL_PUBLISH_TAG, result, getCurrentBundleTimestamp(), 
GlobalWindow.INSTANCE);
       } else {
-        context.output(
-            FAILED_PUBLISH_TAG, result, getCurrentBundleTimestamp(), 
getCurrentBundleWindow());
+        try {
+          BadRecord b =
+              BadRecord.fromExceptionInformation(
+                  result,
+                  null,
+                  null,
+                  result.getError() != null
+                      ? checkNotNull(result.getError())
+                      : "SolaceIO.Write: unknown error.");

Review Comment:
   Create a new variable, assign it `result.getError()` and then perform this 
null check against the variable instead. The reason why error prone keeps 
complaining about it is because the two calls to `getError` may return two 
different results, storing the return value is what you want here. The other 
thing you could do is 
`Optional.ofNullable(result.getError()).orElse("SolaceIO.Write: unknown 
error.")`.



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