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 a4468c470 [SCB-2888]support configuring operation transport (#4413)
a4468c470 is described below
commit a4468c4701c653f4a9ccacd7095af73f144bb7b8
Author: liubao68 <[email protected]>
AuthorDate: Mon Jul 15 14:05:09 2024 +0800
[SCB-2888]support configuring operation transport (#4413)
---
core/pom.xml | 4 ++
.../org/apache/servicecomb/core/CoreConst.java | 2 +
.../org/apache/servicecomb/core/Invocation.java | 15 ++++++
.../servicecomb/core/annotation/Transport.java | 42 +++++++++++++++++
.../core/filter/impl/ProviderOperationFilter.java | 15 ++++++
.../TransportClassAnnotationProcessor.java | 43 +++++++++++++++++
.../TransportMethodAnnotationProcessor.java | 44 +++++++++++++++++
...comb.swagger.generator.ClassAnnotationProcessor | 18 +++++++
...omb.swagger.generator.MethodAnnotationProcessor | 18 +++++++
.../demo/springmvc/client/TestDateTimeSchema.java | 10 ----
.../springmvc/client/TestMaxHttpUrlLength.java | 10 ----
.../demo/springmvc/client/TestTransportSchema.java | 55 ++++++++++++++++++++++
.../demo/springmvc/client/TestWeakSpringmvc.java | 10 ----
.../demo/springmvc/server/TransportSchema.java | 42 +++++++++++++++++
.../samples/ConsumerReactiveStreamController.java | 4 ++
.../consumer/src/main/resources/application.yml | 3 ++
.../samples/ReactiveStreamController.java | 3 ++
.../provider/src/main/resources/application.yml | 3 ++
.../loadbalance/TestLoadBalanceFilter2.java | 21 +++++++++
19 files changed, 332 insertions(+), 30 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index 68cdb6aa4..63245883d 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -40,6 +40,10 @@
<groupId>org.apache.servicecomb</groupId>
<artifactId>swagger-invocation-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.servicecomb</groupId>
+ <artifactId>swagger-generator-core</artifactId>
+ </dependency>
<dependency>
<groupId>io.zipkin.brave</groupId>
<artifactId>brave</artifactId>
diff --git a/core/src/main/java/org/apache/servicecomb/core/CoreConst.java
b/core/src/main/java/org/apache/servicecomb/core/CoreConst.java
index 651f06c4a..dfe2aeebf 100644
--- a/core/src/main/java/org/apache/servicecomb/core/CoreConst.java
+++ b/core/src/main/java/org/apache/servicecomb/core/CoreConst.java
@@ -25,6 +25,8 @@ public final class CoreConst {
public static final String CSE_CONTEXT = "x-cse-context";
+ public static final String TRANSPORT_NAME = "x-transport-name";
+
public static final String RESTFUL = "rest";
public static final String HIGHWAY = "highway";
diff --git a/core/src/main/java/org/apache/servicecomb/core/Invocation.java
b/core/src/main/java/org/apache/servicecomb/core/Invocation.java
index 08628a209..6bb007039 100644
--- a/core/src/main/java/org/apache/servicecomb/core/Invocation.java
+++ b/core/src/main/java/org/apache/servicecomb/core/Invocation.java
@@ -253,7 +253,22 @@ public class Invocation extends SwaggerInvocation {
return operationMeta.getOperationId();
}
+ public String getProviderTransportName() {
+ if (operationMeta.getSwaggerOperation().getExtensions() != null &&
+
operationMeta.getSwaggerOperation().getExtensions().get(CoreConst.TRANSPORT_NAME)
!= null) {
+ return (String)
operationMeta.getSwaggerOperation().getExtensions().get(CoreConst.TRANSPORT_NAME);
+ }
+ if (schemaMeta.getSwagger().getExtensions() != null &&
+ schemaMeta.getSwagger().getExtensions().get(CoreConst.TRANSPORT_NAME)
!= null) {
+ return (String)
schemaMeta.getSwagger().getExtensions().get(CoreConst.TRANSPORT_NAME);
+ }
+ return null;
+ }
+
public String getConfigTransportName() {
+ if (getProviderTransportName() != null) {
+ return getProviderTransportName();
+ }
return referenceConfig.getTransport();
}
diff --git
a/core/src/main/java/org/apache/servicecomb/core/annotation/Transport.java
b/core/src/main/java/org/apache/servicecomb/core/annotation/Transport.java
new file mode 100644
index 000000000..c81055c7b
--- /dev/null
+++ b/core/src/main/java/org/apache/servicecomb/core/annotation/Transport.java
@@ -0,0 +1,42 @@
+/*
+ * 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.annotation;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.springframework.stereotype.Component;
+
+@Inherited
+@Documented
+@Retention(RUNTIME)
+@Target({TYPE, METHOD, ANNOTATION_TYPE})
+@Component
+public @interface Transport {
+ /**
+ * Transport name. e.g. rest, highway.
+ */
+ String name();
+}
diff --git
a/core/src/main/java/org/apache/servicecomb/core/filter/impl/ProviderOperationFilter.java
b/core/src/main/java/org/apache/servicecomb/core/filter/impl/ProviderOperationFilter.java
index 66f95ff76..c8f757bf3 100644
---
a/core/src/main/java/org/apache/servicecomb/core/filter/impl/ProviderOperationFilter.java
+++
b/core/src/main/java/org/apache/servicecomb/core/filter/impl/ProviderOperationFilter.java
@@ -29,6 +29,10 @@ import
org.apache.servicecomb.foundation.common.utils.AsyncUtils;
import org.apache.servicecomb.swagger.engine.SwaggerProducerOperation;
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.context.ContextUtils;
+import org.apache.servicecomb.swagger.invocation.exception.CommonExceptionData;
+import org.apache.servicecomb.swagger.invocation.exception.InvocationException;
+
+import jakarta.ws.rs.core.Response.Status;
public class ProviderOperationFilter extends AbstractFilter implements
ProviderFilter {
public static final String NAME = "producer-operation";
@@ -46,6 +50,10 @@ public class ProviderOperationFilter extends AbstractFilter
implements ProviderF
@Override
public CompletableFuture<Response> onFilter(Invocation invocation,
FilterNode nextNode) {
+ if (!transportAccessAllowed(invocation)) {
+ return CompletableFuture.failedFuture(new
InvocationException(Status.UNAUTHORIZED,
+ new CommonExceptionData("transport access not allowed.")));
+ }
invocation.onBusinessMethodStart();
SwaggerProducerOperation producerOperation =
invocation.getOperationMeta().getSwaggerProducerOperation();
@@ -57,6 +65,13 @@ public class ProviderOperationFilter extends AbstractFilter
implements ProviderF
.whenComplete((response, throwable) -> processMetrics(invocation));
}
+ private boolean transportAccessAllowed(Invocation invocation) {
+ if (invocation.getProviderTransportName() == null) {
+ return true;
+ }
+ return
invocation.getProviderTransportName().equals(invocation.getTransportName());
+ }
+
@SuppressWarnings("unchecked")
protected CompletableFuture<Object> invoke(Invocation invocation, Object
instance, Method method, Object[] args) {
ContextUtils.setInvocationContext(invocation);
diff --git
a/core/src/main/java/org/apache/servicecomb/core/transport/TransportClassAnnotationProcessor.java
b/core/src/main/java/org/apache/servicecomb/core/transport/TransportClassAnnotationProcessor.java
new file mode 100644
index 000000000..5af6705ab
--- /dev/null
+++
b/core/src/main/java/org/apache/servicecomb/core/transport/TransportClassAnnotationProcessor.java
@@ -0,0 +1,43 @@
+/*
+ * 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.transport;
+
+import java.lang.reflect.Type;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.core.CoreConst;
+import org.apache.servicecomb.core.annotation.Transport;
+import org.apache.servicecomb.swagger.generator.ClassAnnotationProcessor;
+import org.apache.servicecomb.swagger.generator.SwaggerGenerator;
+
+import io.swagger.v3.oas.models.OpenAPI;
+
+public class TransportClassAnnotationProcessor implements
ClassAnnotationProcessor<Transport> {
+ @Override
+ public Type getProcessType() {
+ return Transport.class;
+ }
+
+ @Override
+ public void process(SwaggerGenerator swaggerGenerator, Transport transport) {
+ OpenAPI swagger = swaggerGenerator.getOpenAPI();
+ if (StringUtils.isNotEmpty(transport.name())) {
+ swagger.addExtension(CoreConst.TRANSPORT_NAME, transport.name());
+ }
+ }
+}
diff --git
a/core/src/main/java/org/apache/servicecomb/core/transport/TransportMethodAnnotationProcessor.java
b/core/src/main/java/org/apache/servicecomb/core/transport/TransportMethodAnnotationProcessor.java
new file mode 100644
index 000000000..617f4b87d
--- /dev/null
+++
b/core/src/main/java/org/apache/servicecomb/core/transport/TransportMethodAnnotationProcessor.java
@@ -0,0 +1,44 @@
+/*
+ * 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.transport;
+
+import java.lang.reflect.Type;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.servicecomb.core.CoreConst;
+import org.apache.servicecomb.core.annotation.Transport;
+import org.apache.servicecomb.swagger.generator.MethodAnnotationProcessor;
+import org.apache.servicecomb.swagger.generator.OperationGenerator;
+import org.apache.servicecomb.swagger.generator.SwaggerGenerator;
+
+import io.swagger.v3.oas.models.Operation;
+
+public class TransportMethodAnnotationProcessor implements
MethodAnnotationProcessor<Transport> {
+ @Override
+ public Type getProcessType() {
+ return Transport.class;
+ }
+
+ @Override
+ public void process(SwaggerGenerator swaggerGenerator, OperationGenerator
operationGenerator, Transport transport) {
+ Operation operation = operationGenerator.getOperation();
+ if (StringUtils.isNotEmpty(transport.name())) {
+ operation.addExtension(CoreConst.TRANSPORT_NAME, transport.name());
+ }
+ }
+}
diff --git
a/core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ClassAnnotationProcessor
b/core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ClassAnnotationProcessor
new file mode 100644
index 000000000..57d906d81
--- /dev/null
+++
b/core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.ClassAnnotationProcessor
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.core.transport.TransportClassAnnotationProcessor
diff --git
a/core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.MethodAnnotationProcessor
b/core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.MethodAnnotationProcessor
new file mode 100644
index 000000000..a003fcbd2
--- /dev/null
+++
b/core/src/main/resources/META-INF/services/org.apache.servicecomb.swagger.generator.MethodAnnotationProcessor
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.servicecomb.core.transport.TransportMethodAnnotationProcessor
diff --git
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDateTimeSchema.java
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDateTimeSchema.java
index df6325490..909c19068 100644
---
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDateTimeSchema.java
+++
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestDateTimeSchema.java
@@ -95,16 +95,6 @@ public class TestDateTimeSchema implements
CategorizedTestCase {
}
- @Override
- public void testRestTransport() throws Exception {
-
- }
-
- @Override
- public void testHighwayTransport() throws Exception {
-
- }
-
@Override
public void testAllTransport() throws Exception {
testDateTimeSchema();
diff --git
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
index 5d3422ace..08f9cdda1 100644
---
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
+++
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestMaxHttpUrlLength.java
@@ -54,14 +54,4 @@ public class TestMaxHttpUrlLength implements
CategorizedTestCase {
TestMgr.check(REQUEST_URI_TOO_LONG.getStatusCode(), e.getStatusCode());
}
}
-
- @Override
- public void testHighwayTransport() throws Exception {
-
- }
-
- @Override
- public void testAllTransport() throws Exception {
-
- }
}
diff --git
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestTransportSchema.java
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestTransportSchema.java
new file mode 100644
index 000000000..d818ed439
--- /dev/null
+++
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestTransportSchema.java
@@ -0,0 +1,55 @@
+/*
+ * 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.demo.springmvc.client;
+
+import org.apache.servicecomb.demo.CategorizedTestCase;
+import org.apache.servicecomb.demo.TestMgr;
+import org.apache.servicecomb.provider.pojo.RpcReference;
+import org.springframework.stereotype.Component;
+
+@Component
+public class TestTransportSchema implements CategorizedTestCase {
+ interface TransportClient {
+ boolean restTransport();
+
+ boolean highwayTransport();
+ }
+
+ @RpcReference(microserviceName = "springmvc", schemaId = "TransportSchema")
+ private TransportClient transportClient;
+
+ @Override
+ public void testRestTransport() throws Exception {
+ testTransportSchema();
+ }
+
+ @Override
+ public void testHighwayTransport() throws Exception {
+ testTransportSchema();
+ }
+
+ @Override
+ public void testAllTransport() throws Exception {
+ testTransportSchema();
+ }
+
+ private void testTransportSchema() {
+ TestMgr.check(true, transportClient.highwayTransport());
+ TestMgr.check(true, transportClient.restTransport());
+ }
+}
diff --git
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
index b6d6e7680..67d1931e1 100644
---
a/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
+++
b/demo/demo-springmvc/springmvc-client/src/main/java/org/apache/servicecomb/demo/springmvc/client/TestWeakSpringmvc.java
@@ -120,16 +120,6 @@ public class TestWeakSpringmvc implements
CategorizedTestCase {
private RestOperations restTemplate = RestTemplateBuilder.create();
- @Override
- public void testRestTransport() throws Exception {
-
- }
-
- @Override
- public void testHighwayTransport() throws Exception {
-
- }
-
@Override
public void testAllTransport() throws Exception {
testDiffName();
diff --git
a/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/TransportSchema.java
b/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/TransportSchema.java
new file mode 100644
index 000000000..158cd8061
--- /dev/null
+++
b/demo/demo-springmvc/springmvc-server/src/main/java/org/apache/servicecomb/demo/springmvc/server/TransportSchema.java
@@ -0,0 +1,42 @@
+/*
+ * 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.demo.springmvc.server;
+
+import org.apache.servicecomb.core.CoreConst;
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.core.annotation.Transport;
+import org.apache.servicecomb.provider.rest.common.RestSchema;
+import org.apache.servicecomb.swagger.invocation.context.InvocationContext;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+@RestSchema(schemaId = "TransportSchema")
+@RequestMapping(path = "/transport")
+public class TransportSchema {
+ @GetMapping(path = "/restTransport")
+ @Transport(name = CoreConst.RESTFUL)
+ public boolean restTransport(InvocationContext invocation) {
+ return CoreConst.RESTFUL.equals(((Invocation)
invocation).getTransportName());
+ }
+
+ @GetMapping(path = "/highwayTransport")
+ @Transport(name = CoreConst.HIGHWAY)
+ public boolean highwayTransport(InvocationContext invocation) {
+ return CoreConst.HIGHWAY.equals(((Invocation)
invocation).getTransportName());
+ }
+}
diff --git
a/demo/demo-zookeeper/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerReactiveStreamController.java
b/demo/demo-zookeeper/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerReactiveStreamController.java
index 26234acda..aa169801c 100644
---
a/demo/demo-zookeeper/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerReactiveStreamController.java
+++
b/demo/demo-zookeeper/consumer/src/main/java/org/apache/servicecomb/samples/ConsumerReactiveStreamController.java
@@ -17,6 +17,8 @@
package org.apache.servicecomb.samples;
+import org.apache.servicecomb.core.CoreConst;
+import org.apache.servicecomb.core.annotation.Transport;
import org.apache.servicecomb.provider.pojo.RpcReference;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.reactivestreams.Publisher;
@@ -69,11 +71,13 @@ public class ConsumerReactiveStreamController {
}
@GetMapping("/sseString")
+ @Transport(name = CoreConst.RESTFUL)
public Publisher<String> sseString() {
return controller.sseString();
}
@GetMapping("/sseModel")
+ @Transport(name = CoreConst.RESTFUL)
public Publisher<Model> sseModel() {
return controller.sseModel();
}
diff --git a/demo/demo-zookeeper/consumer/src/main/resources/application.yml
b/demo/demo-zookeeper/consumer/src/main/resources/application.yml
index 7c779881b..a0e95d3ec 100644
--- a/demo/demo-zookeeper/consumer/src/main/resources/application.yml
+++ b/demo/demo-zookeeper/consumer/src/main/resources/application.yml
@@ -30,5 +30,8 @@ servicecomb:
rest:
address: 0.0.0.0:9092
+ highway:
+ address: 0.0.0.0:7092
+
diff --git
a/demo/demo-zookeeper/provider/src/main/java/org/apache/servicecomb/samples/ReactiveStreamController.java
b/demo/demo-zookeeper/provider/src/main/java/org/apache/servicecomb/samples/ReactiveStreamController.java
index e134ef925..8108d15fd 100644
---
a/demo/demo-zookeeper/provider/src/main/java/org/apache/servicecomb/samples/ReactiveStreamController.java
+++
b/demo/demo-zookeeper/provider/src/main/java/org/apache/servicecomb/samples/ReactiveStreamController.java
@@ -19,6 +19,8 @@ package org.apache.servicecomb.samples;
import java.util.concurrent.TimeUnit;
+import org.apache.servicecomb.core.CoreConst;
+import org.apache.servicecomb.core.annotation.Transport;
import org.apache.servicecomb.provider.rest.common.RestSchema;
import org.reactivestreams.Publisher;
import org.springframework.web.bind.annotation.GetMapping;
@@ -28,6 +30,7 @@ import io.reactivex.rxjava3.core.Flowable;
@RestSchema(schemaId = "ReactiveStreamController")
@RequestMapping(path = "/")
+@Transport(name = CoreConst.RESTFUL)
public class ReactiveStreamController {
public static class Model {
private String name;
diff --git a/demo/demo-zookeeper/provider/src/main/resources/application.yml
b/demo/demo-zookeeper/provider/src/main/resources/application.yml
index c8a158d31..10e0ab805 100644
--- a/demo/demo-zookeeper/provider/src/main/resources/application.yml
+++ b/demo/demo-zookeeper/provider/src/main/resources/application.yml
@@ -34,6 +34,9 @@ servicecomb:
rest:
address: 0.0.0.0:9094
+ highway:
+ address: 0.0.0.0:7094
+
cors:
enabled: true
origin: "*"
diff --git
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceFilter2.java
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceFilter2.java
index 1cf987433..ef6ef509a 100644
---
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceFilter2.java
+++
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceFilter2.java
@@ -50,6 +50,9 @@ import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.core.env.Environment;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.Operation;
+
public class TestLoadBalanceFilter2 {
Environment environment = Mockito.mock(Environment.class);
@@ -70,6 +73,12 @@ public class TestLoadBalanceFilter2 {
InvocationRuntimeType invocationRuntimeType =
Mockito.mock(InvocationRuntimeType.class);
SchemaMeta schemaMeta = Mockito.mock(SchemaMeta.class);
when(operationMeta.getSchemaMeta()).thenReturn(schemaMeta);
+ Operation operation = Mockito.mock(Operation.class);
+ when(operationMeta.getSwaggerOperation()).thenReturn(operation);
+ when(operation.getExtensions()).thenReturn(null);
+ OpenAPI openAPI = Mockito.mock(OpenAPI.class);
+ when(schemaMeta.getSwagger()).thenReturn(openAPI);
+ when(openAPI.getExtensions()).thenReturn(null);
MicroserviceMeta microserviceMeta = Mockito.mock(MicroserviceMeta.class);
when(schemaMeta.getMicroserviceMeta()).thenReturn(microserviceMeta);
when(schemaMeta.getMicroserviceName()).thenReturn("testMicroserviceName");
@@ -178,6 +187,12 @@ public class TestLoadBalanceFilter2 {
InvocationRuntimeType invocationRuntimeType =
Mockito.mock(InvocationRuntimeType.class);
SchemaMeta schemaMeta = Mockito.mock(SchemaMeta.class);
when(operationMeta.getSchemaMeta()).thenReturn(schemaMeta);
+ Operation operation = Mockito.mock(Operation.class);
+ when(operationMeta.getSwaggerOperation()).thenReturn(operation);
+ when(operation.getExtensions()).thenReturn(null);
+ OpenAPI openAPI = Mockito.mock(OpenAPI.class);
+ when(schemaMeta.getSwagger()).thenReturn(openAPI);
+ when(openAPI.getExtensions()).thenReturn(null);
MicroserviceMeta microserviceMeta = Mockito.mock(MicroserviceMeta.class);
when(schemaMeta.getMicroserviceMeta()).thenReturn(microserviceMeta);
when(schemaMeta.getMicroserviceName()).thenReturn("testMicroserviceName");
@@ -251,6 +266,12 @@ public class TestLoadBalanceFilter2 {
MicroserviceMeta microserviceMeta = Mockito.mock(MicroserviceMeta.class);
when(schemaMeta.getMicroserviceMeta()).thenReturn(microserviceMeta);
when(schemaMeta.getMicroserviceName()).thenReturn("testMicroserviceName");
+ Operation operation = Mockito.mock(Operation.class);
+ when(operationMeta.getSwaggerOperation()).thenReturn(operation);
+ when(operation.getExtensions()).thenReturn(null);
+ OpenAPI openAPI = Mockito.mock(OpenAPI.class);
+ when(schemaMeta.getSwagger()).thenReturn(openAPI);
+ when(openAPI.getExtensions()).thenReturn(null);
when(microserviceMeta.getAppId()).thenReturn("testApp");
when(referenceConfig.getTransport()).thenReturn("rest");
Invocation invocation = new Invocation(referenceConfig, operationMeta,
invocationRuntimeType, new HashMap<>());