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

OAP-227 Close long lived connections when they have handled X requests #249

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ public void testCloseConnection() throws IOException {
exchange.responseOk( "ok", Http.ContentType.TEXT_PLAIN );
} );

for( int i = 0; i < 5; i++ ) {
assertThat( Client.DEFAULT.get( "http://localhost:" + testHttpPort + "/test" ).contentString() ).isEqualTo( "ok" );
var client = Client.custom().setMaxConnTotal( 10 ).setMaxConnPerRoute( 10 ).build();

for( int i = 0; i < 101; i++ ) {
assertThat( client.get( "http://localhost:" + testHttpPort + "/test" ).contentString() ).isEqualTo( "ok" );
}

assertThat( ids ).hasSize( 3 );
assertThat( ids ).hasSize( 51 );
assertThat( keepaliveRequestsHandler.requests ).hasSize( 1 );
}
}
Expand Down
3 changes: 1 addition & 2 deletions oap-stdlib-test/src/test/java/oap/io/IoStreamsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public void encodingResolve() {
assertThat( ZSTD.resolve( Paths.get( "/x/a.txt.zst" ) ) ).isEqualTo( Paths.get( "/x/a.txt.zst" ) );
}

@Test
@SneakyThrows
@Test( enabled = false )
public void compressionLevel() {
List<List<String>> sets = new ArrayList<>();
Random random = new Random();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.server.ServerConnection;
import io.undertow.util.Headers;
import oap.http.server.nio.AbstractNioHandler;

import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -32,6 +33,9 @@ public void handleRequest( HttpServerExchange exchange ) throws Exception {
long requests = count.incrementAndGet();

try {
if( requests >= keepaliveRequests ) {
exchange.getResponseHeaders().put( Headers.CONNECTION, "close" );
}
httpHandler.handleRequest( exchange );
} finally {
if( requests >= keepaliveRequests ) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</repositories>

<properties>
<oap.project.version>21.9.0</oap.project.version>
<oap.project.version>21.9.1</oap.project.version>

<oap.deps.config.version>21.0.0</oap.deps.config.version>
<oap.deps.oap-teamcity.version>21.0.1</oap.deps.oap-teamcity.version>
Expand Down
Loading