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

Use DefaultHttpClient builder #972

Draft
wants to merge 1 commit into
base: 4.2.x
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ tasks.withType(Javadoc).configureEach {

repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencies {

repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
}

sourceSets {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
repositories {
repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
micronaut = "4.6.2"
micronaut = "4.7.0-SNAPSHOT"
micronaut-platform = "4.5.1"
micronaut-docs = "2.0.0"
fn = '1.0.190'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ final class NettyHttpClient implements HttpClient {
final List<RequestInterceptor> requestInterceptors;
final List<OciNettyClientFilter<?>> nettyClientFilter;
final ExecutorService blockingIoExecutor;
final String host;
final int port;
final boolean buffered;
final Closeable upstreamHttpClient;
final ConnectionManager connectionManager;
Expand Down Expand Up @@ -92,7 +90,7 @@ final class NettyHttpClient implements HttpClient {
if (builder.properties.containsKey(StandardClientProperties.READ_TIMEOUT)) {
cfg.setReadTimeout((Duration) builder.properties.get(StandardClientProperties.READ_TIMEOUT));
}
mnClient = new DefaultHttpClient((URI) null, cfg);
mnClient = DefaultHttpClient.builder().configuration(cfg).build();
blockingIoExecutor = Executors.newCachedThreadPool();
jsonMapper = OciSdkMicronautSerializer.getDefaultObjectMapper();
} else {
Expand Down Expand Up @@ -134,9 +132,7 @@ final class NettyHttpClient implements HttpClient {
nettyClientFilter = Collections.emptyList();
}

requestKey = new DefaultHttpClient.RequestKey(mnClient, builder.baseUri);
this.port = builder.baseUri.getPort();
this.host = builder.baseUri.getHost();
requestKey = new DefaultHttpClient.RequestKey(mnClient, this.baseUri);
this.buffered = builder.buffered;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,10 @@
import com.oracle.bmc.http.internal.LogHeadersFilter;
import com.oracle.bmc.http.signing.RequestSigner;
import com.oracle.bmc.util.internal.StringUtils;
import io.micronaut.buffer.netty.NettyByteBufferFactory;
import io.micronaut.core.annotation.AnnotationMetadataResolver;
import io.micronaut.core.convert.ConversionService;
import io.micronaut.core.io.ResourceResolver;
import io.micronaut.http.MediaType;
import io.micronaut.http.body.ContextlessMessageBodyHandlerRegistry;
import io.micronaut.http.client.netty.DefaultHttpClient;
import io.micronaut.http.codec.MediaTypeCodecRegistry;
import io.micronaut.http.netty.body.NettyByteBufMessageBodyHandler;
import io.micronaut.http.netty.body.NettyJsonHandler;
import io.micronaut.http.netty.body.NettyJsonStreamHandler;
import io.micronaut.http.netty.body.NettyWritableBodyWriter;
import io.micronaut.json.JsonMapper;
import io.micronaut.json.codec.JsonMediaTypeCodec;
import io.micronaut.json.codec.JsonStreamMediaTypeCodec;
import io.micronaut.oraclecloud.httpclient.netty.ManagedNettyHttpProvider;
import io.micronaut.oraclecloud.httpclient.netty.OciNettyClientFilter;
import io.micronaut.runtime.ApplicationConfiguration;
import io.netty.channel.MultithreadEventLoopGroup;
import io.netty.util.concurrent.DefaultThreadFactory;

import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
Expand Down Expand Up @@ -145,28 +129,11 @@ public static OkeNettyClientSslBuilder okeNettyClientSslBuilder(String path) {
}

DefaultHttpClient defaultHttpClient() {
JsonMapper mapper = JsonMapper.createDefault();
ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
ContextlessMessageBodyHandlerRegistry registry = new ContextlessMessageBodyHandlerRegistry(
applicationConfiguration,
NettyByteBufferFactory.DEFAULT,
new NettyByteBufMessageBodyHandler(),
new NettyWritableBodyWriter(applicationConfiguration)
);
registry.add(MediaType.APPLICATION_JSON_TYPE, new NettyJsonHandler<>(mapper));
registry.add(MediaType.APPLICATION_JSON_STREAM_TYPE, new NettyJsonStreamHandler<>(mapper));
// Set ca cert when talking to proxymux using https.

return new DefaultHttpClient(null,
getOkeHttpClientConfiguration(), null, new DefaultThreadFactory(MultithreadEventLoopGroup.class),
okeNettyClientSslBuilder(KUBERNETES_SERVICE_ACCOUNT_CERT_PATH),
MediaTypeCodecRegistry.of(
new JsonMediaTypeCodec(mapper, applicationConfiguration, null),
new JsonStreamMediaTypeCodec(mapper, applicationConfiguration, null)
),
registry,
AnnotationMetadataResolver.DEFAULT,
ConversionService.SHARED);
return DefaultHttpClient.builder()
.configuration(getOkeHttpClientConfiguration())
.nettyClientSslBuilder(okeNettyClientSslBuilder(KUBERNETES_SERVICE_ACCOUNT_CERT_PATH))
.build();
}

@Override
Expand Down
7 changes: 7 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ pluginManagement {
includeBuild("settings-build-logic")
}

dependencyResolutionManagement {
repositories {
mavenCentral()
maven { setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots") }
}
}

buildscript {
configurations {
classpath {
Expand Down
Loading