Merge branch 'develop' into feature/log_appender
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
<spring-session-bom.version>Dragonfruit-SR3</spring-session-bom.version>
|
||||
<reactor-bom.version>Dysprosium-SR22</reactor-bom.version>
|
||||
<lettuce.version>5.3.7.RELEASE</lettuce.version>
|
||||
<netty.version>4.1.67.Final</netty.version>
|
||||
<netty.version>4.1.68.Final</netty.version>
|
||||
<httpcore.version>4.4.14</httpcore.version>
|
||||
<log4j2.version>2.14.1</log4j2.version>
|
||||
<slf4j.version>1.7.32</slf4j.version>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package we;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2020 the original author or authors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package we.config;
|
||||
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.web.reactive.function.client.ClientHttpConnectorAutoConfiguration;
|
||||
import org.springframework.boot.web.reactive.function.client.WebClientCustomizer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
/**
|
||||
* @author hongqiaowei
|
||||
*/
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(WebClient.class)
|
||||
@AutoConfigureAfter({CodecsAutoConfiguration.class, ClientHttpConnectorAutoConfiguration.class})
|
||||
public class WebClientBuilderConfig {
|
||||
|
||||
private final WebClient.Builder webClientBuilder;
|
||||
|
||||
public WebClientBuilderConfig(ObjectProvider<WebClientCustomizer> customizerProvider) {
|
||||
this.webClientBuilder = WebClient.builder();
|
||||
customizerProvider.orderedStream().forEach(
|
||||
(customizer) -> {
|
||||
customizer.customize(this.webClientBuilder);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public WebClient.Builder getBuilder() {
|
||||
return this.webClientBuilder.clone();
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.netty.http.client.HttpClient;
|
||||
import reactor.netty.tcp.TcpClient;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.net.ssl.SSLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -125,7 +126,13 @@ public abstract class WebClientConfig {
|
||||
// @Resource
|
||||
// ReactorClientHttpConnector reactorClientHttpConnector;
|
||||
|
||||
public WebClient webClient(WebClient.Builder webClientBuilder) {
|
||||
// @Resource
|
||||
// WebClient.Builder webClientBuilder;
|
||||
|
||||
@Resource
|
||||
WebClientBuilderConfig webClientBuilderConfig;
|
||||
|
||||
public WebClient webClient() {
|
||||
|
||||
HttpClient httpClient = HttpClient.create()
|
||||
.tcpConfiguration(
|
||||
@@ -170,9 +177,10 @@ public abstract class WebClientConfig {
|
||||
}
|
||||
}
|
||||
|
||||
return webClientBuilder.exchangeStrategies(
|
||||
ExchangeStrategies.builder().codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1))
|
||||
.build()
|
||||
return webClientBuilderConfig.getBuilder()
|
||||
.exchangeStrategies(
|
||||
ExchangeStrategies.builder().codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1))
|
||||
.build()
|
||||
)
|
||||
.clientConnector(new ReactorClientHttpConnector(httpClient))
|
||||
.build();
|
||||
|
||||
@@ -73,13 +73,13 @@ public class FizzServerHttpRequestDecorator extends ServerHttpRequestDecorator {
|
||||
return body;
|
||||
}
|
||||
|
||||
public DataBuffer getRawBody() {
|
||||
final DataBuffer[] raw = {null};
|
||||
body.subscribe(
|
||||
dataBuffer -> {
|
||||
raw[0] = dataBuffer;
|
||||
}
|
||||
);
|
||||
return raw[0];
|
||||
}
|
||||
// public DataBuffer getRawBody() {
|
||||
// final DataBuffer[] raw = {null};
|
||||
// body.subscribe(
|
||||
// dataBuffer -> {
|
||||
// raw[0] = dataBuffer;
|
||||
// }
|
||||
// );
|
||||
// return raw[0];
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -82,11 +82,6 @@ public class AggregateFilter implements WebFilter {
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
|
||||
FilterResult pfr = WebUtils.getPrevFilterResult(exchange);
|
||||
if (!pfr.success) {
|
||||
return WebUtils.getDirectResponse(exchange);
|
||||
}
|
||||
|
||||
String serviceId = WebUtils.getBackendService(exchange);
|
||||
if (serviceId == null) {
|
||||
return chain.filter(exchange);
|
||||
@@ -106,6 +101,11 @@ public class AggregateFilter implements WebFilter {
|
||||
}
|
||||
}
|
||||
|
||||
FilterResult pfr = WebUtils.getPrevFilterResult(exchange);
|
||||
if (!pfr.success) {
|
||||
return WebUtils.getDirectResponse(exchange);
|
||||
}
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
ServerHttpResponse serverHttpResponse = exchange.getResponse();
|
||||
|
||||
@@ -96,7 +96,7 @@ public class FilterExceptionHandlerConfig {
|
||||
}
|
||||
}
|
||||
Mono<Void> vm;
|
||||
Object fc = exchange.getAttributes().get(WebUtils.FILTER_CONTEXT);
|
||||
Object fc = exchange.getAttribute(WebUtils.FILTER_CONTEXT);
|
||||
if (fc == null) { // t came from flow control filter
|
||||
StringBuilder b = ThreadContext.getStringBuilder();
|
||||
WebUtils.request2stringBuilder(exchange, b);
|
||||
|
||||
@@ -84,4 +84,11 @@ public final class FizzPluginFilterChain {
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mono<Void> next(ServerWebExchange exchange, List<PluginConfig> pcs) {
|
||||
Iterator<PluginConfig> it = pcs.iterator();
|
||||
Map<String, Object> attris = exchange.getAttributes();
|
||||
attris.put(pluginConfigsIt, it);
|
||||
return next(exchange);
|
||||
}
|
||||
}
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -10,7 +10,7 @@
|
||||
<reactor-bom.version>Dysprosium-SR22</reactor-bom.version>
|
||||
<lettuce.version>5.3.7.RELEASE</lettuce.version>
|
||||
<nacos.cloud.version>2.2.5.RELEASE</nacos.cloud.version>
|
||||
<netty.version>4.1.67.Final</netty.version>
|
||||
<netty.version>4.1.68.Final</netty.version>
|
||||
<httpcore.version>4.4.14</httpcore.version>
|
||||
<log4j2.version>2.14.1</log4j2.version>
|
||||
<slf4j.version>1.7.32</slf4j.version>
|
||||
|
||||
Reference in New Issue
Block a user