Skip to content

Commit

Permalink
fix(serialization): recording serialization properly converts recordi…
Browse files Browse the repository at this point in the history
…ng state types
  • Loading branch information
andrewazores committed Dec 4, 2023
1 parent e77984d commit 48f1d41
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public SerializableRecordingDescriptor(Recording recording) {
this(
recording.getId(),
recording.getName(),
RecordingState.valueOf(recording.getState().name()),
mapRecordingStateState(recording.getState()),
recording.getStartTime() == null ? 0 : recording.getStartTime().toEpochMilli(),
recording.getDuration() == null ? 0 : recording.getDuration().toMillis(),
recording.getDuration() == null,
Expand Down Expand Up @@ -101,6 +101,25 @@ public SerializableRecordingDescriptor(SerializableRecordingDescriptor o) {
this.maxAge = o.getMaxAge();
}

private static RecordingState mapRecordingStateState(jdk.jfr.RecordingState s) {
switch (s) {
case NEW:
return RecordingState.CREATED;
case DELAYED:
return RecordingState.CREATED;
case RUNNING:
return RecordingState.RUNNING;
case STOPPED:
return RecordingState.STOPPED;
case CLOSED:
return RecordingState.STOPPED;
default:
// better not to return null here for NPE safety, but this may not always be
// accurate
return RecordingState.CREATED;
}
}

public IRecordingDescriptor toJmcForm() {
return new IRecordingDescriptor() {

Expand Down

0 comments on commit 48f1d41

Please sign in to comment.