carryxyh closed pull request #1938: Fix a bug when the provider write a
throwable into aysnc context
URL: https://github.com/apache/incubator-dubbo/pull/1938
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContext.java
b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContext.java
index f5e4e5cb15..03c7c80f42 100644
---
a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContext.java
+++
b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContext.java
@@ -16,15 +16,36 @@
*/
package com.alibaba.dubbo.rpc;
+/**
+ * AsyncContext works like {@see javax.servlet.AsyncContext} in the Servlet
3.0.
+ * An AsyncContext is stated by a call to {@link RpcContext#startAsync()}.
+ * <p>
+ * The demo is {@see com.alibaba.dubbo.examples.async.AsyncConsumer}
+ * and {@see com.alibaba.dubbo.examples.async.AsyncProvider}
+ */
public interface AsyncContext {
void addListener(Runnable run);
+ /**
+ * write value and complete the async context.
+ *
+ * @param value invoke result
+ */
void write(Object value);
+ /**
+ * @return true if the aysnc context is started
+ */
boolean isAsyncStarted();
+ /**
+ * change the context state to stop
+ */
boolean stop();
+ /**
+ * change the context state to stop
+ */
void start();
}
diff --git
a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContextImpl.java
b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContextImpl.java
index f5b7a49de6..4e35dec36f 100644
---
a/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContextImpl.java
+++
b/dubbo-rpc/dubbo-rpc-api/src/main/java/com/alibaba/dubbo/rpc/AsyncContextImpl.java
@@ -48,8 +48,9 @@ public void write(Object value) {
// TODO check exception type like ExceptionFilter do.
Throwable bizExe = (Throwable) value;
future.complete(new RpcResult(bizExe));
+ } else {
+ future.complete(new RpcResult(value));
}
- future.complete(new RpcResult(value));
} else {
throw new IllegalStateException("The async response has probably
been wrote back by another thread, or the asyncContext has been closed.");
}
@@ -62,11 +63,7 @@ public boolean isAsyncStarted() {
@Override
public boolean stop() {
- if (started.compareAndSet(true, false)) {
-// future.cancel(true);
- return true;
- }
- return false;
+ return started.compareAndSet(true, false);
}
@Override
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]