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

chore: Fix PostProcessorRegistrationDelegate warning caused by routingFilterHandler #3769

Merged
merged 4 commits into from
Sep 17, 2024
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
1 change: 1 addition & 0 deletions api-catalog-services/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ logging:

# New Config
org.apache: WARN #org.apache.catalina, org.apache.coyote, org.apache.tomcat
org.apache.tomcat.util.net.SSLUtilBase: ERROR
org.eclipse.jetty: WARN
org.apache.http.conn.ssl.DefaultHostnameVerifier: DEBUG #logs only SSLException
javax.net.ssl: ERROR
Expand Down
1 change: 1 addition & 0 deletions discovery-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ logging:
org.eclipse.jetty: WARN
org.apache.http.conn.ssl.DefaultHostnameVerifier: DEBUG #logs only SSLException
javax.net.ssl: ERROR
org.apache.tomcat.util.net.SSLUtilBase: ERROR
# com.netflix.eureka.resources: WARN

apiml:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,13 @@ public HttpsFactory factory() {
}

/**
* This bean processor is used to override bean routingFilter defined at
* org.springframework.cloud.gateway.config.GatewayAutoConfiguration.NettyConfiguration#routingFilter(HttpClient, ObjectProvider, HttpClientProperties)
* <p>
* There is no simple way how to override this specific bean, but bean processing could handle that.
*
* @param httpClient default http client
* @param headersFiltersProvider header filter for spring gateway router
* @param properties client HTTP properties
* @return bean processor to replace NettyRoutingFilter by NettyRoutingFilterApiml
* @return instance of NettyRoutingFilterApiml
*/
@Bean
public BeanPostProcessor routingFilterHandler(HttpClient httpClient, ObjectProvider<List<HttpHeadersFilter>> headersFiltersProvider, HttpClientProperties properties) {
public NettyRoutingFilterApiml createNettyRoutingFilterApiml(HttpClient httpClient, ObjectProvider<List<HttpHeadersFilter>> headersFiltersProvider, HttpClientProperties properties) {
// obtain SSL contexts (one with keystore to support client cert sign and truststore, second just with truststore)
SslContext justTruststore = sslContext(false);
SslContext withKeystore = sslContext(true);
Expand All @@ -199,13 +194,27 @@ public BeanPostProcessor routingFilterHandler(HttpClient httpClient, ObjectProvi
// construct http clients with different SSL configuration - with / without client certs
var httpClientNoCert = httpClient.secure(builderJustTruststore.build());
var httpClientClientCert = httpClient.secure(builderWithKeystore.build());

return new NettyRoutingFilterApiml(httpClientNoCert, httpClientClientCert, headersFiltersProvider, properties);
}

/**
* This bean processor is used to override bean routingFilter defined at
* org.springframework.cloud.gateway.config.GatewayAutoConfiguration.NettyConfiguration#routingFilter(HttpClient, ObjectProvider, HttpClientProperties)
* <p>
* There is no simple way how to override this specific bean, but bean processing could handle that.
*
* @return bean processor to replace NettyRoutingFilter by NettyRoutingFilterApiml
*/
@Bean
public static BeanPostProcessor routingFilterHandler(ApplicationContext context) {
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if ("routingFilter".equals(beanName)) {
log.debug("Updating routing bean {}", NettyRoutingFilterApiml.class);
// once is creating original bean by autoconfiguration replace it with custom implementation
return new NettyRoutingFilterApiml(httpClientNoCert, httpClientClientCert, headersFiltersProvider, properties);
return context.getBean(NettyRoutingFilterApiml.class);
}
// do not touch any other bean
return bean;
Expand Down
4 changes: 4 additions & 0 deletions mock-services/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
logging:
level:
ROOT: INFO
org.apache.tomcat.util.net.SSLUtilBase: ERROR
spring:
application:
name: Mock services
Expand Down
Loading