Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/jetty-12.0.x' into jetty-12.0.…
Browse files Browse the repository at this point in the history
…x-documentation-operations-logging

* upstream/jetty-12.0.x: (35 commits)
  Fixes jetty#9326 - Rename DecryptedEndPoint to SslEndPoint.
  Jetty 10 Upgrade to Hazelcast 5 and totally disable auto join multicast etc.. (fix build on CI) (jetty#9331)
  jetty#9328 - changes from review
  jetty#9287 - catch error in ee9 maxRequestSize MultiPart test
  Jetty 12.0.x 9301 fix ee10 jstl jpms (jetty#9321)
  Issue jetty#9301 Fix dependencies for ee10-glassfish-jstl module (jetty#9303)
  Jetty 12 Hazelcast 5.x and disable auto detection/multicast" (jetty#9332)
  jetty#9287 - fix further test failures
  Fixed imports.
  Issue jetty#7650 - Fix race condition when stopping QueuedThreadPool (jetty#9325)
  jetty#9287 - remove unpaired release of Content.Chunk
  Issue jetty#8991 - rename websocket isDemanding() method to isAutoDemanding()
  Issue jetty#9287 - fix failing tests
  changes f rom review
  add todo to revert to normal pool after fix for jetty#9311
  Issue jetty#9309 - Introducing test for requestlog format with spaces
  use non-pooling RetainableByteBufferPool to work around performance bug
  consumeAvailable should use number of reads instead of bytes
  fix for retainable merge
  changes from review
  ...
  • Loading branch information
Greg Poulos committed Feb 9, 2023
2 parents d2f8ce4 + 4db0c70 commit 2402b6a
Show file tree
Hide file tree
Showing 97 changed files with 1,295 additions and 747 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ circle application
network - SocketChannelEndPoint
SocketChannelEndPoint - SslConnection
SslConnection -- DecryptedEndPoint
DecryptedEndPoint - HttpConnection
SslConnection -- SslEndPoint
SslEndPoint - HttpConnection
HttpConnection - application
----

Bytes read by the `SocketChannelEndPoint` will be interpreted as TLS bytes by the `SslConnection`, then decrypted and made available to the `DecryptedEndPoint` (a component part of `SslConnection`), which will then provide them to `HttpConnection`.
Bytes read by the `SocketChannelEndPoint` will be interpreted as TLS bytes by the `SslConnection`, then decrypted and made available to the `SslEndPoint` (a component part of `SslConnection`), which will then provide them to `HttpConnection`.

The application writes bytes through the `HttpConnection` to the `DecryptedEndPoint`, which will encrypt them through the `SslConnection` and write the encrypted bytes to the `SocketChannelEndPoint`.
The application writes bytes through the `HttpConnection` to the `SslEndPoint`, which will encrypt them through the `SslConnection` and write the encrypted bytes to the `SocketChannelEndPoint`.

[[pg-server-io-arch-connection-factory-detecting]]
==== Choosing `ConnectionFactory` via Bytes Detection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ public void writeLine(String line, Callback callback)
if (failure == null)
{
// Unwrap the SslConnection to access the "line" APIs in TelnetConnection.
TelnetConnection connection = (TelnetConnection)sslConnection.getDecryptedEndPoint().getConnection();
TelnetConnection connection = (TelnetConnection)sslConnection.getSslEndPoint().getConnection();
// Register a listener that receives string lines.
connection.onLine(line -> System.getLogger("app").log(INFO, "line: {0}", line));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.eclipse.jetty.alpn.client.ALPNClientConnection;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.io.ssl.SslConnection.SslEndPoint;
import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -55,8 +55,8 @@ public void configure(SSLEngine sslEngine, Connection connection)
ALPNClientConnection alpn = (ALPNClientConnection)connection;
String[] protocols = alpn.getProtocols().toArray(new String[0]);
Conscrypt.setApplicationProtocols(sslEngine, protocols);
((SslConnection.DecryptedEndPoint)connection.getEndPoint()).getSslConnection()
.addHandshakeListener(new ALPNListener(alpn));
SslEndPoint sslEndPoint = (SslEndPoint)connection.getEndPoint();
sslEndPoint.getSslConnection().addHandshakeListener(new ALPNListener(alpn));
}
catch (RuntimeException x)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.eclipse.jetty.alpn.server.ALPNServerConnection;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection.DecryptedEndPoint;
import org.eclipse.jetty.io.ssl.SslConnection.SslEndPoint;
import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -74,7 +74,8 @@ private final class ALPNCallback extends ApplicationProtocolSelector implements
private ALPNCallback(ALPNServerConnection connection)
{
alpnConnection = connection;
((DecryptedEndPoint)alpnConnection.getEndPoint()).getSslConnection().addHandshakeListener(this);
SslEndPoint sslEndPoint = (SslEndPoint)alpnConnection.getEndPoint();
sslEndPoint.getSslConnection().addHandshakeListener(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.eclipse.jetty.alpn.client.ALPNClientConnection;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection.DecryptedEndPoint;
import org.eclipse.jetty.io.ssl.SslConnection.SslEndPoint;
import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.eclipse.jetty.util.JavaVersion;
import org.slf4j.Logger;
Expand Down Expand Up @@ -52,8 +52,8 @@ public void configure(SSLEngine sslEngine, Connection connection)
List<String> protocols = alpn.getProtocols();
sslParameters.setApplicationProtocols(protocols.toArray(new String[0]));
sslEngine.setSSLParameters(sslParameters);
((DecryptedEndPoint)connection.getEndPoint()).getSslConnection()
.addHandshakeListener(new ALPNListener(alpn));
SslEndPoint sslEndPoint = (SslEndPoint)connection.getEndPoint();
sslEndPoint.getSslConnection().addHandshakeListener(new ALPNListener(alpn));
}

private static final class ALPNListener implements SslHandshakeListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.eclipse.jetty.alpn.server.ALPNServerConnection;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.ssl.ALPNProcessor;
import org.eclipse.jetty.io.ssl.SslConnection;
import org.eclipse.jetty.io.ssl.SslConnection.SslEndPoint;
import org.eclipse.jetty.io.ssl.SslHandshakeListener;
import org.eclipse.jetty.util.JavaVersion;
import org.slf4j.Logger;
Expand Down Expand Up @@ -57,7 +57,8 @@ private static final class ALPNCallback implements BiFunction<SSLEngine, List<St
private ALPNCallback(ALPNServerConnection connection)
{
alpnConnection = connection;
((SslConnection.DecryptedEndPoint)alpnConnection.getEndPoint()).getSslConnection().addHandshakeListener(this);
SslEndPoint sslEndPoint = (SslEndPoint)alpnConnection.getEndPoint();
sslEndPoint.getSslConnection().addHandshakeListener(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.jetty.client.Response.Listener;
import org.eclipse.jetty.io.Content;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.StaticException;
import org.eclipse.jetty.util.thread.AutoLock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -301,7 +302,7 @@ public int read(byte[] b, int offset, int length) throws IOException
break;

if (failure != null)
throw toIOException(failure);
throw new IOException(failure);

if (closed)
throw new AsynchronousCloseException();
Expand All @@ -327,14 +328,6 @@ public int read(byte[] b, int offset, int length) throws IOException
}
}

private IOException toIOException(Throwable failure)
{
if (failure instanceof IOException)
return (IOException)failure;
else
return new IOException(failure);
}

@Override
public void close() throws IOException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected HttpFields customizePartHeaders(MultiPart.Part part)
if (headers.contains(HttpHeader.CONTENT_TYPE))
return headers;

Content.Source partContent = part.getContent();
Content.Source partContent = part.getContentSource();
if (partContent instanceof Request.Content requestContent)
{
String contentType = requestContent.getContentType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testSslConnectionClosedBeforeFill() throws Exception
SSLEngine sslEngine = sslContextFactory.newSSLEngine();
sslEngine.setUseClientMode(false);
SslConnection sslConnection = new SslConnection(bufferPool, threadPool, endPoint, sslEngine);
EndPoint sslEndPoint = sslConnection.getDecryptedEndPoint();
EndPoint sslEndPoint = sslConnection.getSslEndPoint();
sslEndPoint.setConnection(new AbstractConnection(sslEndPoint, threadPool)
{
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ protected void process(MultiPartFormData.Parts parts) throws Exception
int equal = contentType.lastIndexOf('=');
Charset charset = Charset.forName(contentType.substring(equal + 1));
assertEquals(encoding, charset);
assertEquals(value, Content.Source.asString(part.getContent(), charset));
assertEquals(value, Content.Source.asString(part.getContentSource(), charset));
}
});

Expand Down Expand Up @@ -169,7 +169,7 @@ protected void process(MultiPartFormData.Parts parts) throws Exception
MultiPart.Part part = parts.iterator().next();
assertEquals(name, part.getName());
assertEquals("text/plain", part.getHeaders().get(HttpHeader.CONTENT_TYPE));
assertArrayEquals(data, Content.Source.asByteBuffer(part.getContent()).array());
assertArrayEquals(data, Content.Source.asByteBuffer(part.getContentSource()).array());
}
});

