fjtirado commented on code in PR #3895:
URL: 
https://github.com/apache/incubator-kie-kogito-runtimes/pull/3895#discussion_r2046670470


##########
jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/ProtobufProcessInstanceWriter.java:
##########
@@ -143,11 +143,8 @@ public void 
writeProcessInstance(WorkflowProcessInstanceImpl workFlow, OutputStr
 
         HeadersPersistentConfig headersConfig = 
context.get(MARSHALLER_HEADERS_CONFIG);
         if (workFlow.getHeaders() != null && headersConfig != null && 
headersConfig.enabled()) {
-            Stream<Entry<String, List<String>>> stream = 
workFlow.getHeaders().entrySet().stream();
-            if (headersConfig.excluded() != null && 
!headersConfig.excluded().isEmpty()) {
-                stream = stream.filter(e -> 
!headersConfig.excluded().contains(e.getKey()));
-            }
-            instance.addAllHeaders(stream.map(e -> 
HeaderEntry.newBuilder().setKey(e.getKey()).addAllValue(e.getValue()).build()).collect(Collectors.toList()));
+            Stream<Entry<String, List<String>>> headersStream = 
getHeadersStream(workFlow, headersConfig);
+            instance.addAllHeaders(headersStream.map(e -> 
HeaderEntry.newBuilder().setKey(e.getKey()).addAllValue(e.getValue()).build()).collect(Collectors.toList()));

Review Comment:
   ```suggestion
   
           if (LOGGER.isDebugEnabled()) {
                   LOGGER.debug("Headers {} are associated to process instance 
{}", workFlow.getHeaders().keySet(), workFlow.getId());
               }
               Stream<Entry<String, List<String>>> stream = 
workFlow.getHeaders().entrySet().stream();
               if (headersConfig.excluded() != null && 
!headersConfig.excluded().isEmpty()) {
                   stream = stream.filter(e -> 
!headersConfig.excluded().contains(e.getKey()));
               }
               instance.addAllHeaders(stream.map(e -> 
HeaderEntry.newBuilder().setKey(e.getKey()).addAllValue(e.getValue()).build()).collect(Collectors.toList()));
               if (LOGGER.isDebugEnabled()) {
                   LOGGER.debug("Headers {} are stored for process instance 
{}", instance.getHeadersList().stream().map(h -> 
h.getKey()).collect(Collectors.joining()), workFlow.getId());
               }
               
   ```



##########
jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/ProtobufProcessInstanceWriter.java:
##########
@@ -164,6 +161,21 @@ public void 
writeProcessInstance(WorkflowProcessInstanceImpl workFlow, OutputStr
         }
     }
 
+    private Stream<Entry<String, List<String>>> 
getHeadersStream(WorkflowProcessInstanceImpl workFlow, HeadersPersistentConfig 
headersConfig) {
+        Stream<Entry<String, List<String>>> stream = 
workFlow.getHeaders().entrySet().stream();
+        if (headersConfig.excluded() != null && 
!headersConfig.excluded().isEmpty()) {
+            stream = stream.filter(e -> {
+                if (headersConfig.excluded().contains(e.getKey())) {
+                    LOGGER.info("Excluding header {} from process instance {} 
from persistence", e.getKey(), workFlow.getId());
+                    return false;
+                }
+                LOGGER.info("Adding header {} from process instance {} for 
persistence", e.getKey(), workFlow.getId());
+                return true;
+             });
+        }
+        return stream;
+    }

Review Comment:
   This should be deleted. 



##########
jbpm/process-serialization-protobuf/src/main/java/org/jbpm/flow/serialization/impl/ProtobufProcessInstanceReader.java:
##########
@@ -177,6 +177,9 @@ private RuleFlowProcessInstance 
buildWorkflow(KogitoProcessInstanceProtobuf.Proc
 
         if (processInstanceProtobuf.getHeadersList() != null) {
             
processInstance.setHeaders(processInstanceProtobuf.getHeadersList().stream().collect(Collectors.toMap(HeaderEntry::getKey,
 HeaderEntry::getValueList)));
+            processInstance.getHeaders().forEach((key, values) -> {
+                LOGGER.info("Header {} restored for process instance {}", key, 
processInstance.getId());
+            });

Review Comment:
   ```suggestion
                   LOGGER.debug("Headers {} restored for process instance {}", 
processInstance.getHeaders().keySet(), processInstance.getId()));
              }
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to