You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/09/07 12:58:18 UTC
[servicecomb-java-chassis] branch master updated: [SCB-2680]remove some deprecated methods (#3324)
This is an automated email from the ASF dual-hosted git repository.
liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git
The following commit(s) were added to refs/heads/master by this push:
new 36e99c983 [SCB-2680]remove some deprecated methods (#3324)
36e99c983 is described below
commit 36e99c9834cba9d6dba3e39e9c65eb724cddfaa7
Author: liubao68 <bi...@qq.com>
AuthorDate: Wed Sep 7 20:58:11 2022 +0800
[SCB-2680]remove some deprecated methods (#3324)
---
.../common/rest/filter/HttpClientFilter.java | 26 +++----------
.../HttpClientFilterBeforeSendRequestExecutor.java | 2 +-
.../common/rest/filter/HttpServerFilter.java | 20 +---------
...HttpServerFilterBeforeSendResponseExecutor.java | 2 +-
.../common/rest/TestAbstractRestInvocation.java | 28 ++++++++------
.../common/rest/filter/TestHttpServerFilter.java | 15 ++++----
.../core/handler/impl/AbstractHandler.java | 30 ---------------
.../service/encrypt/filter/DecodeBodyFilter.java | 7 ++++
.../jaxrs/server/JaxrsDemoHttpServerFilter.java | 6 ++-
.../demo/signature/ServerSignature.java | 19 ++--------
.../registry/api/registry/Microservice.java | 16 --------
.../it/edge/encrypt/filter/DecodeBodyFilter.java | 7 ++++
.../it/edge/filter/CheckRawFormParamFilter.java | 7 ++++
.../client/ServiceRegistryClient.java | 22 -----------
.../client/LocalServiceRegistryClientImplTest.java | 44 ++++++----------------
.../client/http/TestServiceRegistryClientImpl.java | 34 +++++------------
.../servicecomb/swagger/invocation/Response.java | 5 ---
.../rest/client/http/DefaultHttpClientFilter.java | 7 ++++
18 files changed, 90 insertions(+), 207 deletions(-)
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilter.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilter.java
index 9fe6d1b57..3ae65ff94 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilter.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilter.java
@@ -31,32 +31,16 @@ public interface HttpClientFilter {
int getOrder();
- /**
- * callback method before send a client request.
- *
- * @Deprecated this method may be called in an event-loop thread, do not add blocking
- * methods. Implement #beforeSendRequestAsync instead.
- */
- @Deprecated
- default void beforeSendRequest(Invocation invocation, HttpServletRequestEx requestEx) {
-
- }
-
/**
* callback method before send a client request.
*/
default CompletableFuture<Void> beforeSendRequestAsync(Invocation invocation, HttpServletRequestEx requestEx) {
- CompletableFuture<Void> future = new CompletableFuture<>();
- try {
- beforeSendRequest(invocation, requestEx);
- future.complete(null);
- } catch (Throwable e) {
- future.completeExceptionally(e);
- }
- return future;
+ return CompletableFuture.completedFuture(null);
}
- // if finished, then return a none null response
- // if return a null response, then sdk will call next filter.afterReceive
+ /**
+ * @return if finished, then return a none null response<br>
+ * if return a null response, then sdk will call next filter.afterReceiveResponse
+ */
Response afterReceiveResponse(Invocation invocation, HttpServletResponseEx responseEx);
}
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilterBeforeSendRequestExecutor.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilterBeforeSendRequestExecutor.java
index eab621712..b536aeb42 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilterBeforeSendRequestExecutor.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpClientFilterBeforeSendRequestExecutor.java
@@ -53,7 +53,7 @@ public class HttpClientFilterBeforeSendRequestExecutor {
if (future == null) {
future = new CompletableFuture<>();
future.completeExceptionally(new IllegalStateException(
- "HttpClientFilter beforeSendRequestAsync can not return null, do not override it. Class="
+ "HttpClientFilter beforeSendRequestAsync can not return null. Class="
+ httpClientFilter.getClass()
.getName()));
}
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilter.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilter.java
index 639bd5531..922e90725 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilter.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilter.java
@@ -46,24 +46,6 @@ public interface HttpServerFilter {
* callback method before send a server response.
*/
default CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
- CompletableFuture<Void> future = new CompletableFuture<>();
- try {
- beforeSendResponse(invocation, responseEx);
- future.complete(null);
- } catch (Throwable e) {
- future.completeExceptionally(e);
- }
- return future;
- }
-
- /**
- * callback method before send a server response.
- *
- * @Deprecated this method may be called in an event-loop thread, do not add blocking
- * methods. Implement #beforeSendResponseAsync instead.
- */
- @Deprecated
- default void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx) {
-
+ return CompletableFuture.completedFuture(null);
}
}
diff --git a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilterBeforeSendResponseExecutor.java b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilterBeforeSendResponseExecutor.java
index 45409b368..3c3c23ef2 100644
--- a/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilterBeforeSendResponseExecutor.java
+++ b/common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/HttpServerFilterBeforeSendResponseExecutor.java
@@ -53,7 +53,7 @@ public class HttpServerFilterBeforeSendResponseExecutor {
if (future == null) {
future = new CompletableFuture<>();
future.completeExceptionally(new IllegalStateException(
- "HttpServerFilter beforeSendResponseAsync can not return null, do not override it. Class="
+ "HttpServerFilter beforeSendResponseAsync can not return null. Class="
+ httpServerFilter.getClass()
.getName()));
}
diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java
index 75728a31c..9404c6e39 100644
--- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java
+++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/TestAbstractRestInvocation.java
@@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.RejectedExecutionException;
@@ -75,15 +76,15 @@ import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
import com.google.common.eventbus.Subscribe;
import io.vertx.core.MultiMap;
import io.vertx.core.buffer.Buffer;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.mockito.MockedStatic;
-import org.mockito.Mockito;
@SuppressWarnings("deprecation")
public class TestAbstractRestInvocation {
@@ -182,8 +183,10 @@ public class TestAbstractRestInvocation {
initRestInvocation();
InvocationException exception = Assertions.assertThrows(InvocationException.class,
- () -> restInvocation.initProduceProcessor());
- Assertions.assertEquals("InvocationException: code=406;msg=CommonExceptionData [message=Accept notExistType is not supported]", exception.getMessage());
+ () -> restInvocation.initProduceProcessor());
+ Assertions.assertEquals(
+ "InvocationException: code=406;msg=CommonExceptionData [message=Accept notExistType is not supported]",
+ exception.getMessage());
}
@Test
@@ -652,8 +655,9 @@ public class TestAbstractRestInvocation {
HttpServerFilter filter = new HttpServerFilterBaseForTest() {
@Override
- public void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx) {
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
buffer.appendString("-filter");
+ return CompletableFuture.completedFuture(null);
}
};
@@ -674,9 +678,9 @@ public class TestAbstractRestInvocation {
try (MockedStatic<ServicePathManager> mockedStatic = Mockito.mockStatic(ServicePathManager.class)) {
mockedStatic.when(() -> ServicePathManager.getServicePathManager(microserviceMeta)).thenReturn(null);
InvocationException exception = Assertions.assertThrows(InvocationException.class,
- () -> restInvocation.findRestOperation(microserviceMeta));
+ () -> restInvocation.findRestOperation(microserviceMeta));
Assertions.assertEquals("InvocationException: code=404;msg=CommonExceptionData [message=Not Found]",
- exception.getMessage());
+ exception.getMessage());
}
}
@@ -698,7 +702,8 @@ public class TestAbstractRestInvocation {
};
restInvocation.requestEx = requestEx;
Map<String, String> pathVars = new HashMap<>();
- mockedStatic.when(() -> ServicePathManager.getServicePathManager(microserviceMeta)).thenReturn(servicePathManager);
+ mockedStatic.when(() -> ServicePathManager.getServicePathManager(microserviceMeta))
+ .thenReturn(servicePathManager);
Mockito.when(locator.getPathVarMap()).thenReturn(pathVars);
Mockito.when(locator.getOperation()).thenReturn(restOperation);
@@ -937,7 +942,8 @@ public class TestAbstractRestInvocation {
@Test
public void scheduleInvocation_flowControlReject() {
operationMeta = Mockito.spy(operationMeta);
- Mockito.when(operationMeta.getProviderQpsFlowControlHandler()).thenReturn((invocation, asyncResp) -> asyncResp.producerFail(new InvocationException(
+ Mockito.when(operationMeta.getProviderQpsFlowControlHandler())
+ .thenReturn((invocation, asyncResp) -> asyncResp.producerFail(new InvocationException(
new HttpStatus(429, "Too Many Requests"),
new CommonExceptionData("rejected by qps flowcontrol"))));
restOperation = Mockito.spy(restOperation);
diff --git a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java
index 37449a3dc..a27073f17 100644
--- a/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java
+++ b/common/common-rest/src/test/java/org/apache/servicecomb/common/rest/filter/TestHttpServerFilter.java
@@ -39,17 +39,18 @@ public class TestHttpServerFilter {
public void asyncFailed() throws InterruptedException, ExecutionException {
HttpServerFilter filter = new HttpServerFilterBaseForTest() {
@Override
- @SuppressWarnings("deprecation")
- public void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx) {
- throw new RuntimeExceptionWithoutStackTrace();
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
+ CompletableFuture<Void> result = new CompletableFuture<>();
+ result.completeExceptionally(new RuntimeExceptionWithoutStackTrace());
+ return result;
}
};
ExecutionException exception = Assertions.assertThrows(ExecutionException.class,
- () -> {
- CompletableFuture<Void> future = filter.beforeSendResponseAsync(null, null);
- future.get();
- });
+ () -> {
+ CompletableFuture<Void> future = filter.beforeSendResponseAsync(null, null);
+ future.get();
+ });
Assertions.assertTrue(exception.getCause() instanceof RuntimeExceptionWithoutStackTrace);
}
}
diff --git a/core/src/main/java/org/apache/servicecomb/core/handler/impl/AbstractHandler.java b/core/src/main/java/org/apache/servicecomb/core/handler/impl/AbstractHandler.java
deleted file mode 100644
index 940fd9785..000000000
--- a/core/src/main/java/org/apache/servicecomb/core/handler/impl/AbstractHandler.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.apache.servicecomb.core.handler.impl;
-
-import org.apache.servicecomb.core.Handler;
-import org.apache.servicecomb.core.definition.MicroserviceMeta;
-import org.apache.servicecomb.swagger.invocation.InvocationType;
-
-@Deprecated
-public abstract class AbstractHandler implements Handler {
- @Override
- public void init(MicroserviceMeta microserviceMeta, InvocationType invocationType) {
-
- }
-}
diff --git a/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/service/encrypt/filter/DecodeBodyFilter.java b/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/service/encrypt/filter/DecodeBodyFilter.java
index 73c533e67..07a3aba05 100644
--- a/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/service/encrypt/filter/DecodeBodyFilter.java
+++ b/demo/demo-edge/edge-service/src/main/java/org/apache/servicecomb/demo/edge/service/encrypt/filter/DecodeBodyFilter.java
@@ -17,6 +17,7 @@
package org.apache.servicecomb.demo.edge.service.encrypt.filter;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
@@ -25,6 +26,7 @@ import org.apache.servicecomb.demo.edge.authentication.encrypt.Hcr;
import org.apache.servicecomb.demo.edge.service.EdgeConst;
import org.apache.servicecomb.demo.edge.service.encrypt.EncryptContext;
import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
import org.apache.servicecomb.swagger.invocation.Response;
import com.fasterxml.jackson.databind.JavaType;
@@ -63,4 +65,9 @@ public class DecodeBodyFilter implements HttpServerFilter {
}
return null;
}
+
+ @Override
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
+ return CompletableFuture.completedFuture(null);
+ }
}
diff --git a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/JaxrsDemoHttpServerFilter.java b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/JaxrsDemoHttpServerFilter.java
index e89d3daca..726a3aeed 100644
--- a/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/JaxrsDemoHttpServerFilter.java
+++ b/demo/demo-jaxrs/jaxrs-server/src/main/java/org/apache/servicecomb/demo/jaxrs/server/JaxrsDemoHttpServerFilter.java
@@ -17,6 +17,8 @@
package org.apache.servicecomb.demo.jaxrs.server;
+import java.util.concurrent.CompletableFuture;
+
import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
@@ -39,9 +41,9 @@ public class JaxrsDemoHttpServerFilter implements HttpServerFilter {
}
@Override
- @SuppressWarnings("deprecation")
- public void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx) {
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
// in 404 situation, invocation is null and a NPE is thrown
LOGGER.info("JaxrsDemoHttpServerFilter is called, operation=[{}]", invocation.getOperationName());
+ return CompletableFuture.completedFuture(null);
}
}
diff --git a/demo/demo-signature/src/main/java/org/apache/servicecomb/demo/signature/ServerSignature.java b/demo/demo-signature/src/main/java/org/apache/servicecomb/demo/signature/ServerSignature.java
index 1b623c35c..b39b60371 100644
--- a/demo/demo-signature/src/main/java/org/apache/servicecomb/demo/signature/ServerSignature.java
+++ b/demo/demo-signature/src/main/java/org/apache/servicecomb/demo/signature/ServerSignature.java
@@ -17,18 +17,16 @@
package org.apache.servicecomb.demo.signature;
+import java.util.concurrent.CompletableFuture;
+
import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.definition.OperationMeta;
import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
import org.apache.servicecomb.swagger.invocation.Response;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class ServerSignature implements HttpServerFilter {
- private static final Logger LOGGER = LoggerFactory.getLogger(ServerSignature.class);
-
public ServerSignature() {
}
@@ -44,22 +42,13 @@ public class ServerSignature implements HttpServerFilter {
@Override
public Response afterReceiveRequest(Invocation invocation, HttpServletRequestEx requestEx) {
-// String signature = SignatureUtils.genSignature(requestEx);
-// String clientSignature = requestEx.getHeader("signature");
-// LOGGER.debug("check request signature, client: {}, server: {}.", clientSignature, signature);
-// if (!signature.equals(clientSignature)) {
-// LOGGER.error("check request signature failed: {}", invocation.getInvocationQualifiedName());
-// return Response
-// .create(Status.UNAUTHORIZED, "check request signature failed: " + invocation.getInvocationQualifiedName());
-// }
-
return null;
}
@Override
- @SuppressWarnings("deprecation")
- public void beforeSendResponse(Invocation invocation, HttpServletResponseEx responseEx) {
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
String signature = SignatureUtils.genSignature(responseEx);
responseEx.addHeader("signature", signature);
+ return CompletableFuture.completedFuture(null);
}
}
diff --git a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/Microservice.java b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/Microservice.java
index fa28a02b8..bd7719193 100644
--- a/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/Microservice.java
+++ b/foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/api/registry/Microservice.java
@@ -92,26 +92,10 @@ public class Microservice {
return instance;
}
- /**
- * @deprecated Replace by {@link #getInstance()}
- */
- @Deprecated
- public MicroserviceInstance getIntance() {
- return getInstance();
- }
-
public void setInstance(MicroserviceInstance instance) {
this.instance = instance;
}
- /**
- * @deprecated Replace by {@link #setInstance(MicroserviceInstance)}
- */
- @Deprecated
- public void setIntance(MicroserviceInstance instance) {
- setInstance(instance);
- }
-
public String getServiceId() {
return serviceId;
}
diff --git a/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/encrypt/filter/DecodeBodyFilter.java b/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/encrypt/filter/DecodeBodyFilter.java
index 00f3974bd..aad7f7137 100644
--- a/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/encrypt/filter/DecodeBodyFilter.java
+++ b/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/encrypt/filter/DecodeBodyFilter.java
@@ -17,11 +17,13 @@
package org.apache.servicecomb.it.edge.encrypt.filter;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
import org.apache.servicecomb.it.authentication.encrypt.Hcr;
import org.apache.servicecomb.it.edge.EdgeConst;
import org.apache.servicecomb.it.edge.encrypt.EncryptContext;
@@ -63,4 +65,9 @@ public class DecodeBodyFilter implements HttpServerFilter {
}
return null;
}
+
+ @Override
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
+ return CompletableFuture.completedFuture(null);
+ }
}
diff --git a/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/filter/CheckRawFormParamFilter.java b/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/filter/CheckRawFormParamFilter.java
index e4ff4dc07..cc978e351 100644
--- a/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/filter/CheckRawFormParamFilter.java
+++ b/integration-tests/it-edge/src/main/java/org/apache/servicecomb/it/edge/filter/CheckRawFormParamFilter.java
@@ -18,12 +18,14 @@
package org.apache.servicecomb.it.edge.filter;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import javax.ws.rs.core.Response.Status;
import org.apache.servicecomb.common.rest.filter.HttpServerFilter;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
@@ -51,6 +53,11 @@ public class CheckRawFormParamFilter implements HttpServerFilter {
return checkRequestType((Map<Object, Object>) swaggerArgument);
}
+ @Override
+ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, HttpServletResponseEx responseEx) {
+ return CompletableFuture.completedFuture(null);
+ }
+
private Response checkRequestType(Map<Object, Object> swaggerArgument) {
final Object valueA = swaggerArgument.get("A");
if (null != valueA && !(valueA instanceof String)) {
diff --git a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/ServiceRegistryClient.java b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/ServiceRegistryClient.java
index 902a10719..eca2f8d68 100644
--- a/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/ServiceRegistryClient.java
+++ b/service-registry/registry-service-center/src/main/java/org/apache/servicecomb/serviceregistry/client/ServiceRegistryClient.java
@@ -163,8 +163,6 @@ public interface ServiceRegistryClient {
/**
* 通过serviceId, instanceId 获取instance对象。
- * @param serviceId
- * @param instanceId
* @return MicroserviceInstance
*/
MicroserviceInstance findServiceInstance(String serviceId, String instanceId);
@@ -174,26 +172,6 @@ public interface ServiceRegistryClient {
*/
ServiceCenterInfo getServiceCenterInfo();
- /**
- * 修改微服务实例状态
- * @param microserviceId
- * @param microserviceInstanceId
- * @return
- * @deprecated use {@link #updateMicroserviceInstanceStatus(String, String, MicroserviceInstanceStatus)} instead
- */
- @Deprecated
- default boolean undateMicroserviceInstanceStatus(String microserviceId, String microserviceInstanceId,
- String status) {
- MicroserviceInstanceStatus instanceStatus;
- try {
- instanceStatus = MicroserviceInstanceStatus.valueOf(status);
- } catch (IllegalArgumentException e) {
- throw new IllegalArgumentException("Invalid status: " + status);
- }
-
- return updateMicroserviceInstanceStatus(microserviceId, microserviceInstanceId, instanceStatus);
- }
-
/**
* Update the instance status registered in service center.
* @param microserviceId the microserviceId of the instance
diff --git a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java
index 75ed926f4..a3ebcd311 100644
--- a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java
+++ b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/LocalServiceRegistryClientImplTest.java
@@ -23,11 +23,11 @@ import java.util.List;
import org.apache.servicecomb.registry.api.registry.Microservice;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstanceStatus;
+import org.apache.servicecomb.registry.api.registry.MicroserviceInstances;
+import org.apache.servicecomb.registry.definition.DefinitionConst;
import org.apache.servicecomb.serviceregistry.api.registry.ServiceCenterInfo;
import org.apache.servicecomb.serviceregistry.api.response.GetSchemaResponse;
import org.apache.servicecomb.serviceregistry.client.http.Holder;
-import org.apache.servicecomb.registry.api.registry.MicroserviceInstances;
-import org.apache.servicecomb.registry.definition.DefinitionConst;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.Is;
@@ -153,7 +153,8 @@ public class LocalServiceRegistryClientImplTest {
public void registerSchema_microserviceNotExist() {
mockRegisterMicroservice(appId, microserviceName, "1.0.0");
- IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class, () -> registryClient.registerSchema("notExist", "sid", "content"));
+ IllegalArgumentException exception = Assertions.assertThrows(IllegalArgumentException.class,
+ () -> registryClient.registerSchema("notExist", "sid", "content"));
Assertions.assertEquals("Invalid serviceId, serviceId=notExist", exception.getMessage());
}
@@ -193,16 +194,16 @@ public class LocalServiceRegistryClientImplTest {
Assertions.assertTrue(microservice.getSchemas().contains("hello"));
}
- @SuppressWarnings("deprecation")
@Test
- public void undateMicroserviceInstanceStatus() {
+ public void updateMicroserviceInstanceStatus() {
List<MicroserviceInstance> m = registryClient
.findServiceInstance("", "default", "ms2", DefinitionConst.VERSION_RULE_ALL);
MicroserviceInstance instance = m.get(0);
Assertions.assertEquals(MicroserviceInstanceStatus.UP, instance.getStatus());
boolean updateOperationResult = registryClient
- .undateMicroserviceInstanceStatus(instance.getServiceId(), instance.getInstanceId(), "TESTING");
+ .updateMicroserviceInstanceStatus(instance.getServiceId(), instance.getInstanceId(),
+ MicroserviceInstanceStatus.TESTING);
Assertions.assertTrue(updateOperationResult);
m = registryClient
@@ -211,18 +212,19 @@ public class LocalServiceRegistryClientImplTest {
Assertions.assertEquals(MicroserviceInstanceStatus.TESTING, instance.getStatus());
}
- @SuppressWarnings("deprecation")
@Test
- public void undateMicroserviceInstanceStatus_instance_not_found() {
+ public void updateMicroserviceInstanceStatus_instance_not_found() {
try {
- registryClient.undateMicroserviceInstanceStatus("msIdNotExist", "", "UP");
+ registryClient.updateMicroserviceInstanceStatus
+ ("msIdNotExist", "", MicroserviceInstanceStatus.UP);
shouldThrowException();
} catch (IllegalArgumentException e) {
Assertions.assertEquals("Invalid serviceId, serviceId=msIdNotExist", e.getMessage());
}
try {
- registryClient.undateMicroserviceInstanceStatus("002", "instanceIdNotExist", "UP");
+ registryClient.updateMicroserviceInstanceStatus
+ ("002", "instanceIdNotExist", MicroserviceInstanceStatus.UP);
shouldThrowException();
} catch (IllegalArgumentException e) {
Assertions.assertEquals("Invalid argument. microserviceId=002, instanceId=instanceIdNotExist.",
@@ -230,28 +232,6 @@ public class LocalServiceRegistryClientImplTest {
}
}
- @SuppressWarnings("deprecation")
- @Test
- public void undateMicroserviceInstanceStatus_illegal_status() {
- List<MicroserviceInstance> m = registryClient
- .findServiceInstance("", "default", "ms2", DefinitionConst.VERSION_RULE_ALL);
- MicroserviceInstance instance = m.get(0);
-
- try {
- registryClient.undateMicroserviceInstanceStatus(instance.getServiceId(), instance.getInstanceId(), null);
- shouldThrowException();
- } catch (NullPointerException e) {
- Assertions.assertEquals("Name is null", e.getMessage());
- }
- try {
- registryClient
- .undateMicroserviceInstanceStatus(instance.getServiceId(), instance.getInstanceId(), "IllegalStatus");
- shouldThrowException();
- } catch (IllegalArgumentException e) {
- Assertions.assertEquals("Invalid status: IllegalStatus", e.getMessage());
- }
- }
-
private void shouldThrowException() {
Assertions.fail("an exception is expected");
}
diff --git a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java
index 2b552cf74..77f69c908 100644
--- a/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java
+++ b/service-registry/registry-service-center/src/test/java/org/apache/servicecomb/serviceregistry/client/http/TestServiceRegistryClientImpl.java
@@ -37,6 +37,7 @@ import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
import org.apache.servicecomb.foundation.vertx.client.http.HttpClients;
import org.apache.servicecomb.registry.api.registry.Microservice;
import org.apache.servicecomb.registry.api.registry.MicroserviceFactory;
+import org.apache.servicecomb.registry.api.registry.MicroserviceInstanceStatus;
import org.apache.servicecomb.registry.api.registry.MicroserviceInstances;
import org.apache.servicecomb.registry.definition.DefinitionConst;
import org.apache.servicecomb.serviceregistry.RegistryUtils;
@@ -121,7 +122,8 @@ public class TestServiceRegistryClientImpl {
Assertions.assertFalse(oClient.unregisterMicroserviceInstance("microserviceId", "microserviceInstanceId"));
Assertions.assertNull(oClient.heartbeat("microserviceId", "microserviceInstanceId"));
Assertions.assertNull(oClient.findServiceInstance("selfMicroserviceId", "appId", "serviceName", "versionRule"));
- Assertions.assertNull(oClient.findServiceInstances("selfMicroserviceId", "appId", "serviceName", "versionRule", "0"));
+ Assertions.assertNull(
+ oClient.findServiceInstances("selfMicroserviceId", "appId", "serviceName", "versionRule", "0"));
Assertions.assertEquals("a", new ClientException("a").getMessage());
@@ -540,9 +542,8 @@ public class TestServiceRegistryClientImpl {
}.run();
}
- @SuppressWarnings("deprecation")
@Test
- public void undateMicroserviceInstanceStatus() {
+ public void updateMicroserviceInstanceStatus() {
HttpClientResponse httpClientResponse = new MockUp<HttpClientResponse>() {
@Mock
int statusCode() {
@@ -557,13 +558,13 @@ public class TestServiceRegistryClientImpl {
}
};
- boolean result = oClient.undateMicroserviceInstanceStatus("svcId", "instanceId", "UP");
+ boolean result = oClient.updateMicroserviceInstanceStatus
+ ("svcId", "instanceId", MicroserviceInstanceStatus.UP);
Assertions.assertTrue(result);
}
- @SuppressWarnings("deprecation")
@Test
- public void undateMicroserviceInstanceStatus_response_failure() {
+ public void updateMicroserviceInstanceStatus_response_failure() {
HttpClientResponse httpClientResponse = new MockUp<HttpClientResponse>() {
@Mock
int statusCode() {
@@ -578,28 +579,11 @@ public class TestServiceRegistryClientImpl {
}
};
- boolean result = oClient.undateMicroserviceInstanceStatus("svcId", "instanceId", "UP");
+ boolean result = oClient.updateMicroserviceInstanceStatus
+ ("svcId", "instanceId", MicroserviceInstanceStatus.UP);
Assertions.assertFalse(result);
}
- @SuppressWarnings("deprecation")
- @Test
- public void undateMicroserviceInstanceStatus_illegal_status() {
- try {
- oClient.undateMicroserviceInstanceStatus("svcId", "instanceId", null);
- shouldThrowException();
- } catch (NullPointerException e) {
- Assertions.assertEquals("Name is null", e.getMessage());
- }
- try {
- oClient
- .undateMicroserviceInstanceStatus("svcId", "instanceId", "IllegalStatus");
- shouldThrowException();
- } catch (IllegalArgumentException e) {
- Assertions.assertEquals("Invalid status: IllegalStatus", e.getMessage());
- }
- }
-
private void shouldThrowException() {
Assertions.fail("an exception is expected");
}
diff --git a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/Response.java b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/Response.java
index 9544bc7d4..5b696db2c 100644
--- a/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/Response.java
+++ b/swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/Response.java
@@ -46,11 +46,6 @@ public class Response {
return HttpStatus.isSuccess(status);
}
- @Deprecated
- public boolean isSuccessed() {
- return isSucceed();
- }
-
public boolean isFailed() {
return !isSucceed();
}
diff --git a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/DefaultHttpClientFilter.java b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/DefaultHttpClientFilter.java
index 30cc9b74d..9e9c7d7ce 100644
--- a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/DefaultHttpClientFilter.java
+++ b/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/DefaultHttpClientFilter.java
@@ -18,6 +18,7 @@
package org.apache.servicecomb.transport.rest.client.http;
import java.util.Collection;
+import java.util.concurrent.CompletableFuture;
import javax.ws.rs.core.HttpHeaders;
@@ -28,6 +29,7 @@ import org.apache.servicecomb.common.rest.definition.RestOperationMeta;
import org.apache.servicecomb.common.rest.filter.HttpClientFilter;
import org.apache.servicecomb.core.Invocation;
import org.apache.servicecomb.core.definition.OperationMeta;
+import org.apache.servicecomb.foundation.vertx.http.HttpServletRequestEx;
import org.apache.servicecomb.foundation.vertx.http.HttpServletResponseEx;
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.context.HttpStatus;
@@ -50,6 +52,11 @@ public class DefaultHttpClientFilter implements HttpClientFilter {
return 10000;
}
+ @Override
+ public CompletableFuture<Void> beforeSendRequestAsync(Invocation invocation, HttpServletRequestEx requestEx) {
+ return CompletableFuture.completedFuture(null);
+ }
+
@Override
public boolean enabled() {
return enabled;