Skip to content

Commit

Permalink
Merged branch 'jetty-10.0.x' into 'jetty-10.0.x-250-http_connect_for_…
Browse files Browse the repository at this point in the history
…http2'.
  • Loading branch information
sbordet committed Jul 9, 2019
2 parents 564d5d0 + 352d1e7 commit 68c7869
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Jmh_Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ node("linux") {
// jmh run
node( 'jmh-build-node' ) {
stage("jmh-run") {
timeout( time: 180, unit: 'MINUTES' ) {
timeout( time: 210, unit: 'MINUTES' ) {
withEnv( ["JAVA_HOME=${tool "$jdk"}"] ) {
unstash name: 'perf-tests'
sh "rm -rf jmh_results"
sh "mkdir jmh_results"
sh "${env.JAVA_HOME}/bin/java -jar $jmhJarPath -rff jmh_results/jmh_result.json -rf json -foe true"
sh "${env.JAVA_HOME}/bin/java -jar $jmhJarPath -rff jmh_results/jmh_result.json -rf json -foe true -i 3 -t 3 -wi 3"
jmhReport 'jmh_results/jmh_result.json'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ public CompressionPool(int capacity)
_pool = (_capacity == 0) ? null : new ConcurrentLinkedQueue<>();
}

abstract protected T newObject();
protected abstract T newObject();

abstract protected void end(T object);
protected abstract void end(T object);

abstract protected void reset(T object);
protected abstract void reset(T object);

/**
* @return Object taken from the pool if it is not empty or a newly created Object
Expand Down Expand Up @@ -125,4 +125,4 @@ public void doStop()
}
_numObjects.set(0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ public void upgrade(HttpResponse response, HttpConnectionOverHTTP httpConnection
}

// Negotiate the extension stack
HttpClient httpClient = wsClient.getHttpClient();
ExtensionStack extensionStack = new ExtensionStack(wsClient.getWebSocketComponents(), Behavior.CLIENT);
extensionStack.negotiate(offeredExtensions, negotiatedExtensions);

Expand Down Expand Up @@ -370,6 +369,7 @@ else if (values.length == 1)
WebSocketCoreSession coreSession = newWebSocketCoreSession(frameHandler, negotiated);
customizer.customize(coreSession);

HttpClient httpClient = wsClient.getHttpClient();
WebSocketConnection wsConnection = newWebSocketConnection(endp, httpClient.getExecutor(), httpClient.getScheduler(), httpClient.getByteBufferPool(), coreSession);

for (Connection.Listener listener : wsClient.getBeans(Connection.Listener.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.nio.channels.ClosedChannelException;
import java.time.Duration;
import java.util.ArrayDeque;
import java.util.List;
Expand Down Expand Up @@ -317,7 +316,7 @@ public void closeConnection(CloseStatus closeStatus, Callback callback)
connection.close();

// Forward Errors to Local WebSocket EndPoint
if (closeStatus.isAbnormal())
if (closeStatus.isAbnormal() && closeStatus.getCause() != null)
{
Callback errorCallback = Callback.from(() ->
{
Expand All @@ -332,7 +331,7 @@ public void closeConnection(CloseStatus closeStatus, Callback callback)
}
});

Throwable cause = closeStatus.getCause() != null ? closeStatus.getCause() : new ClosedChannelException();
Throwable cause = closeStatus.getCause();
try
{
handler.onError(cause, errorCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package org.eclipse.jetty.websocket.core.internal;

import java.nio.channels.ClosedChannelException;

import org.eclipse.jetty.websocket.core.CloseStatus;
import org.eclipse.jetty.websocket.core.Frame;
import org.eclipse.jetty.websocket.core.OpCode;
Expand Down Expand Up @@ -133,7 +135,7 @@ public boolean onEof()

default:
if (_closeStatus == null || CloseStatus.isOrdinary(_closeStatus.getCode()))
_closeStatus = new CloseStatus(CloseStatus.NO_CLOSE, "Session Closed");
_closeStatus = new CloseStatus(CloseStatus.NO_CLOSE, "Session Closed", new ClosedChannelException());
_sessionState = State.CLOSED;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.IOException;
import java.net.URI;
import java.nio.channels.ClosedChannelException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;

Expand Down Expand Up @@ -281,6 +282,23 @@ public void onClosed(CloseStatus closeStatus, Callback callback)
if (LOG.isDebugEnabled())
LOG.debug("[{}] onClosed {}", toString(), closeStatus);

boolean abnormalClose = false;
synchronized (lock)
{
switch (state)
{
case CLOSED:
break;

default:
abnormalClose = true;
break;
}
}

if (abnormalClose)
server2Proxy.fail(new ClosedChannelException(), Callback.NOOP);

closed.countDown();
callback.succeeded();
}
Expand Down Expand Up @@ -568,6 +586,24 @@ public void onClosed(CloseStatus closeStatus, Callback callback)
{
if (LOG.isDebugEnabled())
LOG.debug("[{}] onClosed {}", toString(), closeStatus);

boolean abnormalClose = false;
synchronized (lock)
{
switch (state)
{
case CLOSED:
break;

default:
abnormalClose = true;
break;
}
}

if (abnormalClose)
client2Proxy.fail(new ClosedChannelException(), Callback.NOOP);

closed.countDown();
callback.succeeded();
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.1</version>
<configuration>
<verbose>true</verbose>
<debug>true</debug>
Expand Down

0 comments on commit 68c7869

Please sign in to comment.