Skip to content

Commit

Permalink
Merge pull request #8 from buession/development
Browse files Browse the repository at this point in the history
Release 2.2.0
  • Loading branch information
eduosi authored Mar 10, 2023
2 parents 170b5ef + ac11c17 commit 4e1d6e0
Show file tree
Hide file tree
Showing 112 changed files with 4,483 additions and 368 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,45 @@
===========================


## [2.2.0](https://github.com/buession/buession-security/releases/tag/v2.2.0) (2023-03-10)

### 🔨依赖升级

- [依赖库版本升级和安全漏洞修复](https://github.com/buession/buession-parent/releases/tag/v2.2.0)
- **buession-geoip:** 升级 IP 库


### ⭐ 新特性

- **buession-core:** ListBuilder、MapBuilder、QueueBuilder、SetBuilder 增加可以直接传递 List、Map、Queue、Set 实例的 create 方法
- **buession-core:** Assert isEmpty 和 notEmpty 增加基础类型数组判断
- **buession-core:** StringUtils 增加 random 增加支持字符串
- **buession-geoip:** 增加返回 autonomous system number、autonomous system organization
- **buession-geoip:** 增加可支持设置 asn 库地址或流
- **buession-httpclient:** 支持原生 RequestBody 子类转换
- **buession-web:** 增加 web binder 转换器工厂 IgnoreCaseEnumConverterFactory 忽略大小写将字符串转换为枚举值
- **buession-web:** 获取客户端真实 IP,增加标头 Client-IP 的支持


### 🔔 变化
- **buession-web:** 废弃 web binder 转换器 CaseTypeConverter、DomainTLDConverter、DomainTLDTypeConverter、GenderConverter、IpTypeConverter、ISBNTypeConverter、OrderConverter、StatusConverter,统一使用 web binder 转换器工厂 IgnoreCaseEnumConverterFactory
- **buession-core:** Executor、Resolve 增加异常支持


### 🐞 Bug 修复

- **buession-core:** 修复 RandomDigitIdGenerator 最大值大于最小值时报错的问题
- **buession-httpclient:** 修复 Response 返回错误的 statusCode 和 statusText
- **buession-dao:** 修复 DefaultJsonTypeHandler 为 null 或空字符串反序列化出错的 BUG


### ⏪ 优化
- 其它优化


---


## [2.1.2](https://github.com/buession/buessionframework/releases/tag/v2.1.2) (2022-11-13)

### 🔨依赖升级
Expand All @@ -18,6 +57,7 @@
- **buession-http:** 优化 Response,使 statusCode、statusText 与 statusLine 的值始终保持一致
- **buession-geoip:** 优化国家和地区词典解析,GeoIPResolverFactory 支持从默认词典返回文件对象或流对象,以及支持从 classpath 家长词典文件
- 其它优化
- **buession-velocity:** 配置属性 resource.loader 替换 resource.loaders


### 🐞 Bug 修复
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
- [https://mvnrepository.com/search?q=com.buession](https://mvnrepository.com/search?q=com.buession)

## Documentation
---

- 参考文档 [https://www.buession.com/](https://www.buession.com/)
- Wiki [https://github.com/buession/buessionframework/wiki](https://github.com/buession/buessionframework/wiki)
Expand Down
2 changes: 1 addition & 1 deletion buession-aop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.buession</groupId>
<artifactId>buession-parent</artifactId>
<relativePath>../buession-parent</relativePath>
<version>2.1.2</version>
<version>2.2.0</version>
</parent>
<artifactId>buession-aop</artifactId>
<url>https://github.com/buession/buessionframework</url>
Expand Down
2 changes: 1 addition & 1 deletion buession-beans/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.buession</groupId>
<artifactId>buession-parent</artifactId>
<relativePath>../buession-parent</relativePath>
<version>2.1.2</version>
<version>2.2.0</version>
</parent>
<artifactId>buession-beans</artifactId>
<url>https://github.com/buession/buessionframework</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public static void populate(final Object target, final Object source, final Conv

try{
humpBeanUtilsBean.populate(target, (Map<String, ? extends Object>) source);
}catch(IllegalAccessException e){
logger.error("Copy Map to {} error: {}.", target.getClass().getName(), e.getMessage());
}catch(InvocationTargetException e){
}catch(Exception e){
logger.error("Copy Map to {} error: {}.", target.getClass().getName(), e.getMessage());
}
return;
Expand Down Expand Up @@ -137,9 +135,7 @@ public static void copyProperties(final Object target, final Object source, fina
if(source instanceof Map){
try{
org.apache.commons.beanutils.BeanUtils.populate(target, (Map<String, ?>) source);
}catch(IllegalAccessException e){
logger.error("Copy Map to {} error: {}.", target.getClass().getName(), e.getMessage());
}catch(InvocationTargetException e){
}catch(Exception e){
logger.error("Copy Map to {} error: {}.", target.getClass().getName(), e.getMessage());
}
return;
Expand Down
2 changes: 1 addition & 1 deletion buession-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.buession</groupId>
<artifactId>buession-parent</artifactId>
<relativePath>../buession-parent</relativePath>
<version>2.1.2</version>
<version>2.2.0</version>
</parent>
<artifactId>buession-core</artifactId>
<url>https://github.com/buession/buessionframework</url>
Expand Down
7 changes: 5 additions & 2 deletions buession-core/src/main/java/com/buession/core/Executor.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <[email protected]> |
* | Copyright @ 2013-2022 Buession.com Inc. |
* | Copyright @ 2013-2023 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.core;
Expand All @@ -44,7 +44,10 @@ public interface Executor<C, R> {
* 命令执行器上下文
*
* @return 命令执行返回值,R 类型的实例
*
* @throws Exception
* 异常
*/
R execute(C context);
R execute(C context) throws Exception;

}
7 changes: 5 additions & 2 deletions buession-core/src/main/java/com/buession/core/Resolve.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <[email protected]> |
* | Copyright @ 2013-2022 Buession.com Inc. |
* | Copyright @ 2013-2023 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.core;
Expand All @@ -45,7 +45,10 @@ public interface Resolve<S, T> {
* 待解析对象
*
* @return 解析结果
*
* @throws Exception
* 异常
*/
T resolve(final S source);
T resolve(final S source) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private ListBuilder(final List<V> data){
* @return {@link ListBuilder} 实例
*/
public static <V> ListBuilder<V> create(){
return create(16);
return new ListBuilder<>(new ArrayList<>());
}

/**
Expand All @@ -86,6 +86,22 @@ public static <V> ListBuilder<V> create(final int initialCapacity){
return new ListBuilder<>(new ArrayList<>(initialCapacity));
}

/**
* 创建默认为 {@link ArrayList} 类型的 {@link ListBuilder} 实例
*
* @param list
* the list whose elements are to be placed into this list
* @param <V>
* Value 类型
*
* @return {@link ListBuilder} 实例
*
* @since 2.2.0
*/
public static <V> ListBuilder<V> create(final List<V> list){
return new ListBuilder<>(list);
}

/**
* 创建默认为 {@link ArrayList} 类型的 {@link ListBuilder} 实例
*
Expand Down Expand Up @@ -114,7 +130,7 @@ public static <V> ListBuilder<V> create(final Collection<? extends V> c){
*
* @return {@link ListBuilder} 实例
*/
public static <V, S extends List<V>> ListBuilder<V> create(Class<S> clazz){
public static <V, S extends List<V>> ListBuilder<V> create(final Class<S> clazz){
Assert.isNull(clazz, "java.util.List class cloud not be null.");

List<V> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private MapBuilder(final Map<K, V> data){
* @return {@link MapBuilder} 实例
*/
public static <K, V> MapBuilder<K, V> create(){
return create(16);
return new MapBuilder<>(new HashMap<>());
}

/**
Expand Down Expand Up @@ -101,8 +101,8 @@ public static <K, V> MapBuilder<K, V> create(final int initialCapacity, final fl
*
* @since 2.1.2
*/
public static <K, V> MapBuilder<K, V> create(final Map<? extends K, ? extends V> m){
return new MapBuilder<>(new HashMap<>(m));
public static <K, V> MapBuilder<K, V> create(final Map<K, V> m){
return new MapBuilder<>(m);
}

/**
Expand All @@ -119,7 +119,7 @@ public static <K, V> MapBuilder<K, V> create(final Map<? extends K, ? extends V>
*
* @return {@link MapBuilder} 实例
*/
public static <K, V, M extends Map<K, V>> MapBuilder<K, V> create(Class<M> clazz){
public static <K, V, M extends Map<K, V>> MapBuilder<K, V> create(final Class<M> clazz){
Assert.isNull(clazz, "java.util.Map class cloud not be null.");

Map<K, V> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,27 @@ public static <V> QueueBuilder<V> create(){
return new QueueBuilder<>(new LinkedList<>());
}

/**
* 创建默认为 {@link LinkedList} 类型的 {@link QueueBuilder} 实例
*
* @param queue
* the queue whose elements are to be placed into this queue
* @param <V>
* Value 类型
*
* @return {@link QueueBuilder} 实例
*
* @since 2.2.0
*/
public static <V> QueueBuilder<V> create(final Queue<V> queue){
return new QueueBuilder<>(queue);
}

/**
* 创建默认为 {@link LinkedList} 类型的 {@link QueueBuilder} 实例
*
* @param c
* the collection whose elements are to be placed into this list
* the collection whose elements are to be placed into this queue
* @param <V>
* Value 类型
*
Expand All @@ -74,7 +90,7 @@ public static <V> QueueBuilder<V> create(final Collection<? extends V> c){
*
* @return {@link QueueBuilder} 实例
*/
public static <V, S extends Queue<V>> QueueBuilder<V> create(Class<S> clazz){
public static <V, S extends Queue<V>> QueueBuilder<V> create(final Class<S> clazz){
Assert.isNull(clazz, "java.util.Queue class cloud not be null.");

Queue<V> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private SetBuilder(final Set<V> data){
* @return {@link SetBuilder} 实例
*/
public static <V> SetBuilder<V> create(){
return new SetBuilder<>(new HashSet<>(16));
return new SetBuilder<>(new HashSet<>());
}

/**
Expand Down Expand Up @@ -80,6 +80,22 @@ public static <V> SetBuilder<V> create(final int initialCapacity, final float lo
return new SetBuilder<>(new HashSet<>(initialCapacity, loadFactor));
}

/**
* 创建默认为 {@link HashSet} 类型的 {@link SetBuilder} 实例
*
* @param set
* the set whose elements are to be placed into this set
* @param <V>
* Value 类型
*
* @return {@link SetBuilder} 实例
*
* @since 2.2.0
*/
public static <V> SetBuilder<V> create(final Set<V> set){
return new SetBuilder<>(set);
}

/**
* 创建默认为 {@link HashSet} 类型的 {@link SetBuilder} 实例
*
Expand Down Expand Up @@ -108,7 +124,7 @@ public static <V> SetBuilder<V> create(final Collection<? extends V> c){
*
* @return {@link SetBuilder} 实例
*/
public static <V, S extends Set<V>> SetBuilder<V> create(Class<S> clazz){
public static <V, S extends Set<V>> SetBuilder<V> create(final Class<S> clazz){
Assert.isNull(clazz, "java.util.Set class cloud not be null.");

Set<V> data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public Object postProcessAfterInitialization(Object bean, @Nullable String beanN
}

if(field.getType().isAssignableFrom(MessageObject.class) == false){
throw new BeanCreationException("The field " + field.getName() + " is not subclass of " + MessageObject.class.getName() + ", on: " + beanName + "(" + bean.getClass().getName() + ").");
throw new BeanCreationException(
"The field " + field.getName() + " is not subclass of " + MessageObject.class.getName() +
", on: " + beanName + "(" + bean.getClass().getName() + ").");
}

handleMessageInjected(clazz, bean, beanName, field, message);
Expand All @@ -88,22 +90,29 @@ public Object postProcessAfterInitialization(Object bean, @Nullable String beanN
return bean;
}

private void handleMessageInjected(final Class<?> clazz, final Object bean, final String beanName, final Field field, final Message message) throws BeansException{
private void handleMessageInjected(final Class<?> clazz, final Object bean, final String beanName,
final Field field, final Message message) throws BeansException{
final String key = message.value();
final String text = getEnvironment().getProperty(buildProperty(key, message.textField()));

if(message.required() && text == null){
throw new IllegalArgumentException("Could not resolve placeholder '" + key + "' in value \"${" + key + "}\", on: " + beanName + "(" + bean.getClass().getName() + ").");
throw new IllegalArgumentException(
"Could not resolve placeholder '" + key + "' in value \"${" + key + "}\", on: " + beanName + "(" +
bean.getClass().getName() + ").");
}

final int code = getEnvironment().getProperty(buildProperty(key, message.codeField()), Integer.class);
final Integer code = getEnvironment().getProperty(buildProperty(key, message.codeField()), Integer.class);

try{
final Object beanObject = AopUtils.isCglibProxy(bean) ? getCglibProxyTargetObject(bean) : bean;
if(code != null){
try{
final Object beanObject = AopUtils.isCglibProxy(bean) ? getCglibProxyTargetObject(bean) : bean;

FieldUtils.writeField(field, beanObject, new MessageObject(code, text), true);
}catch(Exception e){
throw new BeanCreationException("Exception thrown when handleMessageInjected, on: " + beanName + "(" + clazz.getName() + ")", e);
FieldUtils.writeField(field, beanObject, new MessageObject(code, text), true);
}catch(Exception e){
throw new BeanCreationException(
"Exception thrown when handleMessageInjected, on: " + beanName + "(" + clazz.getName() + ")",
e);
}
}
logger.debug("Parse message '{}', code: {}, text: {}", key, code, text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,7 @@ public <R> Source<R> as(Function<T, R> adapter){

Supplier<Boolean> test = ()->predicate.test(supplier.get());
Predicate<R> predicate = (t)->test.get();
Supplier<R> supplier = ()->{
if(test.get()){
return adapter.apply(this.supplier.get());
}
return null;
};
Supplier<R> supplier = ()->test.get() ? adapter.apply(this.supplier.get()) : null;

return new Source<>(supplier, predicate);
}
Expand Down Expand Up @@ -381,11 +376,11 @@ public <R> R toInstance(Function<T, R> factory){
Assert.isNull(factory, "Factory cloud not be null");

T value = supplier.get();
if(predicate.test(value) == false){
throw new NoSuchElementException("No value present");
if(predicate.test(value)){
return factory.apply(value);
}

return factory.apply(value);
throw new NoSuchElementException("No value present");
}

}
Expand Down
Loading

0 comments on commit 4e1d6e0

Please sign in to comment.