Skip to content
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 @@ -300,7 +300,13 @@ public static boolean defaultUseOnlyEpollNativeTransport() {
}

public static int defaultIoThreadsCount() {
return AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT_CONFIG_ROOT + IO_THREADS_COUNT_CONFIG);
int threads = AsyncHttpClientConfigHelper.getAsyncHttpClientConfig().getInt(ASYNC_CLIENT_CONFIG_ROOT + IO_THREADS_COUNT_CONFIG);

// If threads value is -1 then we will automatically pick number of available processors.
if (threads == -1) {
threads = Runtime.getRuntime().availableProcessors();
}
return threads;
}

public static int defaultHashedWheelTimerTickDuration() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;

public class AsyncHttpClientConfigHelper {
public final class AsyncHttpClientConfigHelper {

private static volatile Config config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ public ChannelManager(final AsyncHttpClientConfig config, Timer nettyTimer) {

httpBootstrap = newBootstrap(transportFactory, eventLoopGroup, config);
wsBootstrap = newBootstrap(transportFactory, eventLoopGroup, config);

// for reactive streams
httpBootstrap.option(ChannelOption.AUTO_READ, false);
}

private static TransportFactory<? extends Channel, ? extends EventLoopGroup> getNativeTransportFactory(AsyncHttpClientConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.asynchttpclient.maxConnectionsPerHost=-1
org.asynchttpclient.acquireFreeChannelTimeout=0
org.asynchttpclient.connectTimeout=5000
org.asynchttpclient.pooledConnectionIdleTimeout=60000
org.asynchttpclient.connectionPoolCleanerPeriod=1000
org.asynchttpclient.connectionPoolCleanerPeriod=100
org.asynchttpclient.readTimeout=60000
org.asynchttpclient.requestTimeout=60000
org.asynchttpclient.connectionTtl=-1
Expand Down Expand Up @@ -49,7 +49,8 @@ org.asynchttpclient.keepEncodingHeader=false
org.asynchttpclient.shutdownQuietPeriod=2000
org.asynchttpclient.shutdownTimeout=15000
org.asynchttpclient.useNativeTransport=false
org.asynchttpclient.ioThreadsCount=0
org.asynchttpclient.useOnlyEpollNativeTransport=false
org.asynchttpclient.ioThreadsCount=-1
org.asynchttpclient.hashedWheelTimerTickDuration=100
org.asynchttpclient.hashedWheelTimerSize=512
org.asynchttpclient.expiredCookieEvictionDelay=30000
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
*/
package org.asynchttpclient;

import io.github.artsok.RepeatedIfExceptionsTest;
import org.asynchttpclient.config.AsyncHttpClientConfigDefaults;
import org.asynchttpclient.config.AsyncHttpClientConfigHelper;
import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;

Expand All @@ -27,127 +27,127 @@

public class AsyncHttpClientDefaultsTest {

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultUseOnlyEpollNativeTransport() {
assertFalse(AsyncHttpClientConfigDefaults.defaultUseOnlyEpollNativeTransport());
testBooleanSystemProperty("useOnlyEpollNativeTransport", "defaultUseOnlyEpollNativeTransport", "false");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultMaxTotalConnections() {
assertEquals(AsyncHttpClientConfigDefaults.defaultMaxConnections(), -1);
testIntegerSystemProperty("maxConnections", "defaultMaxConnections", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultMaxConnectionPerHost() {
assertEquals(AsyncHttpClientConfigDefaults.defaultMaxConnectionsPerHost(), -1);
testIntegerSystemProperty("maxConnectionsPerHost", "defaultMaxConnectionsPerHost", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultConnectTimeOut() {
assertEquals(AsyncHttpClientConfigDefaults.defaultConnectTimeout(), 5 * 1000);
testIntegerSystemProperty("connectTimeout", "defaultConnectTimeout", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultPooledConnectionIdleTimeout() {
assertEquals(AsyncHttpClientConfigDefaults.defaultPooledConnectionIdleTimeout(), 60 * 1000);
testIntegerSystemProperty("pooledConnectionIdleTimeout", "defaultPooledConnectionIdleTimeout", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultReadTimeout() {
assertEquals(AsyncHttpClientConfigDefaults.defaultReadTimeout(), 60 * 1000);
testIntegerSystemProperty("readTimeout", "defaultReadTimeout", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultRequestTimeout() {
assertEquals(AsyncHttpClientConfigDefaults.defaultRequestTimeout(), 60 * 1000);
testIntegerSystemProperty("requestTimeout", "defaultRequestTimeout", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultConnectionTtl() {
assertEquals(AsyncHttpClientConfigDefaults.defaultConnectionTtl(), -1);
testIntegerSystemProperty("connectionTtl", "defaultConnectionTtl", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultFollowRedirect() {
assertFalse(AsyncHttpClientConfigDefaults.defaultFollowRedirect());
testBooleanSystemProperty("followRedirect", "defaultFollowRedirect", "true");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultMaxRedirects() {
assertEquals(AsyncHttpClientConfigDefaults.defaultMaxRedirects(), 5);
testIntegerSystemProperty("maxRedirects", "defaultMaxRedirects", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultCompressionEnforced() {
assertFalse(AsyncHttpClientConfigDefaults.defaultCompressionEnforced());
testBooleanSystemProperty("compressionEnforced", "defaultCompressionEnforced", "true");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultUserAgent() {
assertEquals(AsyncHttpClientConfigDefaults.defaultUserAgent(), "AHC/2.1");
testStringSystemProperty("userAgent", "defaultUserAgent", "MyAHC");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultUseProxySelector() {
assertFalse(AsyncHttpClientConfigDefaults.defaultUseProxySelector());
testBooleanSystemProperty("useProxySelector", "defaultUseProxySelector", "true");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultUseProxyProperties() {
assertFalse(AsyncHttpClientConfigDefaults.defaultUseProxyProperties());
testBooleanSystemProperty("useProxyProperties", "defaultUseProxyProperties", "true");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultStrict302Handling() {
assertFalse(AsyncHttpClientConfigDefaults.defaultStrict302Handling());
testBooleanSystemProperty("strict302Handling", "defaultStrict302Handling", "true");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultAllowPoolingConnection() {
assertTrue(AsyncHttpClientConfigDefaults.defaultKeepAlive());
testBooleanSystemProperty("keepAlive", "defaultKeepAlive", "false");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultMaxRequestRetry() {
assertEquals(AsyncHttpClientConfigDefaults.defaultMaxRequestRetry(), 5);
testIntegerSystemProperty("maxRequestRetry", "defaultMaxRequestRetry", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultDisableUrlEncodingForBoundRequests() {
assertFalse(AsyncHttpClientConfigDefaults.defaultDisableUrlEncodingForBoundRequests());
testBooleanSystemProperty("disableUrlEncodingForBoundRequests", "defaultDisableUrlEncodingForBoundRequests", "true");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultUseInsecureTrustManager() {
assertFalse(AsyncHttpClientConfigDefaults.defaultUseInsecureTrustManager());
testBooleanSystemProperty("useInsecureTrustManager", "defaultUseInsecureTrustManager", "false");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultHashedWheelTimerTickDuration() {
assertEquals(AsyncHttpClientConfigDefaults.defaultHashedWheelTimerTickDuration(), 100);
testIntegerSystemProperty("hashedWheelTimerTickDuration", "defaultHashedWheelTimerTickDuration", "100");
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testDefaultHashedWheelTimerSize() {
assertEquals(AsyncHttpClientConfigDefaults.defaultHashedWheelTimerSize(), 512);
testIntegerSystemProperty("hashedWheelTimerSize", "defaultHashedWheelTimerSize", "512");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
*/
package org.asynchttpclient;

import io.github.artsok.RepeatedIfExceptionsTest;
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.http.HttpHeaders;
import org.asynchttpclient.testserver.HttpServer;
import org.asynchttpclient.testserver.HttpTest;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;

import java.util.Arrays;
Expand Down Expand Up @@ -69,9 +69,8 @@ private static String getTargetUrl() {
return server.getHttpUrl() + "/foo/bar";
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void getWithOnHeadersReceivedAbort() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {
server.enqueueEcho();
Expand All @@ -86,9 +85,8 @@ public State onHeadersReceived(HttpHeaders headers) {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncStreamPOSTTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -129,9 +127,8 @@ public String onCompleted() {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncStreamInterruptTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -171,9 +168,8 @@ public void onThrowable(Throwable t) {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncStreamFutureTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -224,9 +220,8 @@ public void onThrowable(Throwable t) {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncStreamThrowableRefusedTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -258,9 +253,8 @@ public void onThrowable(Throwable t) {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncStreamReusePOSTTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -342,9 +336,8 @@ public String onCompleted() {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncStream302RedirectWithBody() throws Throwable {

withClient(config().setFollowRedirect(true)).run(client ->
withServer(server).run(server -> {

Expand All @@ -365,10 +358,9 @@ public void asyncStream302RedirectWithBody() throws Throwable {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
@Timeout(unit = TimeUnit.MILLISECONDS, value = 3000)
public void asyncStreamJustStatusLine() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -439,9 +431,8 @@ public Integer onCompleted() {

// This test is flaky - see https://github.com/AsyncHttpClient/async-http-client/issues/1728#issuecomment-699962325
// For now, just run again if fails
@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void asyncOptionsTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {

Expand Down Expand Up @@ -483,9 +474,8 @@ public String onCompleted() {
}));
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void closeConnectionTest() throws Throwable {

withClient().run(client ->
withServer(server).run(server -> {
server.enqueueEcho();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
*/
package org.asynchttpclient;

import io.github.artsok.RepeatedIfExceptionsTest;
import io.netty.handler.codec.http.HttpHeaders;
import jakarta.servlet.AsyncContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.io.PrintWriter;
Expand Down Expand Up @@ -90,7 +90,7 @@ public void handle(String s, Request request, HttpServletRequest req, final Http
};
}

@Test
@RepeatedIfExceptionsTest(repeats = 5)
public void testStream() throws Exception {
try (AsyncHttpClient ahc = asyncHttpClient()) {
final AtomicBoolean err = new AtomicBoolean(false);
Expand Down
Loading