Skip to content
Open
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
29 changes: 19 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ subprojects {
apply plugin: 'signing'
apply plugin: 'maven-publish'

sourceCompatibility = '17'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
}

ext {
springBootVersion = '3.4.1'
springBootVersion = '4.0.0'
resilience4jVersion = '2.3.0'
okHttpVersion = '4.12.0'
httpClient5Version = '5.5.1'

group = 'com.github.mkopylec'
pomContent = {
Expand Down Expand Up @@ -54,19 +58,24 @@ subprojects {
}

group = project.ext.group
archivesBaseName = name
base {
archivesName = name
}
version = scmVersion.version

dependencies {
api group: 'org.springframework', name: 'spring-web', version: '6.2.0'
api group: 'org.springframework', name: 'spring-web', version: '7.0.1'
api group: 'io.github.resilience4j', name: 'resilience4j-circuitbreaker', version: resilience4jVersion
api group: 'io.github.resilience4j', name: 'resilience4j-ratelimiter', version: resilience4jVersion
api group: 'io.github.resilience4j', name: 'resilience4j-retry', version: resilience4jVersion
api group: 'io.github.resilience4j', name: 'resilience4j-micrometer', version: resilience4jVersion
api group: 'io.micrometer', name: 'micrometer-core', version: '1.14.2'
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0'
api group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
api group: 'commons-io', name: 'commons-io', version: '2.18.0'
api group: 'io.micrometer', name: 'micrometer-core', version: '1.16.0'
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.20.0'
api group: 'org.apache.commons', name: 'commons-collections4', version: '4.5.0'
api group: 'commons-io', name: 'commons-io', version: '2.21.0'

testImplementation 'org.junit.jupiter:junit-jupiter:6.0.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

test {
Expand All @@ -85,5 +94,5 @@ nexusPublishing {
}

wrapper {
gradleVersion = '8.12'
gradleVersion = '9.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.mkopylec.charon.forwarding;

import com.github.mkopylec.charon.configuration.RequestMappingConfiguration;
import org.springframework.boot.web.reactive.filter.OrderedWebFilter;
import org.springframework.boot.webflux.filter.OrderedWebFilter;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.web.reactive.function.client.WebClient;
Expand Down
7 changes: 4 additions & 3 deletions charon-spring-webflux/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ logging:
level:
com.github.mkopylec.charon: trace

server:
error:
include-message: always
spring:
web:
error:
include-message: always
2 changes: 1 addition & 1 deletion charon-spring-webmvc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'jacoco'
dependencies {
api project(':charon-common').sourceSets.main.output
api group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion
api group: 'com.squareup.okhttp3', name: 'okhttp', version: okHttpVersion
api group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: httpClient5Version

testImplementation project(':charon-test')
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.github.mkopylec.charon.forwarding;

import org.apache.hc.client5.http.classic.HttpClient;
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;

class HttpComponentsClientHttpRequestFactoryCreator implements ClientHttpRequestFactoryCreator {

private HttpClient httpClient;

HttpComponentsClientHttpRequestFactoryCreator() {
httpClient = HttpClientBuilder.create()
.disableRedirectHandling()
.build();
}

@Override
public ClientHttpRequestFactory createRequestFactory(TimeoutConfiguration configuration) {
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient);
requestFactory.setConnectionRequestTimeout(configuration.getConnection());
requestFactory.setReadTimeout(configuration.getRead());
return requestFactory;
}

void setHttpClient(HttpClient httpClient) {
this.httpClient = httpClient;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.github.mkopylec.charon.forwarding;


import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;

public class HttpComponentsClientHttpRequestFactoryCreatorConfigurer extends ClientHttpRequestFactoryCreatorConfigurer<HttpComponentsClientHttpRequestFactoryCreator> {

private HttpComponentsClientHttpRequestFactoryCreatorConfigurer() {
super(new HttpComponentsClientHttpRequestFactoryCreator());
}

public static HttpComponentsClientHttpRequestFactoryCreatorConfigurer httpComponentsClientHttpRequestFactoryCreator() {
return new HttpComponentsClientHttpRequestFactoryCreatorConfigurer();
}

public HttpComponentsClientHttpRequestFactoryCreatorConfigurer httpClient(HttpClientBuilder httpClient) {
configuredObject.setHttpClient(httpClient.build());
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@ public boolean hasError(ClientHttpResponse response) {
return false;
}

@Override
public void handleError(ClientHttpResponse response) {
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.ArrayList;
import java.util.List;

import static com.github.mkopylec.charon.forwarding.OkClientHttpRequestFactoryCreatorConfigurer.okClientHttpRequestFactoryCreator;
import static com.github.mkopylec.charon.forwarding.HttpComponentsClientHttpRequestFactoryCreatorConfigurer.httpComponentsClientHttpRequestFactoryCreator;
import static com.github.mkopylec.charon.forwarding.TimeoutConfigurer.timeout;
import static java.util.stream.Collectors.toList;

Expand All @@ -22,7 +22,7 @@ public class RestTemplateConfiguration implements Valid {

RestTemplateConfiguration() {
this.timeoutConfiguration = timeout().configure();
this.clientHttpRequestFactoryCreator = okClientHttpRequestFactoryCreator().configure();
this.clientHttpRequestFactoryCreator = httpComponentsClientHttpRequestFactoryCreator().configure();
clientHttpRequestInterceptors = new ArrayList<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public HttpStatusCode getStatusCode() {
return status;
}

@Override
public int getRawStatusCode() {
return status.value();
}

@Override
public String getStatusText() {
return status.toString();
Expand Down
6 changes: 4 additions & 2 deletions charon-spring-webmvc/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ logging:
server:
tomcat:
connection-timeout: 0
error:
include-message: always
spring:
web:
error:
include-message: always
4 changes: 3 additions & 1 deletion charon-test/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
dependencies {
api project(':charon-common')
api group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion
api group: 'org.springframework.boot', name: 'spring-boot-starter-restclient', version: springBootVersion
api group: 'org.springframework.boot', name: 'spring-boot-resttestclient', version: springBootVersion
api group: 'org.spockframework', name: 'spock-spring', version: '2.4-M5-groovy-4.0'
api group: 'org.mock-server', name: 'mockserver-netty', version: '5.15.0'
api group: 'com.squareup.okhttp3', name: 'okhttp', version: okHttpVersion
api group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: httpClient5Version
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ResponseAssertion {
}

ResponseAssertion notContainsHeaders(String... headers) {
headers.each { name -> assert !response.headers.containsKey(name) }
headers.each { name -> assert !response.headers.containsHeader(name) }
return this
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.github.mkopylec.charon.test.specification
import com.github.mkopylec.charon.test.stubs.OutgoingServer
import com.github.mkopylec.charon.test.utils.HttpClient
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.resttestclient.autoconfigure.AutoConfigureTestRestTemplate
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.TestPropertySource
import spock.lang.Specification
Expand All @@ -12,6 +13,7 @@ import static com.github.mkopylec.charon.test.utils.MeterRegistryProvider.clearM
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT

@SpringBootTest(webEnvironment = RANDOM_PORT)
@AutoConfigureTestRestTemplate
@TestPropertySource(properties = ['default-charon-configuration = false'])
abstract class BasicSpec extends Specification {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.github.mkopylec.charon.test.utils

import okhttp3.OkHttpClient
import org.springframework.boot.test.web.client.TestRestTemplate
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.springframework.boot.resttestclient.TestRestTemplate
import org.springframework.http.HttpEntity
import org.springframework.http.HttpHeaders
import org.springframework.http.HttpMethod
import org.springframework.http.ResponseEntity
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory
import org.springframework.stereotype.Component

@Component
Expand Down Expand Up @@ -39,14 +39,12 @@ class HttpClient {
}

private void setup() {
def client = new OkHttpClient.Builder()
.followRedirects(false)
.followSslRedirects(false)
def client = HttpClientBuilder.create()
.disableRedirectHandling()
.build()
def requestFactory = new OkHttp3ClientHttpRequestFactory(client)
requestFactory.connectTimeout = 100
def requestFactory = new HttpComponentsClientHttpRequestFactory(client)
requestFactory.connectionRequestTimeout = 100
requestFactory.readTimeout = 100000
requestFactory.writeTimeout = 100000
restTemplate.restTemplate.requestFactory = requestFactory
}
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading