Skip to content

Commit 3582c55

Browse files
authored
Merge pull request #72 from aoju/develop
v5.2.2
2 parents 91ab70d + 8acf622 commit 3582c55

File tree

8 files changed

+48
-35
lines changed

8 files changed

+48
-35
lines changed

bus-bom/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
<artifactId>bus-extra</artifactId>
5151
<version>${project.version}</version>
5252
</dependency>
53+
<dependency>
54+
<groupId>${project.groupId}</groupId>
55+
<artifactId>bus-forest</artifactId>
56+
<version>${project.version}</version>
57+
</dependency>
58+
<dependency>
59+
<groupId>${project.groupId}</groupId>
60+
<artifactId>bus-gitlab</artifactId>
61+
<version>${project.version}</version>
62+
</dependency>
5363
<dependency>
5464
<groupId>${project.groupId}</groupId>
5565
<artifactId>bus-health</artifactId>

bus-core/src/main/java/org/aoju/bus/core/annotation/Inject.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
* 如果为真,且没有找到适当的绑定,则注入器将跳过此方法或字段的注入, 而不会产生错误
3939
* 当应用到一个字段时,任何已经分配给该字段的默认值将保持不变
4040
* 当应用于某个方法时,只有在找到的所有参数的绑定时才调用该方法
41+
* @return the true/false
4142
*/
4243
boolean optional() default false;
44+
4345
}

bus-http/src/main/java/org/aoju/bus/http/HttpClient.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package org.aoju.bus.http;
2525

