Skip to content

Commit

Permalink
Merge pull request #1359 from fl4via/2.2.x_backport_bug_fixes
Browse files Browse the repository at this point in the history
[UNDERTOW-2031][UNDERTOW-2113][UNDERTOW-2130][UNDERTOW-2133][UNDERTOW-2135] backport bug fixes to 2.2.x branch
  • Loading branch information
fl4via committed Aug 11, 2022
2 parents 52a81e5 + 1d95f77 commit 5177c78
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 16 deletions.
Expand Up @@ -31,6 +31,7 @@
import io.undertow.conduits.ConduitListener;
import io.undertow.server.Connectors;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.RequestTooBigException;
import io.undertow.util.ImmediatePooledByteBuffer;
import org.xnio.IoUtils;
import org.xnio.channels.StreamSinkChannel;
Expand Down Expand Up @@ -202,6 +203,8 @@ public int read(ByteBuffer dst) throws IOException {
}
assert STATE_FINISHED == state;
return -1;
} catch (RequestTooBigException e) {
throw e;
} catch (IOException | RuntimeException e) {
IoUtils.safeClose(exchange.getConnection());
throw e;
Expand Down
Expand Up @@ -142,7 +142,6 @@ public void awaitWritable(long time, TimeUnit timeUnit) throws IOException {
HttpServerExchange newExchange = exchange.getConnection().sendOutOfBandResponse(exchange);
exchange.putAttachment(ALREADY_SENT, true);
newExchange.setStatusCode(StatusCodes.CONTINUE);
newExchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, 0);
final StreamSinkChannel responseChannel = newExchange.getResponseChannel();
return new ContinueResponseSender() {
boolean shutdown = false;
Expand Down Expand Up @@ -219,7 +218,6 @@ private static void internalSendContinueResponse(final HttpServerExchange exchan
HttpServerExchange newExchange = exchange.getConnection().sendOutOfBandResponse(exchange);
exchange.putAttachment(ALREADY_SENT, true);
newExchange.setStatusCode(StatusCodes.CONTINUE);
newExchange.getResponseHeaders().put(Headers.CONTENT_LENGTH, 0);
final StreamSinkChannel responseChannel = newExchange.getResponseChannel();
try {
responseChannel.shutdownWrites();
Expand Down
Expand Up @@ -74,9 +74,8 @@ public Http2UpgradeHandler(HttpHandler next, String... upgradeStrings) {
public void handleRequest(HttpServerExchange exchange) throws Exception {
final String upgrade = exchange.getRequestHeaders().getFirst(Headers.UPGRADE);
final String settings = exchange.getRequestHeaders().getFirst("HTTP2-Settings");
if(settings != null && upgrade != null
&& upgradeStrings.contains(upgrade)) {
if(HttpContinue.requiresContinueResponse(exchange) && false) {
if(settings != null && upgrade != null && upgradeStrings.contains(upgrade)) {
if(HttpContinue.requiresContinueResponse(exchange)) {
HttpContinue.sendContinueResponse(exchange, new IoCallback() {
@Override
public void onComplete(HttpServerExchange exchange, Sender sender) {
Expand Down
Expand Up @@ -136,7 +136,7 @@ public long getContentLength() {
client.execute(post);
} catch (SocketException e) {
Assert.assertTrue(e.getMessage(), e.getMessage().contains("Broken pipe")
|| e.getMessage().contains("connection abort"));
|| e.getMessage().contains("connection abort") || e.getMessage().contains("connection was aborted"));
socketFailure = true;
}
Assert.assertTrue("Test sent request without any exception", socketFailure);
Expand Down
Expand Up @@ -18,9 +18,6 @@

package io.undertow.servlet.test.streams;

import io.undertow.testutils.DefaultServer;
import org.junit.runner.RunWith;

import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServlet;
Expand All @@ -33,7 +30,6 @@
/**
* @author Stuart Douglas
*/
@RunWith(DefaultServer.class)
public class EarlyCloseClientServlet extends HttpServlet {

private static volatile boolean exceptionThrown;
Expand Down
Expand Up @@ -29,12 +29,10 @@
import io.undertow.servlet.handlers.ServletRequestContext;
import io.undertow.servlet.spec.HttpServletRequestImpl;
import io.undertow.testutils.DefaultServer;
import org.junit.runner.RunWith;

/**
* @author Stuart Douglas
*/
@RunWith(DefaultServer.class)
public class EarlyCloseServlet extends HttpServlet {

private volatile ServerConnection connection;
Expand Down
Expand Up @@ -23,14 +23,10 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.junit.runner.RunWith;

import io.undertow.testutils.DefaultServer;

/**
* @author Stuart Douglas
*/
@RunWith(DefaultServer.class)
public class ForceDrainServlet extends HttpServlet {

@Override
Expand Down

0 comments on commit 5177c78

Please sign in to comment.