Expand Down Expand Up @@ -221,8 +221,8 @@ protected void process(MultiPartFormData.Parts parts) throws Exception
assertEquals(name, part.getName());
assertEquals(contentType, part.getHeaders().get(HttpHeader.CONTENT_TYPE));
assertEquals(fileName, part.getFileName());
assertEquals(data.length, part.getContent().getLength());
assertArrayEquals(data, Content.Source.asByteBuffer(part.getContent()).array());
assertEquals(data.length, part.getContentSource().getLength());
assertArrayEquals(data, Content.Source.asByteBuffer(part.getContentSource()).array());
}
});

Expand Down Expand Up @@ -277,8 +277,8 @@ protected void process(MultiPartFormData.Parts parts) throws Exception
assertEquals(name, part.getName());
assertEquals(contentType, part.getHeaders().get(HttpHeader.CONTENT_TYPE));
assertEquals(tmpPath.getFileName().toString(), part.getFileName());
assertEquals(Files.size(tmpPath), part.getContent().getLength());
assertEquals(data, Content.Source.asString(part.getContent(), encoding));
assertEquals(Files.size(tmpPath), part.getContentSource().getLength());
assertEquals(data, Content.Source.asString(part.getContentSource(), encoding));
}
});

Expand Down Expand Up @@ -329,14 +329,14 @@ protected void process(MultiPartFormData.Parts parts) throws Exception

