diff --git a/server/src/main/java/org/elasticsearch/action/ActionResponse.java b/server/src/main/java/org/elasticsearch/action/ActionResponse.java index f06a88f84fbc3..b19537a75fd38 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionResponse.java +++ b/server/src/main/java/org/elasticsearch/action/ActionResponse.java @@ -20,6 +20,9 @@ package org.elasticsearch.action; import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.ToXContentObject; +import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.transport.TransportResponse; import java.io.IOException; @@ -35,4 +38,21 @@ public ActionResponse() { public ActionResponse(StreamInput in) throws IOException { super(in); } + + public static final class Empty extends ActionResponse implements ToXContentObject { + public static final ActionResponse.Empty INSTANCE = new ActionResponse.Empty(); + + @Override + public String toString() { + return "EmptyActionResponse{}"; + } + + @Override + public void writeTo(StreamOutput out) {} + + @Override + public XContentBuilder toXContent(final XContentBuilder builder, final Params params) { + return builder; + } + } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java index d974457328b03..885198e46eecd 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsAction.java @@ -18,13 +18,14 @@ */ package org.elasticsearch.action.admin.cluster.configuration; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -public class AddVotingConfigExclusionsAction extends ActionType { +public class AddVotingConfigExclusionsAction extends ActionType { public static final AddVotingConfigExclusionsAction INSTANCE = new AddVotingConfigExclusionsAction(); public static final String NAME = "cluster:admin/voting_config/add_exclusions"; private AddVotingConfigExclusionsAction() { - super(NAME, AddVotingConfigExclusionsResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java deleted file mode 100644 index b6530be9092ae..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponse.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.action.admin.cluster.configuration; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContentObject; -import org.elasticsearch.common.xcontent.XContentBuilder; - -import java.io.IOException; - -/** - * A response to {@link AddVotingConfigExclusionsRequest} indicating that voting config exclusions have been added for the requested nodes - * and these nodes have been removed from the voting configuration. - */ -public class AddVotingConfigExclusionsResponse extends ActionResponse implements ToXContentObject { - - public AddVotingConfigExclusionsResponse() { - } - - public AddVotingConfigExclusionsResponse(StreamInput in) throws IOException { - super(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} - - @Override - public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException { - return builder; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java index c7a00c53bf9ea..7ec554ac55a7f 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsAction.java @@ -18,13 +18,14 @@ */ package org.elasticsearch.action.admin.cluster.configuration; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -public class ClearVotingConfigExclusionsAction extends ActionType { +public class ClearVotingConfigExclusionsAction extends ActionType { public static final ClearVotingConfigExclusionsAction INSTANCE = new ClearVotingConfigExclusionsAction(); public static final String NAME = "cluster:admin/voting_config/clear_exclusions"; private ClearVotingConfigExclusionsAction() { - super(NAME, ClearVotingConfigExclusionsResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java deleted file mode 100644 index 1c36c992eddeb..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.action.admin.cluster.configuration; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.xcontent.ToXContentObject; -import org.elasticsearch.common.xcontent.XContentBuilder; - -import java.io.IOException; - -/** - * A response to {@link ClearVotingConfigExclusionsRequest} indicating that voting config exclusions have been cleared from the - * cluster state. - */ -public class ClearVotingConfigExclusionsResponse extends ActionResponse implements ToXContentObject { - public ClearVotingConfigExclusionsResponse() { - } - - public ClearVotingConfigExclusionsResponse(StreamInput in) throws IOException { - super(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} - - @Override - public XContentBuilder toXContent(final XContentBuilder builder, final Params params) throws IOException { - return builder; - } -} diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java index 876507d3569d2..7e5a5d04e9d1e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterState; @@ -51,7 +52,7 @@ import java.util.stream.Collectors; public class TransportAddVotingConfigExclusionsAction extends TransportMasterNodeAction { + ActionResponse.Empty> { private static final Logger logger = LogManager.getLogger(TransportAddVotingConfigExclusionsAction.class); @@ -65,7 +66,7 @@ public TransportAddVotingConfigExclusionsAction(Settings settings, ClusterSettin ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(AddVotingConfigExclusionsAction.NAME, transportService, clusterService, threadPool, actionFilters, - AddVotingConfigExclusionsRequest::new, indexNameExpressionResolver, AddVotingConfigExclusionsResponse::new, + AddVotingConfigExclusionsRequest::new, indexNameExpressionResolver, in -> ActionResponse.Empty.INSTANCE, ThreadPool.Names.SAME); maxVotingConfigExclusions = MAXIMUM_VOTING_CONFIG_EXCLUSIONS_SETTING.get(settings); @@ -78,7 +79,7 @@ private void setMaxVotingConfigExclusions(int maxVotingConfigExclusions) { @Override protected void masterOperation(AddVotingConfigExclusionsRequest request, ClusterState state, - ActionListener listener) throws Exception { + ActionListener listener) throws Exception { resolveVotingConfigExclusionsAndCheckMaximum(request, state, maxVotingConfigExclusions); // throws IAE if no nodes matched or maximum exceeded @@ -123,7 +124,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS final Listener clusterStateListener = new Listener() { @Override public void onNewClusterState(ClusterState state) { - listener.onResponse(new AddVotingConfigExclusionsResponse()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } @Override diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java index d5d4cd4434a3e..c9534ec828ba9 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsAction.java @@ -23,6 +23,7 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.master.TransportMasterNodeAction; import org.elasticsearch.cluster.ClusterState; @@ -45,7 +46,7 @@ import java.util.function.Predicate; public class TransportClearVotingConfigExclusionsAction - extends TransportMasterNodeAction { + extends TransportMasterNodeAction { private static final Logger logger = LogManager.getLogger(TransportClearVotingConfigExclusionsAction.class); @@ -54,13 +55,13 @@ public TransportClearVotingConfigExclusionsAction(TransportService transportServ ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(ClearVotingConfigExclusionsAction.NAME, transportService, clusterService, threadPool, actionFilters, - ClearVotingConfigExclusionsRequest::new, indexNameExpressionResolver, ClearVotingConfigExclusionsResponse::new, + ClearVotingConfigExclusionsRequest::new, indexNameExpressionResolver, in -> ActionResponse.Empty.INSTANCE, ThreadPool.Names.SAME); } @Override protected void masterOperation(ClearVotingConfigExclusionsRequest request, ClusterState initialState, - ActionListener listener) throws Exception { + ActionListener listener) throws Exception { final long startTimeMillis = threadPool.relativeTimeInMillis(); @@ -103,7 +104,7 @@ public void onTimeout(TimeValue timeout) { } private void submitClearVotingConfigExclusionsTask(ClearVotingConfigExclusionsRequest request, long startTimeMillis, - ActionListener listener) { + ActionListener listener) { clusterService.submitStateUpdateTask("clear-voting-config-exclusions", new ClusterStateUpdateTask(Priority.URGENT, TimeValue.timeValueMillis( Math.max(0, request.getTimeout().millis() + startTimeMillis - threadPool.relativeTimeInMillis()))) { @@ -123,7 +124,7 @@ public void onFailure(String source, Exception e) { @Override public void clusterStateProcessed(String source, ClusterState oldState, ClusterState newState) { - listener.onResponse(new ClearVotingConfigExclusionsResponse()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } }); } diff --git a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java index c588a02d85f7b..96549d87552dc 100644 --- a/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java +++ b/server/src/main/java/org/elasticsearch/index/seqno/RetentionLeaseActions.java @@ -56,7 +56,7 @@ public class RetentionLeaseActions { public static final long RETAIN_ALL = -1; - abstract static class TransportRetentionLeaseAction> extends TransportSingleShardAction { + abstract static class TransportRetentionLeaseAction> extends TransportSingleShardAction { private final IndicesService indicesService; @@ -91,7 +91,7 @@ protected ShardsIterator shards(final ClusterState state, final InternalRequest } @Override - protected void asyncShardOperation(T request, ShardId shardId, final ActionListener listener) { + protected void asyncShardOperation(T request, ShardId shardId, final ActionListener listener) { final IndexService indexService = indicesService.indexServiceSafe(shardId.getIndex()); final IndexShard indexShard = indexService.getShard(shardId.id()); indexShard.acquirePrimaryOperationPermit( @@ -105,15 +105,15 @@ protected void asyncShardOperation(T request, ShardId shardId, final ActionListe } @Override - protected Response shardOperation(final T request, final ShardId shardId) { + protected ActionResponse.Empty shardOperation(final T request, final ShardId shardId) { throw new UnsupportedOperationException(); } - abstract void doRetentionLeaseAction(IndexShard indexShard, T request, ActionListener listener); + abstract void doRetentionLeaseAction(IndexShard indexShard, T request, ActionListener listener); @Override - protected Writeable.Reader getResponseReader() { - return Response::new; + protected final Writeable.Reader getResponseReader() { + return in -> ActionResponse.Empty.INSTANCE; } @Override @@ -123,13 +123,13 @@ protected boolean resolveIndex(final T request) { } - public static class Add extends ActionType { + public static class Add extends ActionType { public static final Add INSTANCE = new Add(); public static final String ACTION_NAME = "indices:admin/seq_no/add_retention_lease"; private Add() { - super(ACTION_NAME, Response::new); + super(ACTION_NAME, in -> ActionResponse.Empty.INSTANCE); } public static class TransportAction extends TransportRetentionLeaseAction { @@ -154,29 +154,24 @@ public TransportAction( } @Override - void doRetentionLeaseAction(final IndexShard indexShard, final AddRequest request, final ActionListener listener) { + void doRetentionLeaseAction(final IndexShard indexShard, final AddRequest request, + final ActionListener listener) { indexShard.addRetentionLease( request.getId(), request.getRetainingSequenceNumber(), request.getSource(), - ActionListener.map(listener, r -> new Response())); + ActionListener.map(listener, r -> ActionResponse.Empty.INSTANCE)); } - - @Override - protected Writeable.Reader getResponseReader() { - return Response::new; - } - } } - public static class Renew extends ActionType { + public static class Renew extends ActionType { public static final Renew INSTANCE = new Renew(); public static final String ACTION_NAME = "indices:admin/seq_no/renew_retention_lease"; private Renew() { - super(ACTION_NAME, Response::new); + super(ACTION_NAME, in -> ActionResponse.Empty.INSTANCE); } public static class TransportAction extends TransportRetentionLeaseAction { @@ -202,21 +197,22 @@ public TransportAction( @Override - void doRetentionLeaseAction(final IndexShard indexShard, final RenewRequest request, final ActionListener listener) { + void doRetentionLeaseAction(final IndexShard indexShard, final RenewRequest request, + final ActionListener listener) { indexShard.renewRetentionLease(request.getId(), request.getRetainingSequenceNumber(), request.getSource()); - listener.onResponse(new Response()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } } } - public static class Remove extends ActionType { + public static class Remove extends ActionType { public static final Remove INSTANCE = new Remove(); public static final String ACTION_NAME = "indices:admin/seq_no/remove_retention_lease"; private Remove() { - super(ACTION_NAME, Response::new); + super(ACTION_NAME, in -> ActionResponse.Empty.INSTANCE); } public static class TransportAction extends TransportRetentionLeaseAction { @@ -242,10 +238,11 @@ public TransportAction( @Override - void doRetentionLeaseAction(final IndexShard indexShard, final RemoveRequest request, final ActionListener listener) { + void doRetentionLeaseAction(final IndexShard indexShard, final RemoveRequest request, + final ActionListener listener) { indexShard.removeRetentionLease( request.getId(), - ActionListener.map(listener, r -> new Response())); + ActionListener.map(listener, r -> ActionResponse.Empty.INSTANCE)); } } @@ -364,17 +361,4 @@ public RemoveRequest(final ShardId shardId, final String id) { } } - - public static class Response extends ActionResponse { - - public Response() {} - - Response(final StreamInput in) throws IOException { - super(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} - } - } diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java index 654c479a4a525..e61298f066176 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java @@ -26,6 +26,7 @@ import org.apache.lucene.index.IndexCommit; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.cluster.ClusterChangedEvent; import org.elasticsearch.cluster.ClusterStateListener; import org.elasticsearch.cluster.SnapshotsInProgress; @@ -452,14 +453,14 @@ public void onFailure(Exception e) { }, (req, reqListener) -> transportService.sendRequest(transportService.getLocalNode(), SnapshotsService.UPDATE_SNAPSHOT_STATUS_ACTION_NAME, req, - new TransportResponseHandler() { + new TransportResponseHandler() { @Override - public UpdateIndexShardSnapshotStatusResponse read(StreamInput in) { - return UpdateIndexShardSnapshotStatusResponse.INSTANCE; + public ActionResponse.Empty read(StreamInput in) { + return ActionResponse.Empty.INSTANCE; } @Override - public void handleResponse(UpdateIndexShardSnapshotStatusResponse response) { + public void handleResponse(ActionResponse.Empty response) { reqListener.onResponse(null); } diff --git a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java index 6d68f2f7bfea7..fee7a96be360c 100644 --- a/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/elasticsearch/snapshots/SnapshotsService.java @@ -27,8 +27,9 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; -import org.elasticsearch.action.StepListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionRunnable; +import org.elasticsearch.action.StepListener; import org.elasticsearch.action.admin.cluster.snapshots.clone.CloneSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.create.CreateSnapshotRequest; import org.elasticsearch.action.admin.cluster.snapshots.delete.DeleteSnapshotRequest; @@ -3106,21 +3107,21 @@ private void startExecutableClones(SnapshotsInProgress snapshotsInProgress, @Nul } private class UpdateSnapshotStatusAction - extends TransportMasterNodeAction { + extends TransportMasterNodeAction { UpdateSnapshotStatusAction(TransportService transportService, ClusterService clusterService, ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) { super(UPDATE_SNAPSHOT_STATUS_ACTION_NAME, false, transportService, clusterService, threadPool, actionFilters, UpdateIndexShardSnapshotStatusRequest::new, indexNameExpressionResolver, - in -> UpdateIndexShardSnapshotStatusResponse.INSTANCE, ThreadPool.Names.SAME + in -> ActionResponse.Empty.INSTANCE, ThreadPool.Names.SAME ); } @Override protected void masterOperation(UpdateIndexShardSnapshotStatusRequest request, ClusterState state, - ActionListener listener) throws Exception { + ActionListener listener) throws Exception { innerUpdateSnapshotState(new ShardSnapshotUpdate(request.snapshot(), request.shardId(), request.status()), - ActionListener.delegateFailure(listener, (l, v) -> l.onResponse(UpdateIndexShardSnapshotStatusResponse.INSTANCE))); + ActionListener.delegateFailure(listener, (l, v) -> l.onResponse(ActionResponse.Empty.INSTANCE))); } @Override diff --git a/server/src/main/java/org/elasticsearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java b/server/src/main/java/org/elasticsearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java deleted file mode 100644 index 92f477074290d..0000000000000 --- a/server/src/main/java/org/elasticsearch/snapshots/UpdateIndexShardSnapshotStatusResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.snapshots; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -class UpdateIndexShardSnapshotStatusResponse extends ActionResponse { - - public static final UpdateIndexShardSnapshotStatusResponse INSTANCE = new UpdateIndexShardSnapshotStatusResponse(); - - private UpdateIndexShardSnapshotStatusResponse() {} - - @Override - public void writeTo(StreamOutput out) throws IOException {} -} diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponseTests.java deleted file mode 100644 index 55613d7bd516f..0000000000000 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/AddVotingConfigExclusionsResponseTests.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.action.admin.cluster.configuration; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -public class AddVotingConfigExclusionsResponseTests extends ESTestCase { - public void testSerialization() throws IOException { - final AddVotingConfigExclusionsResponse originalRequest = new AddVotingConfigExclusionsResponse(); - copyWriteable(originalRequest, writableRegistry(), AddVotingConfigExclusionsResponse::new); - // there are no fields so we're just checking that this doesn't throw anything - } -} diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponseTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponseTests.java deleted file mode 100644 index 97f67c3744e1d..0000000000000 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/ClearVotingConfigExclusionsResponseTests.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.elasticsearch.action.admin.cluster.configuration; - -import org.elasticsearch.test.ESTestCase; - -import java.io.IOException; - -public class ClearVotingConfigExclusionsResponseTests extends ESTestCase { - public void testSerialization() throws IOException { - final ClearVotingConfigExclusionsResponse originalRequest = new ClearVotingConfigExclusionsResponse(); - copyWriteable(originalRequest, writableRegistry(), ClearVotingConfigExclusionsResponse::new); - // there are no fields so we're just checking that this doesn't throw anything - } -} diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java index f40e102a66ca3..024c56121ba17 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java @@ -21,6 +21,7 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.Version; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -53,7 +54,6 @@ import org.junit.Before; import org.junit.BeforeClass; -import java.io.IOException; import java.util.HashSet; import java.util.Set; import java.util.concurrent.CountDownLatch; @@ -511,24 +511,24 @@ public void testTimesOut() throws InterruptedException { } - private TransportResponseHandler expectSuccess( - Consumer onResponse) { + private TransportResponseHandler expectSuccess( + Consumer onResponse) { return responseHandler(onResponse, e -> { throw new AssertionError("unexpected", e); }); } - private TransportResponseHandler expectError(Consumer onException) { + private TransportResponseHandler expectError(Consumer onException) { return responseHandler(r -> { assert false : r; }, onException); } - private TransportResponseHandler responseHandler( - Consumer onResponse, Consumer onException) { - return new TransportResponseHandler() { + private TransportResponseHandler responseHandler( + Consumer onResponse, Consumer onException) { + return new TransportResponseHandler() { @Override - public void handleResponse(AddVotingConfigExclusionsResponse response) { + public void handleResponse(ActionResponse.Empty response) { onResponse.accept(response); } @@ -538,8 +538,8 @@ public void handleException(TransportException exp) { } @Override - public AddVotingConfigExclusionsResponse read(StreamInput in) throws IOException { - return new AddVotingConfigExclusionsResponse(in); + public ActionResponse.Empty read(StreamInput in) { + return ActionResponse.Empty.INSTANCE; } }; } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java index b7fd80018eef9..9ae36e7779c49 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java @@ -21,6 +21,7 @@ import org.apache.lucene.util.SetOnce; import org.elasticsearch.ElasticsearchTimeoutException; import org.elasticsearch.Version; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -47,7 +48,6 @@ import org.junit.Before; import org.junit.BeforeClass; -import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; @@ -113,7 +113,7 @@ public void setupForTest() { public void testClearsVotingConfigExclusions() throws InterruptedException { final CountDownLatch countDownLatch = new CountDownLatch(1); - final SetOnce responseHolder = new SetOnce<>(); + final SetOnce responseHolder = new SetOnce<>(); final ClearVotingConfigExclusionsRequest clearVotingConfigExclusionsRequest = new ClearVotingConfigExclusionsRequest(); clearVotingConfigExclusionsRequest.setWaitForRemoval(false); @@ -155,7 +155,7 @@ public void testTimesOutIfWaitingForNodesThatAreNotRemoved() throws InterruptedE public void testSucceedsIfNodesAreRemovedWhileWaiting() throws InterruptedException { final CountDownLatch countDownLatch = new CountDownLatch(1); - final SetOnce responseHolder = new SetOnce<>(); + final SetOnce responseHolder = new SetOnce<>(); transportService.sendRequest(localNode, ClearVotingConfigExclusionsAction.NAME, new ClearVotingConfigExclusionsRequest(), @@ -173,24 +173,24 @@ public void testSucceedsIfNodesAreRemovedWhileWaiting() throws InterruptedExcept assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), empty()); } - private TransportResponseHandler expectSuccess( - Consumer onResponse) { + private TransportResponseHandler expectSuccess( + Consumer onResponse) { return responseHandler(onResponse, e -> { throw new AssertionError("unexpected", e); }); } - private TransportResponseHandler expectError(Consumer onException) { + private TransportResponseHandler expectError(Consumer onException) { return responseHandler(r -> { assert false : r; }, onException); } - private TransportResponseHandler responseHandler( - Consumer onResponse, Consumer onException) { - return new TransportResponseHandler() { + private TransportResponseHandler responseHandler( + Consumer onResponse, Consumer onException) { + return new TransportResponseHandler() { @Override - public void handleResponse(ClearVotingConfigExclusionsResponse response) { + public void handleResponse(ActionResponse.Empty response) { onResponse.accept(response); } @@ -200,8 +200,8 @@ public void handleException(TransportException exp) { } @Override - public ClearVotingConfigExclusionsResponse read(StreamInput in) throws IOException { - return new ClearVotingConfigExclusionsResponse(in); + public ActionResponse.Empty read(StreamInput in) { + return ActionResponse.Empty.INSTANCE; } }; } diff --git a/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java b/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java index 511a93e8268d1..3bcdebba582c3 100644 --- a/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java +++ b/server/src/test/java/org/elasticsearch/index/seqno/RetentionLeaseActionsTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.index.seqno; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.indices.stats.IndicesStatsAction; import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest; import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse; @@ -315,10 +316,10 @@ public void testAddUnderBlock() throws InterruptedException { client().execute( RetentionLeaseActions.Add.INSTANCE, new RetentionLeaseActions.AddRequest(shardId, id, retainingSequenceNumber, source), - new ActionListener() { + new ActionListener() { @Override - public void onResponse(final RetentionLeaseActions.Response response) { + public void onResponse(final ActionResponse.Empty response) { actionLatch.countDown(); } @@ -416,10 +417,10 @@ public void testRenewUnderBlock() throws InterruptedException { client().execute( RetentionLeaseActions.Renew.INSTANCE, new RetentionLeaseActions.RenewRequest(shardId, id, nextRetainingSequenceNumber, source), - new ActionListener() { + new ActionListener() { @Override - public void onResponse(final RetentionLeaseActions.Response response) { + public void onResponse(final ActionResponse.Empty response) { actionLatch.countDown(); } @@ -475,10 +476,10 @@ public void testRemoveUnderBlock() throws InterruptedException { client().execute( RetentionLeaseActions.Remove.INSTANCE, new RetentionLeaseActions.RemoveRequest(shardId, id), - new ActionListener() { + new ActionListener() { @Override - public void onResponse(final RetentionLeaseActions.Response response) { + public void onResponse(final ActionResponse.Empty response) { actionLatch.countDown(); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java index 917308eea972e..a7689d069159b 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRepositoryManager.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.ccr; import org.elasticsearch.action.ActionRequest; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.service.ClusterService; @@ -49,14 +50,14 @@ protected void doClose() throws IOException { private void putRepository(String repositoryName) { ActionRequest request = new PutInternalCcrRepositoryRequest(repositoryName, CcrRepository.TYPE); - PlainActionFuture f = PlainActionFuture.newFuture(); + PlainActionFuture f = PlainActionFuture.newFuture(); client.execute(PutInternalCcrRepositoryAction.INSTANCE, request, f); assert f.isDone() : "Should be completed as it is executed synchronously"; } private void deleteRepository(String repositoryName) { DeleteInternalCcrRepositoryRequest request = new DeleteInternalCcrRepositoryRequest(repositoryName); - PlainActionFuture f = PlainActionFuture.newFuture(); + PlainActionFuture f = PlainActionFuture.newFuture(); client.execute(DeleteInternalCcrRepositoryAction.INSTANCE, request, f); assert f.isDone() : "Should be completed as it is executed synchronously"; } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java index 7f165a8cf5d56..e81c95c3b6f7f 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/CcrRetentionLeases.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.ccr; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.common.settings.Setting; @@ -74,7 +75,7 @@ public static Optional syncAddRetentionLea final Client remoteClient, final TimeValue timeout) { try { - final PlainActionFuture response = new PlainActionFuture<>(); + final PlainActionFuture response = new PlainActionFuture<>(); asyncAddRetentionLease(leaderShardId, retentionLeaseId, retainingSequenceNumber, remoteClient, response); response.actionGet(timeout); return Optional.empty(); @@ -99,7 +100,7 @@ public static void asyncAddRetentionLease( final String retentionLeaseId, final long retainingSequenceNumber, final Client remoteClient, - final ActionListener listener) { + final ActionListener listener) { final RetentionLeaseActions.AddRequest request = new RetentionLeaseActions.AddRequest(leaderShardId, retentionLeaseId, retainingSequenceNumber, "ccr"); remoteClient.execute(RetentionLeaseActions.Add.INSTANCE, request, listener); @@ -123,7 +124,7 @@ public static Optional syncRenewRetentionLease( final Client remoteClient, final TimeValue timeout) { try { - final PlainActionFuture response = new PlainActionFuture<>(); + final PlainActionFuture response = new PlainActionFuture<>(); asyncRenewRetentionLease(leaderShardId, retentionLeaseId, retainingSequenceNumber, remoteClient, response); response.actionGet(timeout); return Optional.empty(); @@ -148,7 +149,7 @@ public static void asyncRenewRetentionLease( final String retentionLeaseId, final long retainingSequenceNumber, final Client remoteClient, - final ActionListener listener) { + final ActionListener listener) { final RetentionLeaseActions.RenewRequest request = new RetentionLeaseActions.RenewRequest(leaderShardId, retentionLeaseId, retainingSequenceNumber, "ccr"); remoteClient.execute(RetentionLeaseActions.Renew.INSTANCE, request, listener); @@ -168,7 +169,7 @@ public static void asyncRemoveRetentionLease( final ShardId leaderShardId, final String retentionLeaseId, final Client remoteClient, - final ActionListener listener) { + final ActionListener listener) { final RetentionLeaseActions.RemoveRequest request = new RetentionLeaseActions.RemoveRequest(leaderShardId, retentionLeaseId); remoteClient.execute(RetentionLeaseActions.Remove.INSTANCE, request, listener); } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java index ac8ba9261631d..369c8460b6071 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowTasksExecutor.java @@ -13,6 +13,7 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest; @@ -47,7 +48,6 @@ import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.engine.CommitStats; import org.elasticsearch.index.engine.Engine; -import org.elasticsearch.index.seqno.RetentionLeaseActions; import org.elasticsearch.index.seqno.RetentionLeaseInvalidRetainingSeqNoException; import org.elasticsearch.index.seqno.RetentionLeaseNotFoundException; import org.elasticsearch.index.seqno.SeqNoStats; @@ -427,7 +427,7 @@ protected Scheduler.Cancellable scheduleBackgroundRetentionLeaseRenewal(final Lo * again. If that fails, it had better not be because the retention lease already exists. Either way, we will attempt to * renew again on the next scheduled execution. */ - final ActionListener listener = ActionListener.wrap( + final ActionListener listener = ActionListener.wrap( r -> {}, e -> { /* @@ -451,7 +451,7 @@ protected Scheduler.Cancellable scheduleBackgroundRetentionLeaseRenewal(final Lo params.getFollowShardId(), retentionLeaseId); try { - final ActionListener wrappedListener = ActionListener.wrap( + final ActionListener wrappedListener = ActionListener.wrap( r -> {}, inner -> { /* diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java index f4e82d3957b48..253158197e340 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/TransportUnfollowAction.java @@ -13,6 +13,7 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.GroupedActionListener; import org.elasticsearch.action.support.master.AcknowledgedResponse; @@ -31,7 +32,6 @@ import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexNotFoundException; -import org.elasticsearch.index.seqno.RetentionLeaseActions; import org.elasticsearch.index.seqno.RetentionLeaseNotFoundException; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.persistent.PersistentTasksCustomMetadata; @@ -106,11 +106,11 @@ public void clusterStateProcessed(final String source, final ClusterState oldSta leaderIndex); final int numberOfShards = IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.get(indexMetadata.getSettings()); - final GroupedActionListener groupListener = new GroupedActionListener<>( - new ActionListener>() { + final GroupedActionListener groupListener = new GroupedActionListener<>( + new ActionListener>() { @Override - public void onResponse(final Collection responses) { + public void onResponse(final Collection responses) { logger.trace( "[{}] removed retention lease [{}] on all leader primary shards", indexMetadata.getIndex(), @@ -157,7 +157,7 @@ private void removeRetentionLeaseForShard( final ShardId leaderShardId, final String retentionLeaseId, final Client remoteClient, - final ActionListener listener) { + final ActionListener listener) { logger.trace("{} removing retention lease [{}] while unfollowing leader index", followerShardId, retentionLeaseId); final ThreadContext threadContext = threadPool.getThreadContext(); try (ThreadContext.StoredContext ignore = threadPool.getThreadContext().stashContext()) { @@ -171,7 +171,7 @@ private void handleException( final ShardId followerShardId, final String retentionLeaseId, final ShardId leaderShardId, - final ActionListener listener, + final ActionListener listener, final Exception e) { final Throwable cause = ExceptionsHelper.unwrapCause(e); assert cause instanceof ElasticsearchSecurityException == false : e; @@ -183,7 +183,7 @@ private void handleException( retentionLeaseId, leaderShardId), e); - listener.onResponse(new RetentionLeaseActions.Response()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } else { logger.warn(new ParameterizedMessage( "{} failed to remove retention lease [{}] on {} while unfollowing", diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionAction.java index ec8bb500fc34e..e0ed85883df93 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionAction.java @@ -12,27 +12,23 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.tasks.Task; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.transport.TransportActionProxy; import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.ccr.repository.CcrRestoreSourceService; -import java.io.IOException; - -public class ClearCcrRestoreSessionAction extends ActionType { +public class ClearCcrRestoreSessionAction extends ActionType { public static final ClearCcrRestoreSessionAction INSTANCE = new ClearCcrRestoreSessionAction(); public static final String NAME = "internal:admin/ccr/restore/session/clear"; private ClearCcrRestoreSessionAction() { - super(NAME, ClearCcrRestoreSessionAction.ClearCcrRestoreSessionResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } public static class TransportDeleteCcrRestoreSessionAction - extends HandledTransportAction { + extends HandledTransportAction { private final CcrRestoreSourceService ccrRestoreService; @@ -40,27 +36,15 @@ public static class TransportDeleteCcrRestoreSessionAction public TransportDeleteCcrRestoreSessionAction(ActionFilters actionFilters, TransportService transportService, CcrRestoreSourceService ccrRestoreService) { super(NAME, transportService, actionFilters, ClearCcrRestoreSessionRequest::new, ThreadPool.Names.GENERIC); - TransportActionProxy.registerProxyAction(transportService, NAME, ClearCcrRestoreSessionResponse::new); + TransportActionProxy.registerProxyAction(transportService, NAME, in -> ActionResponse.Empty.INSTANCE); this.ccrRestoreService = ccrRestoreService; } @Override protected void doExecute(Task task, ClearCcrRestoreSessionRequest request, - ActionListener listener) { + ActionListener listener) { ccrRestoreService.closeSession(request.getSessionUUID()); - listener.onResponse(new ClearCcrRestoreSessionResponse()); - } - } - - public static class ClearCcrRestoreSessionResponse extends ActionResponse { - - ClearCcrRestoreSessionResponse() { + listener.onResponse(ActionResponse.Empty.INSTANCE); } - - ClearCcrRestoreSessionResponse(StreamInput in) { - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java index aa0b384acc6b3..bd8d74c0ad12e 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/DeleteInternalCcrRepositoryAction.java @@ -12,25 +12,21 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.TransportAction; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; -import java.io.IOException; - -public class DeleteInternalCcrRepositoryAction extends ActionType { +public class DeleteInternalCcrRepositoryAction extends ActionType { public static final DeleteInternalCcrRepositoryAction INSTANCE = new DeleteInternalCcrRepositoryAction(); public static final String NAME = "internal:admin/ccr/internal_repository/delete"; private DeleteInternalCcrRepositoryAction() { - super(NAME, DeleteInternalCcrRepositoryAction.DeleteInternalCcrRepositoryResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } public static class TransportDeleteInternalRepositoryAction - extends TransportAction { + extends TransportAction { private final RepositoriesService repositoriesService; @@ -43,23 +39,9 @@ public TransportDeleteInternalRepositoryAction(RepositoriesService repositoriesS @Override protected void doExecute(Task task, DeleteInternalCcrRepositoryRequest request, - ActionListener listener) { + ActionListener listener) { repositoriesService.unregisterInternalRepository(request.getName()); - listener.onResponse(new DeleteInternalCcrRepositoryResponse()); - } - } - - public static class DeleteInternalCcrRepositoryResponse extends ActionResponse { - - DeleteInternalCcrRepositoryResponse() { - super(); + listener.onResponse(ActionResponse.Empty.INSTANCE); } - - DeleteInternalCcrRepositoryResponse(StreamInput streamInput) throws IOException { - super(streamInput); - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java index 264c5adcc10a4..9c5d6d52c2654 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/repositories/PutInternalCcrRepositoryAction.java @@ -12,25 +12,21 @@ import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.TransportAction; import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.repositories.RepositoriesService; import org.elasticsearch.tasks.Task; import org.elasticsearch.transport.TransportService; -import java.io.IOException; - -public class PutInternalCcrRepositoryAction extends ActionType { +public class PutInternalCcrRepositoryAction extends ActionType { public static final PutInternalCcrRepositoryAction INSTANCE = new PutInternalCcrRepositoryAction(); public static final String NAME = "internal:admin/ccr/internal_repository/put"; private PutInternalCcrRepositoryAction() { - super(NAME, PutInternalCcrRepositoryAction.PutInternalCcrRepositoryResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } public static class TransportPutInternalRepositoryAction - extends TransportAction { + extends TransportAction { private final RepositoriesService repositoriesService; @@ -43,23 +39,9 @@ public TransportPutInternalRepositoryAction(RepositoriesService repositoriesServ @Override protected void doExecute(Task task, PutInternalCcrRepositoryRequest request, - ActionListener listener) { + ActionListener listener) { repositoriesService.registerInternalRepository(request.getName(), request.getType()); - listener.onResponse(new PutInternalCcrRepositoryResponse()); - } - } - - public static class PutInternalCcrRepositoryResponse extends ActionResponse { - - PutInternalCcrRepositoryResponse() { - super(); + listener.onResponse(ActionResponse.Empty.INSTANCE); } - - PutInternalCcrRepositoryResponse(StreamInput streamInput) throws IOException { - super(streamInput); - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} } } diff --git a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java index 4d043c601955c..e204b8a80f1b3 100644 --- a/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java +++ b/x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/repository/CcrRepository.java @@ -17,6 +17,7 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest; import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest; @@ -109,7 +110,6 @@ import static org.elasticsearch.xpack.ccr.CcrRetentionLeases.syncAddRetentionLease; import static org.elasticsearch.xpack.ccr.CcrRetentionLeases.syncRenewRetentionLease; - /** * This repository relies on a remote cluster for Ccr restores. It is read-only so it can only be used to * restore shards/indexes that exist on the remote cluster. @@ -617,7 +617,7 @@ public void close() { @Override public void close() { ClearCcrRestoreSessionRequest clearRequest = new ClearCcrRestoreSessionRequest(sessionUUID, node); - ClearCcrRestoreSessionAction.ClearCcrRestoreSessionResponse response = + ActionResponse.Empty response = remoteClient.execute(ClearCcrRestoreSessionAction.INSTANCE, clearRequest).actionGet(ccrSettings.getRecoveryActionTimeout()); } diff --git a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java index 8f7db22080c07..a97c59fb3926c 100644 --- a/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java +++ b/x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/repository/CcrRepositoryRetentionLeaseTests.java @@ -7,6 +7,7 @@ package org.elasticsearch.xpack.ccr.repository; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.client.Client; import org.elasticsearch.cluster.metadata.RepositoryMetadata; @@ -74,8 +75,8 @@ public void testWhenRetentionLeaseAlreadyExistsWeTryToRenewIt() { ArgumentCaptor.forClass(RetentionLeaseActions.AddRequest.class); doAnswer( invocationOnMock -> { - @SuppressWarnings("unchecked") final ActionListener listener = - (ActionListener) invocationOnMock.getArguments()[2]; + @SuppressWarnings("unchecked") final ActionListener listener = + (ActionListener) invocationOnMock.getArguments()[2]; listener.onFailure(new RetentionLeaseAlreadyExistsException(retentionLeaseId)); return null; }) @@ -85,9 +86,9 @@ public void testWhenRetentionLeaseAlreadyExistsWeTryToRenewIt() { ArgumentCaptor.forClass(RetentionLeaseActions.RenewRequest.class); doAnswer( invocationOnMock -> { - @SuppressWarnings("unchecked") final ActionListener listener = - (ActionListener) invocationOnMock.getArguments()[2]; - listener.onResponse(new RetentionLeaseActions.Response()); + @SuppressWarnings("unchecked") final ActionListener listener = + (ActionListener) invocationOnMock.getArguments()[2]; + listener.onResponse(ActionResponse.Empty.INSTANCE); return null; }) .when(remoteClient) @@ -137,8 +138,8 @@ public void testWhenRetentionLeaseExpiresBeforeWeCanRenewIt() { final Client remoteClient = mock(Client.class); final ArgumentCaptor addRequestCaptor = ArgumentCaptor.forClass(RetentionLeaseActions.AddRequest.class); - final PlainActionFuture response = new PlainActionFuture<>(); - response.onResponse(new RetentionLeaseActions.Response()); + final PlainActionFuture response = new PlainActionFuture<>(); + response.onResponse(ActionResponse.Empty.INSTANCE); doAnswer( new Answer() { @@ -146,12 +147,12 @@ public void testWhenRetentionLeaseExpiresBeforeWeCanRenewIt() { @Override public Void answer(final InvocationOnMock invocationOnMock) { - @SuppressWarnings("unchecked") final ActionListener listener = - (ActionListener) invocationOnMock.getArguments()[2]; + @SuppressWarnings("unchecked") final ActionListener listener = + (ActionListener) invocationOnMock.getArguments()[2]; if (firstInvocation.compareAndSet(true, false)) { listener.onFailure(new RetentionLeaseAlreadyExistsException(retentionLeaseId)); } else { - listener.onResponse(new RetentionLeaseActions.Response()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } return null; } @@ -162,8 +163,8 @@ public Void answer(final InvocationOnMock invocationOnMock) { ArgumentCaptor.forClass(RetentionLeaseActions.RenewRequest.class); doAnswer( invocationOnMock -> { - @SuppressWarnings("unchecked") final ActionListener listener = - (ActionListener) invocationOnMock.getArguments()[2]; + @SuppressWarnings("unchecked") final ActionListener listener = + (ActionListener) invocationOnMock.getArguments()[2]; listener.onFailure(new RetentionLeaseNotFoundException(retentionLeaseId)); return null; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java index c0e95bd100a12..c1a13d59ce199 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutAction.java @@ -5,17 +5,18 @@ */ package org.elasticsearch.xpack.core.security.action.saml; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; /** * ActionType for completing SAML LogoutResponse */ -public final class SamlCompleteLogoutAction extends ActionType { +public final class SamlCompleteLogoutAction extends ActionType { public static final String NAME = "cluster:admin/xpack/security/saml/complete_logout"; public static final SamlCompleteLogoutAction INSTANCE = new SamlCompleteLogoutAction(); private SamlCompleteLogoutAction() { - super(NAME, SamlCompleteLogoutResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutResponse.java deleted file mode 100644 index cc38b17a1dd20..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/saml/SamlCompleteLogoutResponse.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.core.security.action.saml; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -/** - * A response to complete the LogoutResponse from idP - */ -public final class SamlCompleteLogoutResponse extends ActionResponse { - - public SamlCompleteLogoutResponse(StreamInput in) throws IOException { - super(in); - } - - public SamlCompleteLogoutResponse() { - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - } -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java index e72a969f2403e..189e518d6cd7c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordAction.java @@ -5,14 +5,15 @@ */ package org.elasticsearch.xpack.core.security.action.user; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; -public class ChangePasswordAction extends ActionType { +public class ChangePasswordAction extends ActionType { public static final ChangePasswordAction INSTANCE = new ChangePasswordAction(); public static final String NAME = "cluster:admin/xpack/security/user/change_password"; protected ChangePasswordAction() { - super(NAME, ChangePasswordResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java index 632e5fb6b5473..226adbe0a4f01 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordRequestBuilder.java @@ -7,6 +7,7 @@ import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.ActionRequestBuilder; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.WriteRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.ValidationException; @@ -29,7 +30,7 @@ * Request to change a user's password. */ public class ChangePasswordRequestBuilder - extends ActionRequestBuilder + extends ActionRequestBuilder implements WriteRequestBuilder { public ChangePasswordRequestBuilder(ElasticsearchClient client) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordResponse.java deleted file mode 100644 index 591fbd98a3a07..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/ChangePasswordResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.core.security.action.user; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -public class ChangePasswordResponse extends ActionResponse { - - public ChangePasswordResponse() {} - - public ChangePasswordResponse(StreamInput in) throws IOException { - super(in); - } - - @Override - public void writeTo(StreamOutput out) throws IOException {} -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java index 9cb6d8f9626f4..8b1382a68381d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledAction.java @@ -5,17 +5,18 @@ */ package org.elasticsearch.xpack.core.security.action.user; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.ActionType; /** * This action is for setting the enabled flag on a native or reserved user */ -public class SetEnabledAction extends ActionType { +public class SetEnabledAction extends ActionType { public static final SetEnabledAction INSTANCE = new SetEnabledAction(); public static final String NAME = "cluster:admin/xpack/security/user/set_enabled"; private SetEnabledAction() { - super(NAME, SetEnabledResponse::new); + super(NAME, in -> ActionResponse.Empty.INSTANCE); } } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java index b8298f09b9b79..f15a5608a3cac 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledRequestBuilder.java @@ -6,13 +6,14 @@ package org.elasticsearch.xpack.core.security.action.user; import org.elasticsearch.action.ActionRequestBuilder; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.WriteRequestBuilder; import org.elasticsearch.client.ElasticsearchClient; /** * Request builder for setting a user as enabled or disabled */ -public class SetEnabledRequestBuilder extends ActionRequestBuilder +public class SetEnabledRequestBuilder extends ActionRequestBuilder implements WriteRequestBuilder { public SetEnabledRequestBuilder(ElasticsearchClient client) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledResponse.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledResponse.java deleted file mode 100644 index fdb6a6a8aaa13..0000000000000 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/action/user/SetEnabledResponse.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.core.security.action.user; - -import org.elasticsearch.action.ActionResponse; -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; - -import java.io.IOException; - -/** - * Empty response for a {@link SetEnabledRequest} - */ -public class SetEnabledResponse extends ActionResponse { - - public SetEnabledResponse() {} - - public SetEnabledResponse(StreamInput in) throws IOException { - super(in); - } - @Override - public void writeTo(StreamOutput out) throws IOException {} -} diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java index 3a54f8f51a13a..b1e8f1c84d3f4 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/security/client/SecurityClient.java @@ -7,6 +7,7 @@ import org.elasticsearch.action.ActionFuture; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.ElasticsearchClient; import org.elasticsearch.common.bytes.BytesReference; import org.elasticsearch.common.settings.SecureString; @@ -72,7 +73,6 @@ import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequestBuilder; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordResponse; import org.elasticsearch.xpack.core.security.action.user.DeleteUserAction; import org.elasticsearch.xpack.core.security.action.user.DeleteUserRequest; import org.elasticsearch.xpack.core.security.action.user.DeleteUserRequestBuilder; @@ -96,7 +96,6 @@ import org.elasticsearch.xpack.core.security.action.user.SetEnabledAction; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequestBuilder; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledResponse; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import java.io.IOException; @@ -246,7 +245,7 @@ public ChangePasswordRequestBuilder prepareChangePassword(String username, Bytes return new ChangePasswordRequestBuilder(client).username(username).source(source, xContentType, hasher); } - public void changePassword(ChangePasswordRequest request, ActionListener listener) { + public void changePassword(ChangePasswordRequest request, ActionListener listener) { client.execute(ChangePasswordAction.INSTANCE, request, listener); } @@ -254,7 +253,7 @@ public SetEnabledRequestBuilder prepareSetEnabled(String username, boolean enabl return new SetEnabledRequestBuilder(client).username(username).enabled(enabled); } - public void setEnabled(SetEnabledRequest request, ActionListener listener) { + public void setEnabled(SetEnabledRequest request, ActionListener listener) { client.execute(SetEnabledAction.INSTANCE, request, listener); } diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java index 21f0d1403daf9..b8713f9bdd486 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/NativeRealmIntegTests.java @@ -7,6 +7,7 @@ import org.apache.lucene.util.CollectionUtil; import org.elasticsearch.ElasticsearchSecurityException; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.action.admin.cluster.snapshots.restore.RestoreSnapshotResponse; import org.elasticsearch.action.admin.indices.create.CreateIndexResponse; @@ -37,7 +38,6 @@ import org.elasticsearch.xpack.core.security.action.user.AuthenticateAction; import org.elasticsearch.xpack.core.security.action.user.AuthenticateRequest; import org.elasticsearch.xpack.core.security.action.user.AuthenticateResponse; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordResponse; import org.elasticsearch.xpack.core.security.action.user.DeleteUserResponse; import org.elasticsearch.xpack.core.security.action.user.GetUsersResponse; import org.elasticsearch.xpack.core.security.authc.Authentication; @@ -675,7 +675,7 @@ public void testCreateAndChangePassword() throws Exception { .admin().cluster().prepareHealth().get(); assertThat(response.isTimedOut(), is(false)); - ChangePasswordResponse passwordResponse = securityClient( + ActionResponse.Empty passwordResponse = securityClient( client().filterWithHeader(Collections.singletonMap("Authorization", token))) .prepareChangePassword("joe", SecuritySettingsSourceField.TEST_PASSWORD.toCharArray(), hasher).get(); assertThat(passwordResponse, notNullValue()); diff --git a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java index 4ed27bec0de72..2c2b9953e642d 100644 --- a/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java +++ b/x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmIntegTests.java @@ -6,11 +6,11 @@ package org.elasticsearch.xpack.security.authc.esnative; import org.elasticsearch.ElasticsearchSecurityException; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.NativeRealmIntegTestCase; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordResponse; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.client.SecurityClient; import org.elasticsearch.xpack.core.security.user.APMSystemUser; @@ -103,7 +103,7 @@ public void testChangingPassword() { assertThat(response.getClusterName(), is(cluster().getClusterName())); } - ChangePasswordResponse response = securityClient() + ActionResponse.Empty response = securityClient() .prepareChangePassword(username, Arrays.copyOf(newPassword, newPassword.length), hasher) .get(); assertThat(response, notNullValue()); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java index f4893c15f1cae..83d2b54de8b11 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/saml/TransportSamlCompleteLogoutAction.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.security.action.saml; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; @@ -13,7 +14,6 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutAction; import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutRequest; -import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutResponse; import org.elasticsearch.xpack.security.authc.Realms; import org.elasticsearch.xpack.security.authc.saml.SamlLogoutResponseHandler; import org.elasticsearch.xpack.security.authc.saml.SamlRealm; @@ -26,7 +26,7 @@ /** * Transport action responsible for completing SAML LogoutResponse */ -public final class TransportSamlCompleteLogoutAction extends HandledTransportAction { +public final class TransportSamlCompleteLogoutAction extends HandledTransportAction { private final Realms realms; @@ -37,7 +37,7 @@ public TransportSamlCompleteLogoutAction(TransportService transportService, Acti } @Override - protected void doExecute(Task task, SamlCompleteLogoutRequest request, ActionListener listener) { + protected void doExecute(Task task, SamlCompleteLogoutRequest request, ActionListener listener) { List realms = findSamlRealms(this.realms, request.getRealm(), null); if (realms.isEmpty()) { listener.onFailure(SamlUtils.samlException("Cannot find any matching realm with name [{}]", request.getRealm())); @@ -49,12 +49,12 @@ protected void doExecute(Task task, SamlCompleteLogoutRequest request, ActionLis } private void processLogoutResponse(SamlRealm samlRealm, SamlCompleteLogoutRequest request, - ActionListener listener) { + ActionListener listener) { final SamlLogoutResponseHandler logoutResponseHandler = samlRealm.getLogoutResponseHandler(); try { logoutResponseHandler.handle(request.isHttpRedirect(), request.getPayload(), request.getValidRequestIds()); - listener.onResponse(new SamlCompleteLogoutResponse()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } catch (Exception e) { listener.onFailure(e); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java index 96553f8f7bdeb..b39526be721d8 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.security.action.user; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; @@ -15,14 +16,13 @@ import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordAction; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordResponse; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.user.AnonymousUser; import org.elasticsearch.xpack.core.security.user.SystemUser; import org.elasticsearch.xpack.core.security.user.XPackUser; import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; -public class TransportChangePasswordAction extends HandledTransportAction { +public class TransportChangePasswordAction extends HandledTransportAction { private final Settings settings; private final NativeUsersStore nativeUsersStore; @@ -36,7 +36,7 @@ public TransportChangePasswordAction(Settings settings, TransportService transpo } @Override - protected void doExecute(Task task, ChangePasswordRequest request, ActionListener listener) { + protected void doExecute(Task task, ChangePasswordRequest request, ActionListener listener) { final String username = request.username(); if (AnonymousUser.isAnonymousUsername(username, settings)) { listener.onFailure(new IllegalArgumentException("user [" + username + "] is anonymous and cannot be modified via the API")); @@ -55,7 +55,7 @@ protected void doExecute(Task task, ChangePasswordRequest request, ActionListene nativeUsersStore.changePassword(request, new ActionListener() { @Override public void onResponse(Void v) { - listener.onResponse(new ChangePasswordResponse()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java index 2640961acf1ee..f5bd938b23da5 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java @@ -6,6 +6,7 @@ package org.elasticsearch.xpack.security.action.user; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.HandledTransportAction; import org.elasticsearch.common.inject.Inject; @@ -16,7 +17,6 @@ import org.elasticsearch.xpack.core.security.SecurityContext; import org.elasticsearch.xpack.core.security.action.user.SetEnabledAction; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledResponse; import org.elasticsearch.xpack.core.security.user.AnonymousUser; import org.elasticsearch.xpack.core.security.user.SystemUser; import org.elasticsearch.xpack.core.security.user.XPackUser; @@ -25,7 +25,7 @@ /** * Transport action that handles setting a native or reserved user to enabled */ -public class TransportSetEnabledAction extends HandledTransportAction { +public class TransportSetEnabledAction extends HandledTransportAction { private final Settings settings; private final ThreadPool threadPool; @@ -43,7 +43,7 @@ public TransportSetEnabledAction(Settings settings, ThreadPool threadPool, Trans } @Override - protected void doExecute(Task task, SetEnabledRequest request, ActionListener listener) { + protected void doExecute(Task task, SetEnabledRequest request, ActionListener listener) { final String username = request.username(); // make sure the user is not disabling themselves if (securityContext.getUser().principal().equals(request.username())) { @@ -60,7 +60,7 @@ protected void doExecute(Task task, SetEnabledRequest request, ActionListener() { @Override public void onResponse(Void v) { - listener.onResponse(new SetEnabledResponse()); + listener.onResponse(ActionResponse.Empty.INSTANCE); } @Override diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java index 7f5031e695382..4f894131b4293 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/saml/RestSamlCompleteLogoutAction.java @@ -8,6 +8,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.ParseField; import org.elasticsearch.common.Strings; @@ -23,7 +24,6 @@ import org.elasticsearch.rest.action.RestBuilderListener; import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutAction; import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutRequest; -import org.elasticsearch.xpack.core.security.action.saml.SamlCompleteLogoutResponse; import java.io.IOException; import java.util.Collections; @@ -76,9 +76,9 @@ protected RestChannelConsumer innerPrepareRequest(RestRequest request, NodeClien Strings.cleanTruncate(samlCompleteLogoutRequest.getContent(), 128), samlCompleteLogoutRequest.getValidRequestIds()); return channel -> client.execute(SamlCompleteLogoutAction.INSTANCE, samlCompleteLogoutRequest, - new RestBuilderListener(channel) { + new RestBuilderListener(channel) { @Override - public RestResponse buildResponse(SamlCompleteLogoutResponse response, XContentBuilder builder) throws Exception { + public RestResponse buildResponse(ActionResponse.Empty response, XContentBuilder builder) throws Exception { builder.startObject().endObject(); return new BytesRestResponse(RestStatus.OK, builder); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java index 8c51898cd7017..d9747f9e5d577 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestChangePasswordAction.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.security.rest.action.user; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -16,7 +17,6 @@ import org.elasticsearch.rest.action.RestBuilderListener; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.SecurityContext; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordResponse; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.client.SecurityClient; import org.elasticsearch.rest.RestRequestFilter; @@ -83,9 +83,9 @@ public RestChannelConsumer innerPrepareRequest(RestRequest request, NodeClient c new SecurityClient(client) .prepareChangePassword(username, request.requiredContent(), request.getXContentType(), passwordHasher) .setRefreshPolicy(refresh) - .execute(new RestBuilderListener(channel) { + .execute(new RestBuilderListener(channel) { @Override - public RestResponse buildResponse(ChangePasswordResponse changePasswordResponse, + public RestResponse buildResponse(ActionResponse.Empty changePasswordResponse, XContentBuilder builder) throws Exception { return new BytesRestResponse(RestStatus.OK, builder.startObject().endObject()); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java index 4b953b7856c13..6194eab4b26fd 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/rest/action/user/RestSetEnabledAction.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.security.rest.action.user; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentBuilder; @@ -14,7 +15,6 @@ import org.elasticsearch.rest.RestResponse; import org.elasticsearch.rest.RestStatus; import org.elasticsearch.rest.action.RestBuilderListener; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledResponse; import org.elasticsearch.xpack.core.security.client.SecurityClient; import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler; @@ -68,9 +68,9 @@ public RestChannelConsumer innerPrepareRequest(RestRequest request, NodeClient c assert enabled || request.path().endsWith("_disable"); final String username = request.param("username"); return channel -> new SecurityClient(client).prepareSetEnabled(username, enabled) - .execute(new RestBuilderListener(channel) { + .execute(new RestBuilderListener(channel) { @Override - public RestResponse buildResponse(SetEnabledResponse setEnabledResponse, XContentBuilder builder) throws Exception { + public RestResponse buildResponse(ActionResponse.Empty setEnabledResponse, XContentBuilder builder) throws Exception { return new BytesRestResponse(RestStatus.OK, builder.startObject().endObject()); } }); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java index aabaa40381f69..ed11c83bf7a62 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordActionTests.java @@ -7,6 +7,7 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.tasks.Task; @@ -16,7 +17,6 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.XPackSettings; import org.elasticsearch.xpack.core.security.action.user.ChangePasswordRequest; -import org.elasticsearch.xpack.core.security.action.user.ChangePasswordResponse; import org.elasticsearch.xpack.core.security.authc.support.Hasher; import org.elasticsearch.xpack.core.security.user.AnonymousUser; import org.elasticsearch.xpack.core.security.user.ElasticUser; @@ -63,10 +63,10 @@ public void testAnonymousUser() { request.passwordHash(Hasher.resolve(hashingAlgorithm).hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(ChangePasswordResponse changePasswordResponse) { + public void onResponse(ActionResponse.Empty changePasswordResponse) { responseRef.set(changePasswordResponse); } @@ -97,10 +97,10 @@ public void testInternalUsers() { request.passwordHash(Hasher.resolve(hashingAlgorithm).hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(ChangePasswordResponse changePasswordResponse) { + public void onResponse(ActionResponse.Empty changePasswordResponse) { responseRef.set(changePasswordResponse); } @@ -138,10 +138,10 @@ public void testValidUser() { TransportChangePasswordAction action = new TransportChangePasswordAction(passwordHashingSettings, transportService, mock(ActionFilters.class), usersStore); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(ChangePasswordResponse changePasswordResponse) { + public void onResponse(ActionResponse.Empty changePasswordResponse) { responseRef.set(changePasswordResponse); } @@ -152,7 +152,7 @@ public void onFailure(Exception e) { }); assertThat(responseRef.get(), is(notNullValue())); - assertThat(responseRef.get(), instanceOf(ChangePasswordResponse.class)); + assertSame(responseRef.get(), ActionResponse.Empty.INSTANCE); assertThat(throwableRef.get(), is(nullValue())); verify(usersStore, times(1)).changePassword(eq(request), any(ActionListener.class)); } @@ -165,16 +165,16 @@ public void testIncorrectPasswordHashingAlgorithm() { request.username(user.principal()); request.passwordHash(hasher.hash(SecuritySettingsSourceField.TEST_PASSWORD_SECURE_STRING)); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); + final AtomicReference responseRef = new AtomicReference<>(); TransportService transportService = new TransportService(Settings.EMPTY, mock(Transport.class), null, TransportService.NOOP_TRANSPORT_INTERCEPTOR, x -> null, null, Collections.emptySet()); Settings passwordHashingSettings = Settings.builder().put(XPackSettings.PASSWORD_HASHING_ALGORITHM.getKey(), randomFrom("pbkdf2_50000", "pbkdf2_100000", "bcrypt11", "bcrypt8", "bcrypt")).build(); TransportChangePasswordAction action = new TransportChangePasswordAction(passwordHashingSettings, transportService, mock(ActionFilters.class), usersStore); - action.doExecute(mock(Task.class), request, new ActionListener() { + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(ChangePasswordResponse changePasswordResponse) { + public void onResponse(ActionResponse.Empty changePasswordResponse) { responseRef.set(changePasswordResponse); } @@ -214,10 +214,10 @@ public Void answer(InvocationOnMock invocation) { TransportChangePasswordAction action = new TransportChangePasswordAction(passwordHashingSettings, transportService, mock(ActionFilters.class), usersStore); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(ChangePasswordResponse changePasswordResponse) { + public void onResponse(ActionResponse.Empty changePasswordResponse) { responseRef.set(changePasswordResponse); } diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java index 3fc6d40c999fc..9a557a7f91039 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledActionTests.java @@ -7,6 +7,7 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.action.ActionListener; +import org.elasticsearch.action.ActionResponse; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.common.settings.Settings; @@ -18,7 +19,6 @@ import org.elasticsearch.transport.TransportService; import org.elasticsearch.xpack.core.security.SecurityContext; import org.elasticsearch.xpack.core.security.action.user.SetEnabledRequest; -import org.elasticsearch.xpack.core.security.action.user.SetEnabledResponse; import org.elasticsearch.xpack.core.security.authc.Authentication; import org.elasticsearch.xpack.core.security.authc.support.AuthenticationContextSerializer; import org.elasticsearch.xpack.core.security.user.AnonymousUser; @@ -77,10 +77,10 @@ public void testAnonymousUser() throws Exception { request.enabled(randomBoolean()); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(SetEnabledResponse setEnabledResponse) { + public void onResponse(ActionResponse.Empty setEnabledResponse) { responseRef.set(setEnabledResponse); } @@ -119,10 +119,10 @@ public void testInternalUser() throws Exception { request.enabled(randomBoolean()); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(SetEnabledResponse setEnabledResponse) { + public void onResponse(ActionResponse.Empty setEnabledResponse) { responseRef.set(setEnabledResponse); } @@ -172,10 +172,10 @@ public Void answer(InvocationOnMock invocation) { mock(ActionFilters.class), securityContext, usersStore); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(SetEnabledResponse setEnabledResponse) { + public void onResponse(ActionResponse.Empty setEnabledResponse) { responseRef.set(setEnabledResponse); } @@ -186,7 +186,7 @@ public void onFailure(Exception e) { }); assertThat(responseRef.get(), is(notNullValue())); - assertThat(responseRef.get(), instanceOf(SetEnabledResponse.class)); + assertSame(responseRef.get(), ActionResponse.Empty.INSTANCE); assertThat(throwableRef.get(), is(nullValue())); verify(usersStore, times(1)) .setEnabled(eq(user.principal()), eq(request.enabled()), eq(request.getRefreshPolicy()), any(ActionListener.class)); @@ -227,10 +227,10 @@ public Void answer(InvocationOnMock invocation) { mock(ActionFilters.class), securityContext, usersStore); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(SetEnabledResponse setEnabledResponse) { + public void onResponse(ActionResponse.Empty setEnabledResponse) { responseRef.set(setEnabledResponse); } @@ -270,10 +270,10 @@ public void testUserModifyingThemselves() throws Exception { mock(ActionFilters.class), securityContext, usersStore); final AtomicReference throwableRef = new AtomicReference<>(); - final AtomicReference responseRef = new AtomicReference<>(); - action.doExecute(mock(Task.class), request, new ActionListener() { + final AtomicReference responseRef = new AtomicReference<>(); + action.doExecute(mock(Task.class), request, new ActionListener() { @Override - public void onResponse(SetEnabledResponse setEnabledResponse) { + public void onResponse(ActionResponse.Empty setEnabledResponse) { responseRef.set(setEnabledResponse); }