You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/11/08 03:12:10 UTC
[james-project] 23/36: PROTOCOLS-36 [Refactoring]
AbstractProtocolTransport response queue is no longer needed
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit f3ae6ea82c161960e9a1d272440af2a0e1ca85f0
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Nov 7 09:20:08 2019 +0700
PROTOCOLS-36 [Refactoring] AbstractProtocolTransport response queue is no longer needed
As stated by PROTOCOLS-36:
```
If we mix FutureResponse and Response implementation we MUST ensure that
the right order of responses is maintained. This basicly means that we need
to put responses in a queue and dequeue them in the right order (respecting
the FutureResponse async nature)
```
Removing FutureResponse solves this, and removes the need for a queue.
---
.../protocols/api/AbstractProtocolTransport.java | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java b/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
index 65825ca..1b76bf8 100644
--- a/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
+++ b/protocols/api/src/main/java/org/apache/james/protocols/api/AbstractProtocolTransport.java
@@ -22,8 +22,6 @@ package org.apache.james.protocols.api;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.LinkedBlockingQueue;
/**
@@ -32,27 +30,10 @@ import java.util.concurrent.LinkedBlockingQueue;
*/
public abstract class AbstractProtocolTransport implements ProtocolTransport {
private static final String CRLF = "\r\n";
-
- // TODO: Should we limit the size ?
- private final Queue<Response> responses = new LinkedBlockingQueue<>();
- private volatile boolean isAsync = false;
@Override
public final void writeResponse(Response response, ProtocolSession session) {
- // if we already in asynchrnous mode we simply enqueue the response
- // we do this synchronously because we may have a dequeuer thread working on
- // isAsync and responses.
- boolean enqueued = false;
- synchronized (this) {
- if (isAsync == true) {
- responses.offer(response);
- enqueued = true;
- }
- }
-
- if (!enqueued) {
- writeResponseToClient(response, session);
- }
+ writeResponseToClient(response, session);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org