assertEquals(field, fieldPart.getName());
assertEquals(contentType, fieldPart.getHeaders().get(HttpHeader.CONTENT_TYPE));
assertEquals(value, Content.Source.asString(fieldPart.getContent(), encoding));
assertEquals(value, Content.Source.asString(fieldPart.getContentSource(), encoding));
assertEquals(headerValue, fieldPart.getHeaders().get(headerName));

assertEquals(fileField, filePart.getName());
assertEquals("application/octet-stream", filePart.getHeaders().get(HttpHeader.CONTENT_TYPE));
assertEquals(tmpPath.getFileName().toString(), filePart.getFileName());
assertEquals(Files.size(tmpPath), filePart.getContent().getLength());
assertArrayEquals(data, Content.Source.asByteBuffer(filePart.getContent()).array());
assertEquals(Files.size(tmpPath), filePart.getContentSource().getLength());
assertArrayEquals(data, Content.Source.asByteBuffer(filePart.getContentSource()).array());
}
});

Expand Down Expand Up @@ -373,11 +373,11 @@ protected void process(MultiPartFormData.Parts parts) throws Exception
MultiPart.Part fieldPart = parts.get(0);
MultiPart.Part filePart = parts.get(1);

assertEquals(value, Content.Source.asString(fieldPart.getContent(), encoding));
assertEquals(value, Content.Source.asString(fieldPart.getContentSource(), encoding));
assertEquals("file", filePart.getName());
assertEquals("application/octet-stream", filePart.getHeaders().get(HttpHeader.CONTENT_TYPE));
assertEquals("fileName", filePart.getFileName());
assertArrayEquals(fileData, Content.Source.asByteBuffer(filePart.getContent()).array());
assertArrayEquals(fileData, Content.Source.asByteBuffer(filePart.getContentSource()).array());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ public boolean isCommitted()
return _committed;
}

@Override
public Throwable consumeAvailable()
{
return HttpStream.consumeAvailable(this, _httpChannel.getConnectionMetaData().getHttpConfiguration());
}

@Override
public void succeeded()
{
Expand Down

0 comments on commit 2402b6a

Please sign in to comment.