Skip to content

Commit 3810d41

Browse files
committed
add LOGGER for test
1 parent ed158f6 commit 3810d41

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

common/common-rest/src/main/java/org/apache/servicecomb/common/rest/codec/produce/ProduceEventStreamProcessor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@
2323

2424
import org.apache.commons.lang3.StringUtils;
2525
import org.apache.servicecomb.common.rest.codec.RestObjectMapperFactory;
26+
import org.apache.servicecomb.common.rest.filter.inner.ServerRestArgsFilter;
2627
import org.apache.servicecomb.swagger.sse.SseEventResponseEntity;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
2730

2831
import com.fasterxml.jackson.databind.JavaType;
2932

3033
import jakarta.ws.rs.core.MediaType;
3134

3235
public class ProduceEventStreamProcessor implements ProduceProcessor {
36+
private static final Logger LOGGER = LoggerFactory.getLogger(ServerRestArgsFilter.class);
37+
3338
private int writeIndex = 0;
3439

3540
@Override
@@ -54,13 +59,15 @@ public void doEncodeResponse(OutputStream output, Object result) throws Exceptio
5459
appendEventId(bufferBuilder, writeIndex++);
5560
appendData(bufferBuilder, result);
5661
}
62+
LOGGER.info("==============provider encoder bufferBuilder==============>" + bufferBuilder);
5763
bufferBuilder.append("\n");
5864
output.write(bufferBuilder.toString().getBytes(StandardCharsets.UTF_8));
5965
}
6066

6167
@Override
6268
public Object doDecodeResponse(InputStream input, JavaType type) throws Exception {
6369
String buffer = new String(input.readAllBytes(), StandardCharsets.UTF_8);
70+
LOGGER.info("=========doDecodeResponse buffer===================>" + buffer);
6471
SseEventResponseEntity<?> responseEntity = new SseEventResponseEntity<>();
6572
boolean isResponseEntity = false;
6673
for (String line : buffer.split("\n")) {

common/common-rest/src/main/java/org/apache/servicecomb/common/rest/filter/inner/ServerRestArgsFilter.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ public CompletableFuture<Void> beforeSendResponseAsync(Invocation invocation, Ht
8686
if (isServerSendEvent(response)) {
8787
produceProcessor = new ProduceEventStreamProcessor();
8888
responseEx.setContentType(produceProcessor.getName() + "; charset=utf-8");
89-
try {
90-
Thread.sleep(10000);
91-
} catch (InterruptedException e) {
92-
throw new RuntimeException(e);
93-
}
9489
return writeServerSendEvent(invocation, response, produceProcessor, responseEx);
9590
}
9691

demo/demo-spring-boot-transport/demo-spring-boot-springmvc-client/src/main/java/org/apache/servicecomb/springboot/springmvc/client/ReactiveStreamIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ private void testSseStringWithParam(ReactiveStreamClient client) throws Exceptio
5858
}
5959

6060
private String buildBufferString(Publisher<String> result) throws Exception {
61-
StringBuilder buffer = new StringBuilder();
6261
CountDownLatch countDownLatch = new CountDownLatch(1);
62+
countDownLatch.await(20, TimeUnit.SECONDS);
63+
StringBuilder buffer = new StringBuilder();
6364
result.subscribe(new Subscriber<>() {
6465
Subscription subscription;
6566

@@ -93,6 +94,7 @@ public void onComplete() {
9394
private void testSseModel(ReactiveStreamClient client) throws Exception {
9495
Publisher<Model> result = client.sseModel();
9596
CountDownLatch countDownLatch = new CountDownLatch(1);
97+
countDownLatch.await(20, TimeUnit.SECONDS);
9698
StringBuilder buffer = new StringBuilder();
9799
result.subscribe(new Subscriber<>() {
98100
Subscription subscription;
@@ -127,6 +129,7 @@ public void onComplete() {
127129
private void testSseResponseEntity(ReactiveStreamClient client) throws Exception {
128130
Publisher<SseEventResponseEntity<Model>> result = client.sseResponseEntity();
129131
CountDownLatch countDownLatch = new CountDownLatch(1);
132+
countDownLatch.await(20, TimeUnit.SECONDS);
130133
StringBuilder buffer = new StringBuilder();
131134
result.subscribe(new Subscriber<>() {
132135
Subscription subscription;

0 commit comments

Comments
 (0)