diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchRequest.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchRequest.java index e1766038d82..38318c36715 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchRequest.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/xpack/watcher/transport/actions/put/PutWatchRequest.java @@ -114,6 +114,7 @@ public class PutWatchRequest extends MasterNodeRequest { super.readFrom(in); id = in.readString(); source = in.readBytesReference(); + active = in.readBoolean(); } @Override @@ -121,6 +122,7 @@ public class PutWatchRequest extends MasterNodeRequest { super.writeTo(out); out.writeString(id); out.writeBytesReference(source); + out.writeBoolean(active); } } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java new file mode 100644 index 00000000000..8747949947c --- /dev/null +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/xpack/watcher/transport/action/put/PutWatchSerializationTests.java @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +package org.elasticsearch.xpack.watcher.transport.action.put; + +import org.elasticsearch.common.bytes.BytesArray; +import org.elasticsearch.common.io.stream.BytesStreamOutput; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.xpack.watcher.transport.actions.put.PutWatchRequest; + +import static org.hamcrest.Matchers.is; + +public class PutWatchSerializationTests extends ESTestCase { + + // https://github.com/elastic/x-plugins/issues/2490 + public void testPutWatchSerialization() throws Exception { + PutWatchRequest request = new PutWatchRequest(); + request.setId(randomAsciiOfLength(10)); + request.setActive(randomBoolean()); + request.setSource(new BytesArray(randomAsciiOfLength(20))); + + BytesStreamOutput streamOutput = new BytesStreamOutput(); + request.writeTo(streamOutput); + + PutWatchRequest readRequest = new PutWatchRequest(); + readRequest.readFrom(streamOutput.bytes().streamInput()); + assertThat(readRequest.isActive(), is(request.isActive())); + assertThat(readRequest.getId(), is(request.getId())); + assertThat(readRequest.getSource(), is(request.getSource())); + } + +}