Skip to content

Commit 801d9b4

Browse files
authored
Bug Fix for null pointer exception in case header getFields is null in workflow context replay (#891)
* Fix for null pointer exception
1 parent d9a7750 commit 801d9b4

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/java/com/uber/cadence/internal/replay/WorkflowContext.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,16 @@ Map<String, Object> getPropagatedContexts() {
156156
return new HashMap<>();
157157
}
158158

159+
Map<String, ByteBuffer> fields = headers.getFields();
160+
if (fields == null) {
161+
return new HashMap<>();
162+
}
163+
159164
Map<String, byte[]> headerData = new HashMap<>();
160-
headers
161-
.getFields()
162-
.forEach(
163-
(k, v) -> {
164-
headerData.put(k, org.apache.thrift.TBaseHelper.byteBufferToByteArray(v));
165-
});
165+
fields.forEach(
166+
(k, v) -> {
167+
headerData.put(k, org.apache.thrift.TBaseHelper.byteBufferToByteArray(v));
168+
});
166169

167170
Map<String, Object> contextData = new HashMap<>();
168171
for (ContextPropagator propagator : contextPropagators) {

0 commit comments

Comments
 (0)