Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[UNDERTOW-2249] Change that HttpClientConnection.sendRequest on a clo... #1564

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.io.IOException;
import java.net.URI;
import java.nio.channels.ClosedChannelException;

/**
* starting from 1000
Expand Down Expand Up @@ -74,4 +75,7 @@ public interface UndertowClientMessages {

@Message(id = 1038, value = "Received invalid AJP chunk %s with response already complete")
IOException receivedInvalidChunk(byte prefix);

@Message(id = 1039, value = "Closed connection state")
ClosedChannelException closedConnectionState();
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,12 @@ public void addCloseListener(ChannelListener<ClientConnection> listener) {

@Override
public void sendRequest(final ClientRequest request, final ClientCallback<ClientExchange> clientCallback) {
if (anyAreSet(state, UPGRADE_REQUESTED | UPGRADED | CLOSE_REQ | CLOSED)) {
if (anyAreSet(state, UPGRADE_REQUESTED | UPGRADED)) {
clientCallback.failed(UndertowClientMessages.MESSAGES.invalidConnectionState());
return;
} else if (anyAreSet(state, CLOSE_REQ | CLOSED)) {
clientCallback.failed(UndertowClientMessages.MESSAGES.closedConnectionState());
return;
}
final AjpClientExchange AjpClientExchange = new AjpClientExchange(clientCallback, request, this);
if (currentRequest == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,12 @@ public void sendRequest(final ClientRequest request, final ClientCallback<Client
http2Delegate.sendRequest(request, clientCallback);
return;
}
if (anyAreSet(state, UPGRADE_REQUESTED | UPGRADED | CLOSE_REQ | CLOSED)) {
if (anyAreSet(state, UPGRADE_REQUESTED | UPGRADED)) {
clientCallback.failed(UndertowClientMessages.MESSAGES.invalidConnectionState());
return;
} else if (anyAreSet(state, CLOSE_REQ | CLOSED)) {
clientCallback.failed(UndertowClientMessages.MESSAGES.closedConnectionState());
return;
}
final HttpClientExchange httpClientExchange = new HttpClientExchange(clientCallback, request, this);
boolean ssl = this.connection instanceof SslConnection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -360,8 +361,7 @@ public void testSslServerIdentity() throws Exception {
latch.await(10, TimeUnit.SECONDS);

Assert.assertEquals(0, responses.size());
// see UNDERTOW-2249: assert exception instanceof ClosedChannelException
Assert.assertNotNull(exception);
Assert.assertTrue(exception instanceof ClosedChannelException);
} finally {
connection.getIoThread().execute(() -> IoUtils.safeClose(connection));
DefaultServer.stopSSLServer();
Expand Down