Skip to content

Commit

Permalink
Merge branch 'jetty-10.0.x' into jetty-10.0.x-simplify-poms
Browse files Browse the repository at this point in the history
  • Loading branch information
olamy authored Mar 22, 2022
2 parents 3a208ae + 29011e9 commit 1b703ae
Show file tree
Hide file tree
Showing 75 changed files with 2,607 additions and 316 deletions.
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ updates:
versions: [ ">=1.1.0" ]
- dependency-name: "org.infinispan:*"
versions: [ ">=12" ]
- dependency-name: "org.jboss.weld.servlet:*"
versions: [ ">=4.0.0" ]

- package-ecosystem: "maven"
directory: "/"
Expand Down
10 changes: 10 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pipeline {
steps {
container('jetty-build') {
timeout( time: 120, unit: 'MINUTES' ) {
mavenBuild( "jdk17", "clean install", "maven3")
mavenBuild( "jdk17", "clean install -Perrorprone", "maven3")
// Collect up the jacoco execution results (only on main build)
jacoco inclusionPattern: '**/org/eclipse/jetty/**/*.class',
exclusionPattern: '' +
Expand All @@ -31,7 +31,7 @@ pipeline {
execPattern: '**/target/jacoco.exec',
classPattern: '**/target/classes',
sourcePattern: '**/src/main/java'
recordIssues id: "jdk17", name: "Static Analysis jdk17", aggregatingResults: true, enabledForFailure: true, tools: [mavenConsole(), java(), checkStyle()]
recordIssues id: "jdk17", name: "Static Analysis jdk17", aggregatingResults: true, enabledForFailure: true, tools: [mavenConsole(), java(), checkStyle(), errorProne(), spotBugs()]
}
}
}
Expand All @@ -42,8 +42,8 @@ pipeline {
steps {
container( 'jetty-build' ) {
timeout( time: 120, unit: 'MINUTES' ) {
mavenBuild( "jdk11", "clean install -Dspotbugs.skip=true -Djacoco.skip=true -Perrorprone", "maven3")
recordIssues id: "jdk11", name: "Static Analysis jdk11", aggregatingResults: true, enabledForFailure: true, tools: [mavenConsole(), java(), checkStyle(), errorProne()]
mavenBuild( "jdk11", "clean install -Dspotbugs.skip=true -Djacoco.skip=true", "maven3")
recordIssues id: "jdk11", name: "Static Analysis jdk11", aggregatingResults: true, enabledForFailure: true, tools: [mavenConsole(), java(), checkStyle()]
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions javadoc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jspc-maven-plugin</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
import org.junit.jupiter.params.provider.MethodSource;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.lessThanOrEqualTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand All @@ -75,11 +77,6 @@ public static Stream<ConnectionPoolFactory> pools()
return Stream.of(DUPLEX, MULTIPLEX, RANDOM, DUPLEX_MAX_DURATION, ROUND_ROBIN);
}

public static Stream<ConnectionPoolFactory> poolsNoMaxDuration()
{
return Stream.of(DUPLEX, MULTIPLEX, RANDOM, ROUND_ROBIN);
}

public static Stream<ConnectionPoolFactory> poolsNoRoundRobin()
{
return Stream.of(DUPLEX, MULTIPLEX, RANDOM, DUPLEX_MAX_DURATION);
Expand Down Expand Up @@ -316,7 +313,10 @@ public void resolve(String host, int port, Promise<List<InetSocketAddress>> prom
assertEquals(1, destinations.size());
HttpDestination destination = (HttpDestination)destinations.get(0);
AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool();
assertEquals(2, connectionPool.getConnectionCount());
if (DUPLEX_MAX_DURATION == factory)
assertThat(connectionPool.getConnectionCount(), lessThanOrEqualTo(2)); // The connections can expire upon release.
else
assertThat(connectionPool.getConnectionCount(), is(2));
}

@ParameterizedTest
Expand Down Expand Up @@ -376,17 +376,15 @@ public void resolve(String host, int port, Promise<List<InetSocketAddress>> prom
}

@ParameterizedTest
// Connection pool aggressively closes expired connections upon release, which interferes with this test's assertion.
@MethodSource("poolsNoMaxDuration")
@MethodSource("pools")
public void testConcurrentRequestsAllBlockedOnServerWithLargeConnectionPool(ConnectionPoolFactory factory) throws Exception
{
int count = 50;
testConcurrentRequestsAllBlockedOnServer(factory, count, 2 * count);
}

@ParameterizedTest
// Connection pool aggressively closes expired connections upon release, which interferes with this test's assertion.
@MethodSource("poolsNoMaxDuration")
@MethodSource("pools")
public void testConcurrentRequestsAllBlockedOnServerWithExactConnectionPool(ConnectionPoolFactory factory) throws Exception
{
int count = 50;
Expand Down Expand Up @@ -449,9 +447,13 @@ protected void service(String target, org.eclipse.jetty.server.Request jettyRequ
assertTrue(latch.await(5, TimeUnit.SECONDS), "server requests " + barrier.getNumberWaiting() + "<" + count + " - client: " + client.dump());
List<Destination> destinations = client.getDestinations();
assertEquals(1, destinations.size());
HttpDestination destination = (HttpDestination)destinations.get(0);
AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool();
assertThat(connectionPool.getConnectionCount(), Matchers.greaterThanOrEqualTo(count));
// The max duration connection pool aggressively closes expired connections upon release, which interferes with this assertion.
if (DUPLEX_MAX_DURATION != factory)
{
HttpDestination destination = (HttpDestination)destinations.get(0);
AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool();
assertThat(connectionPool.getConnectionCount(), Matchers.greaterThanOrEqualTo(count));
}
}

@Test
Expand Down Expand Up @@ -588,8 +590,17 @@ public void testConnectionMaxUsage(ConnectionPoolFactory factory) throws Excepti
AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool();

assertEquals(0, connectionPool.getActiveConnectionCount());
assertEquals(1, connectionPool.getIdleConnectionCount());
assertEquals(1, connectionPool.getConnectionCount());
if (DUPLEX_MAX_DURATION == factory)
{
// The connections can expire upon release.
assertThat(connectionPool.getIdleConnectionCount(), lessThanOrEqualTo(1));
assertThat(connectionPool.getConnectionCount(), lessThanOrEqualTo(1));
}
else
{
assertThat(connectionPool.getIdleConnectionCount(), is(1));
assertThat(connectionPool.getConnectionCount(), is(1));
}

// Send second request, max usage count will be reached,
// the only connection must be closed.
Expand Down Expand Up @@ -625,7 +636,10 @@ public void testIdleTimeoutNoRequests(ConnectionPoolFactory factory) throws Exce
// Trigger the creation of a destination, that will create the connection pool.
HttpDestination destination = client.resolveDestination(new Origin("http", "localhost", connector.getLocalPort()));
AbstractConnectionPool connectionPool = (AbstractConnectionPool)destination.getConnectionPool();
assertEquals(1, connectionPool.getConnectionCount());
if (DUPLEX_MAX_DURATION == factory)
assertThat(connectionPool.getConnectionCount(), lessThanOrEqualTo(1)); // The connections can expire upon release.
else
assertThat(connectionPool.getConnectionCount(), is(1));

// Wait for the pre-created connections to idle timeout.
Thread.sleep(idleTimeout + idleTimeout / 2);
Expand Down
2 changes: 1 addition & 1 deletion jetty-gcloud/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<name>Jetty :: GCloud</name>

<properties>
<gcloud.version>2.2.4</gcloud.version>
<gcloud.version>2.2.9</gcloud.version>
</properties>

<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public QpackDecoder getQpackDecoder()
return decoder;
}

public QpackEncoder getQpackEncoder()
{
return encoder;
}

public HTTP3SessionClient getSessionClient()
{
return session;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,24 @@ protected GoAwayFrame newGoAwayFrame(boolean graceful)
return GoAwayFrame.CLIENT_GRACEFUL;
return super.newGoAwayFrame(graceful);
}

@Override
protected void onSettingMaxTableCapacity(long value)
{
getProtocolSession().getQpackEncoder().setCapacity((int)value);
}

@Override
protected void onSettingMaxFieldSectionSize(long value)
{
getProtocolSession().getQpackDecoder().setMaxHeaderSize((int)value);
}

@Override
protected void onSettingMaxBlockedStreams(long value)
{
ClientHTTP3Session session = getProtocolSession();
session.getQpackDecoder().setMaxBlockedStreams((int)value);
session.getQpackEncoder().setMaxBlockedStreams((int)value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@

public class SettingsFrame extends Frame
{
public static final long MAX_TABLE_CAPACITY = 0x01;
public static final long MAX_FIELD_SECTION_SIZE = 0x06;
public static final long MAX_BLOCKED_STREAMS = 0x07;

public static boolean isReserved(long key)
{
return key >= 0 && key <= 5;
if (key == MAX_TABLE_CAPACITY ||
key == MAX_FIELD_SECTION_SIZE ||
key == MAX_BLOCKED_STREAMS)
return false;
// Other HTTP/2 settings are reserved and must not be sent/received.
return key >= 0x00 && key <= 0x05;
}

private final Map<Long, Long> settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,9 +371,32 @@ public void onSettings(SettingsFrame frame)
{
if (LOG.isDebugEnabled())
LOG.debug("received {} on {}", frame, this);

frame.getSettings().forEach((key, value) ->
{
if (key == SettingsFrame.MAX_TABLE_CAPACITY)
onSettingMaxTableCapacity(value);
else if (key == SettingsFrame.MAX_FIELD_SECTION_SIZE)
onSettingMaxFieldSectionSize(value);
else if (key == SettingsFrame.MAX_BLOCKED_STREAMS)
onSettingMaxBlockedStreams(value);
});

notifySettings(frame);
}

protected void onSettingMaxTableCapacity(long value)
{
}

protected void onSettingMaxFieldSectionSize(long value)
{
}

protected void onSettingMaxBlockedStreams(long value)
{
}

private void notifySettings(SettingsFrame frame)
{
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class QpackDecoder implements Dumpable
private final List<EncodedFieldSection> _encodedFieldSections = new ArrayList<>();
private final NBitIntegerParser _integerDecoder = new NBitIntegerParser();
private final InstructionHandler _instructionHandler = new InstructionHandler();
private final int _maxHeaderSize;
private int _maxHeaderSize;
private int _maxBlockedStreams;

private static class MetaDataNotification
{
Expand Down Expand Up @@ -87,6 +88,27 @@ QpackContext getQpackContext()
return _context;
}

public int getMaxHeaderSize()
{
return _maxHeaderSize;
}

public void setMaxHeaderSize(int maxHeaderSize)
{
_maxHeaderSize = maxHeaderSize;
}

public int getMaxBlockedStreams()
{
// TODO: implement logic about blocked streams by calling this method.
return _maxBlockedStreams;
}

public void setMaxBlockedStreams(int maxBlockedStreams)
{
_maxBlockedStreams = maxBlockedStreams;
}

public interface Handler
{
void onMetaData(long streamId, MetaData metadata);
Expand All @@ -110,7 +132,8 @@ public boolean decode(long streamId, ByteBuffer buffer, Handler handler) throws
LOG.debug("Decoding: streamId={}, buffer={}", streamId, BufferUtil.toDetailString(buffer));

// If the buffer is big, don't even think about decoding it
if (buffer.remaining() > _maxHeaderSize)
int maxHeaderSize = getMaxHeaderSize();
if (buffer.remaining() > maxHeaderSize)
throw new QpackException.SessionException(QPACK_DECOMPRESSION_FAILED, "header_too_large");

_integerDecoder.setPrefix(8);
Expand Down Expand Up @@ -139,7 +162,7 @@ public boolean decode(long streamId, ByteBuffer buffer, Handler handler) throws
// Decode it straight away if we can, otherwise add it to the list of EncodedFieldSections.
if (requiredInsertCount <= insertCount)
{
MetaData metaData = encodedFieldSection.decode(_context, _maxHeaderSize);
MetaData metaData = encodedFieldSection.decode(_context, maxHeaderSize);
if (LOG.isDebugEnabled())
LOG.debug("Decoded: streamId={}, metadata={}", streamId, metaData);
_metaDataNotifications.add(new MetaDataNotification(streamId, metaData, handler));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class QpackEncoder implements Dumpable
private final List<Instruction> _instructions = new ArrayList<>();
private final Instruction.Handler _handler;
private final QpackContext _context;
private final int _maxBlockedStreams;
private int _maxBlockedStreams;
private final Map<Long, StreamInfo> _streamInfoMap = new HashMap<>();
private final EncoderInstructionParser _parser;
private final InstructionHandler _instructionHandler = new InstructionHandler();
Expand All @@ -106,6 +106,21 @@ public QpackEncoder(Instruction.Handler handler, int maxBlockedStreams)
_parser = new EncoderInstructionParser(_instructionHandler);
}

public int getMaxBlockedStreams()
{
return _maxBlockedStreams;
}

public void setMaxBlockedStreams(int maxBlockedStreams)
{
_maxBlockedStreams = maxBlockedStreams;
}

public int getCapacity()
{
return _context.getDynamicTable().getCapacity();
}

/**
* Set the capacity of the DynamicTable and send a instruction to set the capacity on the remote Decoder.
*
Expand Down Expand Up @@ -411,7 +426,7 @@ private boolean referenceEntry(Entry entry, StreamInfo streamInfo)
return true;
}

if (_blockedStreams < _maxBlockedStreams)
if (_blockedStreams < getMaxBlockedStreams())
{
_blockedStreams++;
sectionInfo.block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ protected GoAwayFrame newGoAwayFrame(boolean graceful)
return super.newGoAwayFrame(graceful);
}

@Override
protected void onSettingMaxTableCapacity(long value)
{
getProtocolSession().getQpackEncoder().setCapacity((int)value);
}

@Override
protected void onSettingMaxFieldSectionSize(long value)
{
getProtocolSession().getQpackDecoder().setMaxHeaderSize((int)value);
}

@Override
protected void onSettingMaxBlockedStreams(long value)
{
ServerHTTP3Session session = getProtocolSession();
session.getQpackDecoder().setMaxBlockedStreams((int)value);
session.getQpackEncoder().setMaxBlockedStreams((int)value);
}

private void notifyAccept()
{
Server.Listener listener = getListener();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public QpackDecoder getQpackDecoder()
return decoder;
}

public QpackEncoder getQpackEncoder()
{
return encoder;
}

public HTTP3SessionServer getSessionServer()
{
return session;
Expand Down
Loading

0 comments on commit 1b703ae

Please sign in to comment.