26+
import org.aoju.bus.core.consts.Charset;
2627
import org.aoju.bus.core.consts.Httpd;
2728
import org.aoju.bus.core.consts.MediaType;
2829
import org.aoju.bus.core.lang.exception.InstrumentException;
@@ -227,7 +228,7 @@ public HttpClient(final Dns dns,
227228
* @return String
228229
*/
229230
public static String get(final String url) {
230-
return get(url, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
231+
return get(url, Charset.DEFAULT_UTF_8);
231232
}
232233

233234
/**
@@ -263,7 +264,7 @@ public static String get(final String url, final boolean isAsync) {
263264
* @return String
264265
*/
265266
public static String get(final String url, final Map<String, Object> queryMap) {
266-
return get(url, queryMap, null, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
267+
return get(url, queryMap, null, Charset.DEFAULT_UTF_8);
267268
}
268269

269270
/**
@@ -275,7 +276,7 @@ public static String get(final String url, final Map<String, Object> queryMap) {
275276
* @return String
276277
*/
277278
public static String get(final String url, final Map<String, Object> queryMap, Map<String, String> headerMap) {
278-
return get(url, queryMap, headerMap, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
279+
return get(url, queryMap, headerMap, Charset.DEFAULT_UTF_8);
279280
}
280281

281282
/**
@@ -364,7 +365,7 @@ public static String post(final String url, final Map<String, Object> formMap) {
364365
*/
365366
public static String post(final String url, final String data,
366367
final String mediaType) {
367-
return post(url, data, mediaType, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
368+
return post(url, data, mediaType, Charset.DEFAULT_UTF_8);
368369
}
369370

370371
/**
@@ -392,7 +393,7 @@ public static String post(final String url, final String data, final String medi
392393
*/
393394
public static String post(final String url, final Map<String, Object> queryMap,
394395
final String mediaType) {
395-
return post(url, queryMap, mediaType, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
396+
return post(url, queryMap, mediaType, Charset.DEFAULT_UTF_8);
396397
}
397398

398399
/**
@@ -405,7 +406,7 @@ public static String post(final String url, final Map<String, Object> queryMap,
405406
*/
406407
public static String post(final String url, final Map<String, Object> queryMap,
407408
final Map<String, String> headerMap) {
408-
return post(url, queryMap, headerMap, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
409+
return post(url, queryMap, headerMap, MediaType.APPLICATION_FORM_URLENCODED);
409410
}
410411

411412
/**
@@ -434,7 +435,7 @@ public static String post(final String url, final Map<String, Object> queryMap,
434435
*/
435436
public static String post(final String url, final Map<String, Object> queryMap,
436437
final Map<String, String> headerMap, final String mediaType) {
437-
return post(url, queryMap, headerMap, mediaType, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
438+
return post(url, queryMap, headerMap, mediaType, Charset.DEFAULT_UTF_8);
438439
}
439440

440441
/**
@@ -464,7 +465,7 @@ public static String post(final String url, final Map<String, Object> queryMap,
464465
*/
465466
public static String post(final String url, final Map<String, Object> params,
466467
final List<String> pathList) {
467-
MediaType mediaType = MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED + ";" + org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
468+
MediaType mediaType = MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED + ";" + Charset.DEFAULT_UTF_8);
468469
RequestBody bodyParams = RequestBody.create(mediaType, params.toString());
469470
MultipartBody.Builder requestBodyBuilder = new MultipartBody.Builder().setType(MediaType.MULTIPART_FORM_DATA_TYPE)
470471
.addFormDataPart("params", "", bodyParams);
@@ -482,7 +483,7 @@ public static String post(final String url, final Map<String, Object> params,
482483
if (response.isSuccessful()) {
483484
assert response.body() != null;
484485
byte[] bytes = response.body().bytes();
485-
result = new String(bytes, org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8);
486+
result = new String(bytes, Charset.DEFAULT_UTF_8);
486487
}
487488
} catch (Exception e) {
488489
Logger.error(">>>>>>>>error requesting HTTP upload file form request<<<<<<<<", e);
@@ -498,10 +499,10 @@ public static String post(final String url, final Map<String, Object> params,
498499
*/
499500
private static String execute(final Builder builder) {
500501
if (StringUtils.isBlank(builder.requestCharset)) {
501-
builder.requestCharset = org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8;
502+
builder.requestCharset = Charset.DEFAULT_UTF_8;
502503
}
503504
if (StringUtils.isBlank(builder.responseCharset)) {
504-
builder.responseCharset = org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8;
505+
builder.responseCharset = Charset.DEFAULT_UTF_8;
505506
}
506507
if (StringUtils.isBlank(builder.method)) {
507508
builder.method = Httpd.GET;
@@ -562,10 +563,10 @@ private static String execute(final Builder builder) {
562563
*/
563564
private static String enqueue(final Builder builder) {
564565
if (StringUtils.isBlank(builder.requestCharset)) {
565-
builder.requestCharset = org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8;
566+
builder.requestCharset = Charset.DEFAULT_UTF_8;
566567
}
567568
if (StringUtils.isBlank(builder.responseCharset)) {
568-
builder.responseCharset = org.aoju.bus.core.consts.Charset.DEFAULT_UTF_8;
569+
builder.responseCharset = Charset.DEFAULT_UTF_8;
569570
}
570571
if (StringUtils.isBlank(builder.method)) {
571572
builder.method = Httpd.GET;

bus-http/src/main/java/org/aoju/bus/http/internal/http/second/Http2Connection.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ public final class Http2Connection implements Closeable {
131131
pushObserver = builder.pushObserver;
132132
client = builder.client;
133133
listener = builder.listener;
134-
// http://tools.ietf.org/html/draft-ietf-httpbis-http2-17#section-5.2.2
135134
nextStreamId = builder.client ? 1 : 2;
136135
if (builder.client) {
137136
nextStreamId += 2; // In HTTP/2, 1 on client is reserved for Upgrade.

bus-starter/src/main/java/org/aoju/bus/starter/wrapper/RequestWrapper.java renamed to bus-starter/src/main/java/org/aoju/bus/starter/wrapper/CacheRequestWrapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@
4040
* @version 5.2.2
4141
* @since JDK 1.8+
4242
*/
43-
public class RequestWrapper extends HttpServletRequestWrapper {
43+
public class CacheRequestWrapper extends HttpServletRequestWrapper {
4444

4545
private final static byte[] DEFAULT_BYTE = new byte[0];
4646
private byte[] body;
4747
private ServletInputStreamWrapper inputStreamWrapper;
4848

49-
RequestWrapper(HttpServletRequest request) throws IOException {
49+
CacheRequestWrapper(HttpServletRequest request) throws IOException {
5050
super(request);
5151
this.body = IoUtils.readBytes(request.getInputStream());
5252
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.body != null ? this.body : DEFAULT_BYTE);

bus-starter/src/main/java/org/aoju/bus/starter/wrapper/ResponseWrapper.java renamed to bus-starter/src/main/java/org/aoju/bus/starter/wrapper/CacheResponseWrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
* @version 5.2.2
3939
* @since JDK 1.8+
4040
*/
41-
public class ResponseWrapper extends HttpServletResponseWrapper {
41+
public class CacheResponseWrapper extends HttpServletResponseWrapper {
4242

4343
private ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
4444
private PrintWriter writer = new PrintWriter(byteArrayOutputStream);
4545

46-
ResponseWrapper(HttpServletResponse response) {
46+
CacheResponseWrapper(HttpServletResponse response) {
4747
super(response);
4848
}
4949

@@ -71,7 +71,7 @@ public void setWriteListener(WriteListener writeListener) {
7171

7272
@Override
7373
public void write(int b) throws IOException {
74-
TeeOutputStream write = new TeeOutputStream(ResponseWrapper.super.getOutputStream(), byteArrayOutputStream);
74+
TeeOutputStream write = new TeeOutputStream(CacheResponseWrapper.super.getOutputStream(), byteArrayOutputStream);
7575
write.write(b);
7676
}
7777
};

bus-starter/src/main/java/org/aoju/bus/starter/wrapper/GenieWrapperHandler.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ private static void isHandle(String method, String url) {
9898
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
9999
final String method = request.getMethod().toUpperCase();
100100
isHandle(method, request.getRequestURL().toString());
101-
if (Httpd.GET.equals(method) || Httpd.POST.equals(method) || Httpd.PATCH.equals(method) || Httpd.PUT.equals(method)) {
102-
if (request instanceof RequestWrapper) {
103-
RequestWrapper requestWrapper = ((RequestWrapper) request);
104-
Logger.info("==> {}", new String(requestWrapper.getBody()));
101+
if (Httpd.GET.equals(method)
102+
|| Httpd.POST.equals(method)
103+
|| Httpd.PATCH.equals(method)
104+
|| Httpd.PUT.equals(method)) {
105+
if (request instanceof CacheRequestWrapper) {
106+
CacheRequestWrapper cacheRequestWrapper = ((CacheRequestWrapper) request);
107+
Logger.info("==> {}", new String(cacheRequestWrapper.getBody()));
105108
}
106109
}
107110
return true;
@@ -140,10 +143,12 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response,
140143
@Override
141144
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) {
142145
final String method = request.getMethod();
143-
if (Httpd.POST.equals(method) || Httpd.PATCH.equals(method) || Httpd.PUT.equals(method)) {
144-
if (response instanceof ResponseWrapper) {
145-
ResponseWrapper responseWrapper = ((ResponseWrapper) response);
146-
Logger.info("<== {}", new String(responseWrapper.getBody()));
146+
if (Httpd.POST.equals(method)
147+
|| Httpd.PATCH.equals(method)
148+
|| Httpd.PUT.equals(method)) {
149+
if (response instanceof CacheResponseWrapper) {
150+
CacheResponseWrapper cacheResponseWrapper = ((CacheResponseWrapper) response);
151+
Logger.info("<== {}", new String(cacheResponseWrapper.getBody()));
147152
}
148153
}
149154
}

bus-starter/src/main/java/org/aoju/bus/starter/wrapper/WrapperConfiguration.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ public class WrapperConfiguration {
6464
public FilterRegistrationBean registrationBodyCacheFilter() {
6565
FilterRegistrationBean<BodyCacheFilter> registrationBean = new FilterRegistrationBean<>();
6666
registrationBean.setEnabled(this.properties.getEnabled());
67-
// 设置顺序
6867
registrationBean.setOrder(this.properties.getOrder());
69-
// 设置 BodyCacheFilter
7068
registrationBean.setFilter(new BodyCacheFilter());
7169
if (!StringUtils.isEmpty(this.properties.getName())) {
7270
registrationBean.setName(this.properties.getName());
@@ -85,9 +83,7 @@ public FilterRegistrationBean registrationBodyCacheFilter() {
8583

8684
@Bean
8785
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
88-
//解析器
8986
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
90-
//注册xss解析器
9187
SimpleModule simpleModule = new SimpleModule("commonJsonSerializer");
9288
simpleModule.addSerializer(new CommonJsonSerializer(this.properties));
9389
objectMapper.registerModule(simpleModule);
@@ -123,12 +119,12 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse
123119
final String method = request.getMethod();
124120
// 如果不是 POST PATCH PUT 等有流的接口则无需进行类型转换,提高性能
125121
if (Httpd.POST.equals(method) || Httpd.PATCH.equals(method) || Httpd.PUT.equals(method)) {
126-
if (!(request instanceof RequestWrapper)) {
127-
request = new RequestWrapper(request);
122+
if (!(request instanceof CacheRequestWrapper)) {
123+
request = new CacheRequestWrapper(request);
128124
}
129125
}
130-
if (!(response instanceof ResponseWrapper)) {
131-
response = new ResponseWrapper(response);
126+
if (!(response instanceof CacheResponseWrapper)) {
127+
response = new CacheResponseWrapper(response);
132128
}
133129
filterChain.doFilter(request, response);
134130
}

0 commit comments

Comments
 (0)