Skip to content

Commit

Permalink
Fix null hack
Browse files Browse the repository at this point in the history
Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas committed Feb 13, 2024
1 parent 143cae8 commit 08bddb3
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.opensearch.commons.alerting.util.IndexUtils.Companion._VERSION
import org.opensearch.commons.notifications.action.BaseResponse
import org.opensearch.core.common.io.stream.StreamInput
import org.opensearch.core.common.io.stream.StreamOutput
import org.opensearch.core.common.io.stream.Writeable
import org.opensearch.core.xcontent.ToXContent
import org.opensearch.core.xcontent.ToXContentFragment
import org.opensearch.core.xcontent.XContentBuilder
Expand Down Expand Up @@ -51,8 +52,7 @@ class GetMonitorResponse : BaseResponse {
monitor = if (sin.readBoolean()) {
Monitor.readFrom(sin) // monitor
} else null,
// TODO - find correct solution for this instead of setting to null
associatedCompositeMonitors = null
associatedCompositeMonitors = sin.readList((AssociatedWorkflow)::readFrom)
)

@Throws(IOException::class)
Expand All @@ -67,9 +67,7 @@ class GetMonitorResponse : BaseResponse {
} else {
out.writeBoolean(false)
}
associatedWorkflows?.forEach {
it.writeTo(out)
}
out.writeList((associatedWorkflows?: emptyList()) as MutableList<AssociatedWorkflow>?)
}

@Throws(IOException::class)
Expand All @@ -88,7 +86,7 @@ class GetMonitorResponse : BaseResponse {
return builder.endObject()
}

class AssociatedWorkflow : ToXContentFragment {
class AssociatedWorkflow : ToXContentFragment, Writeable {
val id: String
val name: String

Expand All @@ -105,7 +103,7 @@ class GetMonitorResponse : BaseResponse {
return builder
}

fun writeTo(out: StreamOutput) {
override fun writeTo(out: StreamOutput) {
out.writeString(id)
out.writeString(name)
}
Expand Down

0 comments on commit 08bddb3

Please sign in to comment.