Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2014-04-24 16:23:22 +0000
committerJesse McConnell2014-09-02 19:44:10 +0000
commit71268ba47c518bbc02fce202ab1956a2ec0e2bad (patch)
treef3f57f5e20aafd6ea3ad4e1bb5aca5b4732de9cf
parentcab425b479062d49d996272db0de13e23414d8fe (diff)
downloadorg.eclipse.jetty.project-71268ba47c518bbc02fce202ab1956a2ec0e2bad.tar.gz
org.eclipse.jetty.project-71268ba47c518bbc02fce202ab1956a2ec0e2bad.tar.xz
org.eclipse.jetty.project-71268ba47c518bbc02fce202ab1956a2ec0e2bad.zip
409788 - Large POST body causes java.lang.IllegalStateException: SENDING => HEADERS.
Added additional state for when the response completes before the request.
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java27
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientDuplexTest.java6
2 files changed, 28 insertions, 5 deletions
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java
index e694182d40..f11ca50e80 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpExchange.java
@@ -93,6 +93,7 @@ public class HttpExchange
public static final int STATUS_CANCELLED = 11;
public static final int STATUS_SENDING_PARSING_HEADERS = 12;
public static final int STATUS_SENDING_PARSING_CONTENT = 13;
+ public static final int STATUS_SENDING_COMPLETED = 14;
// HTTP protocol fields
private String _method = HttpMethods.GET;
@@ -131,7 +132,8 @@ public class HttpExchange
int status = getStatus();
if (status < STATUS_COMPLETED ||
status == STATUS_SENDING_PARSING_HEADERS ||
- status == STATUS_SENDING_PARSING_CONTENT)
+ status == STATUS_SENDING_PARSING_CONTENT ||
+ status == STATUS_SENDING_COMPLETED)
setStatus(STATUS_EXPIRED);
destination.exchangeExpired(this);
if (connection != null)
@@ -409,7 +411,7 @@ public class HttpExchange
getEventListener().onRequestCommitted();
break;
case STATUS_COMPLETED:
- if (set = _status.compareAndSet(oldStatus,newStatus))
+ if (set = _status.compareAndSet(oldStatus,STATUS_SENDING_COMPLETED))
getEventListener().onResponseComplete();
break;
case STATUS_CANCELLING:
@@ -423,6 +425,24 @@ public class HttpExchange
break;
}
break;
+ case STATUS_SENDING_COMPLETED:
+ switch (newStatus)
+ {
+ case STATUS_WAITING_FOR_RESPONSE:
+ if (set = _status.compareAndSet(oldStatus,STATUS_COMPLETED))
+ getEventListener().onRequestCommitted();
+ break;
+ case STATUS_CANCELLING:
+ case STATUS_EXCEPTED:
+ set = _status.compareAndSet(oldStatus,newStatus);
+ break;
+ case STATUS_EXPIRED:
+ set = setStatusExpired(newStatus,oldStatus);
+ break;
+ default:
+ break;
+ }
+ break;
default:
// Here means I allowed to set a state that I don't recognize
throw new AssertionError(oldStatus + " => " + newStatus);
@@ -954,6 +974,9 @@ public class HttpExchange
case STATUS_SENDING_PARSING_CONTENT:
state = "SENDING+CONTENT";
break;
+ case STATUS_SENDING_COMPLETED:
+ state = "SENDING+COMPLETED";
+ break;
default:
state = "UNKNOWN";
}
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientDuplexTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientDuplexTest.java
index 96c4f2e95e..2277a8d556 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientDuplexTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpClientDuplexTest.java
@@ -306,9 +306,9 @@ public class HttpClientDuplexTest
@Test
public void testResponseCompleteBeforeRequestContent() throws Exception
{
- // Must be greater than 2 to stay in "sending"
- // state and trigger the condition of this test.
- int contentLength = 16;
+ // Must be greater than 2 to stay in "sending" state while
+ // receiving the response and trigger the condition of this test.
+ int contentLength = 4;
final byte[] chunk = new byte[]{'A'};
final AtomicInteger requestContent = new AtomicInteger(contentLength);
ContentExchange exchange = new ContentExchange(true)

Back to the top