[ 
https://issues.apache.org/jira/browse/BEAM-7507?focusedWorklogId=263154&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-263154
 ]

ASF GitHub Bot logged work on BEAM-7507:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 19/Jun/19 16:49
            Start Date: 19/Jun/19 16:49
    Worklog Time Spent: 10m 
      Work Description: lukecwik commented on pull request #8888: [BEAM-7507] 
Avoid more String.format and ByteString.toStringUtf8
URL: https://github.com/apache/beam/pull/8888#discussion_r295401148
 
 

 ##########
 File path: 
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java
 ##########
 @@ -2023,17 +2023,22 @@ public void completeWork(ByteString key, long 
workToken) {
         Queue<Work> queue = activeWork.get(key);
         Preconditions.checkNotNull(queue);
         Work completedWork = queue.poll();
-        Preconditions.checkNotNull(
-            completedWork,
-            "No active state for key %s, expected token %s",
-            key.toStringUtf8(),
-            workToken);
-        Preconditions.checkState(
-            completedWork.getWorkItem().getWorkToken() == workToken,
-            "Token mismatch for key %s: %s and %s",
-            key.toStringUtf8(),
-            completedWork.getWorkItem().getWorkToken(),
-            workToken);
+        // avoid Preconditions.checkNotNull and checkState here to prevent 
eagerly evaluating the
+        // format string parameters for the error message.
+        if (completedWork == null) {
+          throw new NullPointerException(
+              String.format(
+                  "No active state for key %s, expected token %s",
+                  TextFormat.escapeBytes(key), workToken));
+        }
+        if (completedWork.getWorkItem().getWorkToken() != workToken) {
 
 Review comment:
   Ah, then your good, for some reason I thought it was a string.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 263154)
    Time Spent: 1h 10m  (was: 1h)

> StreamingDataflowWorker attempts to decode non-utf8 binary data as utf8
> -----------------------------------------------------------------------
>
>                 Key: BEAM-7507
>                 URL: https://issues.apache.org/jira/browse/BEAM-7507
>             Project: Beam
>          Issue Type: Improvement
>          Components: runner-dataflow
>            Reporter: Steve Niemitz
>            Assignee: Steve Niemitz
>            Priority: Trivial
>             Fix For: 2.14.0
>
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> In StreamingDataflowWorker, when setting the workId for the logging MDC, 
> currently the code attempts to decode a binary blob as utf8.  This will 
> (generally) cause a decoding error, and the java UTF8 decoder uses a globally 
> synchronized cache to handle generating these error results.
> A simple solution would be to use the protobuf TextFormat escaping to convert 
> the ByteString key into a string.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to