Skip to content

Commit

Permalink
ss
Browse files Browse the repository at this point in the history
  • Loading branch information
hussainkarafallah committed Aug 8, 2024
1 parent 87e2086 commit 668f1de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ public interface ITaskDaoDataSerializer {

byte[] deserialize(SerializedData serializedData);

TaskContext deserializeTaskContext(SerializedData serializedData);

@Data
@Accessors(chain = true)
class SerializedData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,15 @@ protected void assertIsolationLevel(Isolation isolation) {
}

protected TaskContext getContext(ResultSet rs, int dataFormatIdx, int contextIdx) throws SQLException {
byte[] context = rs.getBytes(contextIdx);
return taskDataSerializer.deserializeTaskContext(new SerializedData().setDataFormat(rs.getInt(dataFormatIdx)).setData(context));
return ExceptionUtils.doUnchecked(() ->
objectMapper.readValue(
taskDataSerializer.deserialize(new SerializedData()
.setDataFormat(rs.getInt(dataFormatIdx))
.setData(rs.getBytes(contextIdx))
),
TaskContext.class
)
);
}

protected byte[] getData(ResultSet rs, int deprecatedDataIdx, int dataFormatIdx, int dataIdx) throws SQLException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,5 @@ public byte[] deserialize(SerializedData serializedData) {
return serializedData.getData();
});
}

@Override
public TaskContext deserializeTaskContext(SerializedData serializedData) {
byte[] deserializedData = deserialize(serializedData);
if (deserializedData == null) {
return null;
}
try {
return objectMapper.readValue(deserializedData, TaskContext.class);
} catch (Exception e) {
log.error("Error deserializing task context. Will fallback to empty context.");
return new TaskContext();
}
}

}

0 comments on commit 668f1de

Please sign in to comment.