From 2ed3c2e45e1d8ce40f7af2159e71e63baaab9cbc Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Wed, 15 Jun 2022 11:37:31 +0800 Subject: [PATCH 1/9] bug fix and add method --- .../core/beans/copier/BeanToMapCopier.java | 2 +- .../bus/core/beans/copier/CopyOptions.java | 2 + .../core/beans/copier/MapToBeanCopier.java | 2 +- .../copier/ValueProviderToBeanCopier.java | 6 ++ .../aoju/bus/core/convert/ArrayConverter.java | 68 +++++++++++++--- .../org/aoju/bus/core/convert/Convert.java | 3 + .../bus/core/convert/ConverterRegistry.java | 1 + .../org/aoju/bus/core/date/Converter.java | 25 ++++++ .../java/org/aoju/bus/core/lang/FileType.java | 1 + .../org/aoju/bus/core/lang/SimpleCache.java | 2 +- .../org/aoju/bus/core/toolkit/ArrayKit.java | 15 +++- .../org/aoju/bus/core/toolkit/BeanKit.java | 31 ++++++++ .../org/aoju/bus/core/toolkit/IterKit.java | 3 + .../java/org/aoju/bus/extra/ssh/JSchKit.java | 17 +++- .../aoju/bus/extra/ssh/JSchSessionPool.java | 4 +- .../java/org/aoju/bus/extra/ssh/Sftp.java | 14 +++- .../org/aoju/bus/health/builtin/Java.java | 77 ------------------- .../software/AbstractOperatingSystem.java | 5 +- .../health/linux/hardware/LinuxNetworkIF.java | 5 +- 19 files changed, 178 insertions(+), 105 deletions(-) diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/BeanToMapCopier.java b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/BeanToMapCopier.java index 3002b772ad..fbee5a1c53 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/BeanToMapCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/BeanToMapCopier.java @@ -50,7 +50,7 @@ public class BeanToMapCopier extends AbstractCopier { * 构造 * * @param source 来源Map - * @param target 目标Bean对象 + * @param target 目标Map对象 * @param targetType 目标泛型类型 * @param copyOptions 拷贝选项 */ diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/CopyOptions.java b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/CopyOptions.java index cbcec10f73..357e8f2a8a 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/CopyOptions.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/CopyOptions.java @@ -249,6 +249,7 @@ public CopyOptions ignoreCase() { /** * 设置拷贝属性的字段映射,用于不同的属性之前拷贝做对应表用 + * 需要注意的是,当使用ValueProvider作为数据提供者时,这个映射是相反的,即fieldMapping中key为目标Bean的名称,而value是提供者中的key * * @param fieldMapping 拷贝属性的字段映射,用于不同的属性之前拷贝做对应表用 * @return this @@ -261,6 +262,7 @@ public CopyOptions setFieldMapping(Map fieldMapping) { * 设置字段属性编辑器,用于自定义属性转换规则,例如驼峰转下划线等 * 此转换器只针对源端的字段做转换,请确认转换后与目标端字段一致 * 当转换后的字段名为null时忽略这个字段 + * 需要注意的是,当使用ValueProvider作为数据提供者时,这个映射是相反的,即fieldMapping中key为目标Bean的名称,而value是提供者中的key * * @param fieldNameEditor 字段属性编辑器,用于自定义属性转换规则,例如驼峰转下划线等 * @return this diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/MapToBeanCopier.java b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/MapToBeanCopier.java index c81737223c..52c8535a5f 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/MapToBeanCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/MapToBeanCopier.java @@ -94,7 +94,7 @@ public T copy() { } // 检查目标字段可写性 - PropertyDesc tDesc = findPropertyDesc(targetPropertyDescMap, sKeyStr); + final PropertyDesc tDesc = findPropertyDesc(targetPropertyDescMap, sKeyStr); if (null == tDesc || false == tDesc.isWritable(this.copyOptions.transientSupport)) { // 字段不可写,跳过之 return; diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/ValueProviderToBeanCopier.java b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/ValueProviderToBeanCopier.java index e3dc5aed28..c807e95171 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/copier/ValueProviderToBeanCopier.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/copier/ValueProviderToBeanCopier.java @@ -76,6 +76,12 @@ public T copy() { return; } + tFieldName = copyOptions.editFieldName(tFieldName); + // 对key做转换,转换后为null的跳过 + if (null == tFieldName) { + return; + } + // 无字段内容跳过 if (false == source.containsKey(tFieldName)) { return; diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/ArrayConverter.java b/bus-core/src/main/java/org/aoju/bus/core/convert/ArrayConverter.java index 9721c2ff87..0c545946e8 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/ArrayConverter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/ArrayConverter.java @@ -25,6 +25,7 @@ ********************************************************************************/ package org.aoju.bus.core.convert; +import org.aoju.bus.core.codec.Base64; import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.*; @@ -53,12 +54,27 @@ public class ArrayConverter extends AbstractConverter { */ private final Class targetComponentType; + /** + * 是否忽略元素转换错误 + */ + private boolean ignoreElementError; + /** * 构造 * * @param targetType 目标数组类型 */ public ArrayConverter(Class targetType) { + this(targetType, false); + } + + /** + * 构造 + * + * @param targetType 目标数组类型 + * @param ignoreElementError 是否忽略元素转换错误 + */ + public ArrayConverter(Class targetType, boolean ignoreElementError) { if (null == targetType) { // 默认Object数组 targetType = Object[].class; @@ -72,6 +88,8 @@ public ArrayConverter(Class targetType) { this.targetComponentType = targetType; this.targetType = ArrayKit.getArrayType(targetType); } + + this.ignoreElementError = ignoreElementError; } @Override @@ -84,6 +102,15 @@ public Class getTargetType() { return this.targetType; } + /** + * 设置是否忽略元素转换错误 + * + * @param ignoreElementError 是否忽略元素转换错误 + */ + public void setIgnoreElementError(boolean ignoreElementError) { + this.ignoreElementError = ignoreElementError; + } + /** * 数组对数组转换 * @@ -97,12 +124,11 @@ private Object convertArrayToArray(Object array) { return array; } - final int len = ArrayKit.getLength(array); + final int len = ArrayKit.length(array); final Object result = Array.newInstance(targetComponentType, len); - final ConverterRegistry converter = ConverterRegistry.getInstance(); for (int i = 0; i < len; i++) { - Array.set(result, i, converter.convert(targetComponentType, Array.get(array, i))); + Array.set(result, i, convertComponentType(Array.get(array, i))); } return result; } @@ -119,19 +145,27 @@ private Object convertObjectToArray(Object value) { return convertArrayToArray(value.toString().toCharArray()); } + // 字符串转bytes,首先判断是否为Base64,是则转换,否则按照默认getBytes方法。 + if (targetComponentType == byte.class) { + final String str = value.toString(); + if (Base64.isBase64(str)) { + return Base64.decode(value.toString()); + } + return str.getBytes(); + } + // 单纯字符串情况下按照逗号分隔后劈开 - final String[] strings = StringKit.splitToArray(value.toString(), Symbol.COMMA); + final String[] strings = StringKit.splitToArray(value.toString(), Symbol.C_COMMA); return convertArrayToArray(strings); } - final ConverterRegistry converter = ConverterRegistry.getInstance(); Object result; if (value instanceof List) { // List转数组 final List list = (List) value; result = Array.newInstance(targetComponentType, list.size()); for (int i = 0; i < list.size(); i++) { - Array.set(result, i, converter.convert(targetComponentType, list.get(i))); + Array.set(result, i, convertComponentType(list.get(i))); } } else if (value instanceof Collection) { // 集合转数组 @@ -140,22 +174,22 @@ private Object convertObjectToArray(Object value) { int i = 0; for (Object element : collection) { - Array.set(result, i, converter.convert(targetComponentType, element)); + Array.set(result, i, convertComponentType(element)); i++; } } else if (value instanceof Iterable) { - // 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组 + // 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组 final List list = IterKit.toList((Iterable) value); result = Array.newInstance(targetComponentType, list.size()); for (int i = 0; i < list.size(); i++) { - Array.set(result, i, converter.convert(targetComponentType, list.get(i))); + Array.set(result, i, convertComponentType(list.get(i))); } } else if (value instanceof Iterator) { - // 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组 + // 可循环对象转数组,可循环对象无法获取长度,因此先转为List后转为数组 final List list = IterKit.toList((Iterator) value); result = Array.newInstance(targetComponentType, list.size()); for (int i = 0; i < list.size(); i++) { - Array.set(result, i, converter.convert(targetComponentType, list.get(i))); + Array.set(result, i, convertComponentType(list.get(i))); } } else if (value instanceof Number && byte.class == targetComponentType) { // 用户可能想序列化指定对象 @@ -178,8 +212,18 @@ private Object convertObjectToArray(Object value) { */ private Object[] convertToSingleElementArray(Object value) { final Object[] singleElementArray = ArrayKit.newArray(targetComponentType, 1); - singleElementArray[0] = ConverterRegistry.getInstance().convert(targetComponentType, value); + singleElementArray[0] = convertComponentType(value); return singleElementArray; } + /** + * 转换元素类型 + * + * @param value 值 + * @return 转换后的值,转换失败若{@link #ignoreElementError}为true,返回null,否则抛出异常 + */ + private Object convertComponentType(Object value) { + return Convert.convertWithCheck(this.targetComponentType, value, null, this.ignoreElementError); + } + } diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/Convert.java b/bus-core/src/main/java/org/aoju/bus/core/convert/Convert.java index c55060d684..a7264db6c9 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/Convert.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/Convert.java @@ -738,6 +738,9 @@ public static String toSBC(String input) { * @return 全角字符串. */ public static String toSBC(String input, Set notConvertSet) { + if (StringKit.isEmpty(input)) { + return input; + } char[] c = input.toCharArray(); for (int i = 0; i < c.length; i++) { if (null != notConvertSet && notConvertSet.contains(c[i])) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java b/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java index d0d6e3da29..3f52f1eab8 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/ConverterRegistry.java @@ -82,6 +82,7 @@ public static ConverterRegistry getInstance() { /** * 登记自定义转换器 + * F * * @param type 转换的目标类型 * @param converterClass 转换器类,必须有默认构造方法 diff --git a/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java b/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java index e07df3098c..de7c4af47c 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java @@ -27,6 +27,7 @@ import org.aoju.bus.core.lang.Symbol; import org.aoju.bus.core.toolkit.CharsKit; +import org.aoju.bus.core.toolkit.ZoneKit; import java.sql.Timestamp; import java.time.*; @@ -295,6 +296,30 @@ public static LocalDate toLocalDate(YearMonth yearMonth, int dayOfMonth) { return yearMonth.atDay(dayOfMonth); } + /** + * {@link Date} 转换时区 + * + * @param date {@link Date} + * @param zoneId {@link ZoneId} + * @return {@link DateTime} + * @see DateTime(Date, ZoneId ) + */ + public static DateTime toTimeZone(Date date, ZoneId zoneId) { + return new DateTime(date, ZoneKit.toTimeZone(zoneId)); + } + + /** + * {@link Date} 转换时区 + * + * @param date {@link Date} + * @param timeZone {@link TimeZone} + * @return {@link DateTime} + * @see DateTime(Date,ZoneId) + */ + public static DateTime toTimeZone(Date date, TimeZone timeZone) { + return new DateTime(date, timeZone); + } + /** * YearMonth转LocalDate,转换为当月第一天 * diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java b/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java index 578ce81d54..b7d5427562 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/FileType.java @@ -834,6 +834,7 @@ public class FileType { put("E3828596", "pwl"); // Real Audio (ram) put("2E7261FD", "ram"); + put("52494646", "webp"); } }; diff --git a/bus-core/src/main/java/org/aoju/bus/core/lang/SimpleCache.java b/bus-core/src/main/java/org/aoju/bus/core/lang/SimpleCache.java index cac5753d5e..ba07447718 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/lang/SimpleCache.java +++ b/bus-core/src/main/java/org/aoju/bus/core/lang/SimpleCache.java @@ -119,7 +119,7 @@ public V get(K key, Func0 supplier) { */ public V get(K key, Predicate validPredicate, Func0 supplier) { V v = get(key); - if ((null != validPredicate && false == validPredicate.test(v))) { + if ((null != validPredicate && null != v && false == validPredicate.test(v))) { v = null; } if (null == v && null != supplier) { diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java index a21a4c28a6..cd247d3b0e 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ArrayKit.java @@ -4709,10 +4709,11 @@ public static T[] remove(final T[] array, final int index) { * 去重数组中的元素,去重后生成新的数组,原数组不变 * 此方法通过{@link LinkedHashSet} 去重 * - * @param 数组元素类型 - * @param 唯一键类型 - * @param array 数组 - * @param override 是否覆盖模式,如果为{@code true},加入的新值会覆盖相同key的旧值,否则会忽略新加值 + * @param 数组元素类型 + * @param 唯一键类型 + * @param array 数组 + * @param uniqueGenerator 唯一键生成器 + * @param override 是否覆盖模式,如果为{@code true},加入的新值会覆盖相同key的旧值,否则会忽略新加值 * @return 去重后的数组 */ public static T[] remove(T[] array, Function uniqueGenerator, boolean override) { @@ -7074,6 +7075,12 @@ public static T[] setOrAppend(T[] buffer, int index, T value) { Array.set(buffer, index, value); return buffer; } else { + if (isEmpty(buffer)) { + // 可变长类型在buffer为空的情况下,类型会被擦除,导致报错,此处修正 + final T[] values = newArray(value.getClass(), 1); + values[0] = value; + return append(buffer, values); + } return append(buffer, value); } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java index f3828e5cc2..246bbf0c68 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/BeanKit.java @@ -1181,6 +1181,37 @@ public static String getFieldName(String getterOrSetterName) { } } + /** + * 判断source与target的所有公共字段的值是否相同 + * + * @param source 待检测对象1 + * @param target 待检测对象2 + * @param ignoreProperties 不需要检测的字段 + * @return 判断结果,如果为true则证明所有字段的值都相同 + */ + public static boolean isCommonFieldsEqual(Object source, Object target, String... ignoreProperties) { + if (null == source && null == target) { + return true; + } + if (null == source || null == target) { + return false; + } + + Map sourceFieldsMap = beanToMap(source); + Map targetFieldsMap = beanToMap(target); + + Set sourceFields = sourceFieldsMap.keySet(); + sourceFields.removeAll(Arrays.asList(ignoreProperties)); + + for (String field : sourceFields) { + if (ObjectKit.notEqual(sourceFieldsMap.get(field), targetFieldsMap.get(field))) { + return false; + } + } + + return true; + } + /** * 修饰符枚举 */ diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java index e304ca896c..29a1b1c3ec 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/IterKit.java @@ -1004,6 +1004,9 @@ public static Iterator get(Iterable iterable) { */ public static E get(final Iterator iterator, int index) { Assert.isTrue(index >= 0, "[index] must be >= 0"); + if (null == iterator) { + return null; + } while (iterator.hasNext()) { index--; if (-1 == index) { diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java index 75f337704b..db6bd7a01e 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchKit.java @@ -141,9 +141,24 @@ public static Session openSession(String sshHost, int sshPort, String sshUser, S * @return SSH会话 */ public static Session openSession(String sshHost, int sshPort, String sshUser, String privateKeyPath, byte[] passphrase) { + return openSession(sshHost, sshPort, sshUser, privateKeyPath, passphrase, 0); + } + + /** + * 打开一个新的SSH会话 + * + * @param sshHost 主机 + * @param sshPort 端口 + * @param sshUser 用户名 + * @param privateKeyPath 私钥的路径 + * @param passphrase 私钥文件的密码,可以为null + * @param timeOut 超时时间,单位毫秒 + * @return SSH会话 + */ + public static Session openSession(String sshHost, int sshPort, String sshUser, String privateKeyPath, byte[] passphrase, int timeOut) { final Session session = createSession(sshHost, sshPort, sshUser, privateKeyPath, passphrase); try { - session.connect(); + session.connect(timeOut); } catch (JSchException e) { throw new InstrumentException(e); } diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchSessionPool.java b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchSessionPool.java index a1dd292aff..b006aadf58 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchSessionPool.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/JSchSessionPool.java @@ -69,7 +69,7 @@ public Session get(String key) { */ public Session getSession(String sshHost, int sshPort, String sshUser, String sshPass) { final String key = StringKit.format("{}@{}:{}", sshUser, sshHost, sshPort); - return this.cache.get(key, Session::isConnected, () -> JSchKit.openSession(sshHost, sshPort, sshUser, sshPass)); + return this.cache.get(key, (conn) -> null != conn && conn.isConnected(), () -> JSchKit.openSession(sshHost, sshPort, sshUser, sshPass)); } /** @@ -84,7 +84,7 @@ public Session getSession(String sshHost, int sshPort, String sshUser, String ss */ public Session getSession(String sshHost, int sshPort, String sshUser, String prvkey, byte[] passphrase) { final String key = StringKit.format("{}@{}:{}", sshUser, sshHost, sshPort); - return this.cache.get(key, Session::isConnected, () -> JSchKit.openSession(sshHost, sshPort, sshUser, prvkey, passphrase)); + return this.cache.get(key, (conn) -> null != conn && conn.isConnected(), () -> JSchKit.openSession(sshHost, sshPort, sshUser, prvkey, passphrase)); } /** diff --git a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java index 51d2eac37f..1f10223b91 100755 --- a/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java +++ b/bus-extra/src/main/java/org/aoju/bus/extra/ssh/Sftp.java @@ -93,8 +93,20 @@ public Sftp(String sshHost, int sshPort, String sshUser, String sshPass, Charset * @param config FTP配置 */ public Sftp(FtpConfig config) { + this(config, true); + } + + /** + * 构造 + * + * @param config FTP配置 + * @param init 是否立即初始化 + */ + public Sftp(FtpConfig config, boolean init) { super(config); - init(config); + if (init) { + init(config); + } } /** diff --git a/bus-health/src/main/java/org/aoju/bus/health/builtin/Java.java b/bus-health/src/main/java/org/aoju/bus/health/builtin/Java.java index 13a6957b1a..ab4027924e 100755 --- a/bus-health/src/main/java/org/aoju/bus/health/builtin/Java.java +++ b/bus-health/src/main/java/org/aoju/bus/health/builtin/Java.java @@ -48,13 +48,6 @@ public class Java implements Serializable { private final String JAVA_VENDOR = Platform.get(System.VENDOR, false); private final String JAVA_VENDOR_URL = Platform.get(System.VENDOR_URL, false); - private final boolean IS_JAVA_1_1 = getJavaVersionMatches("1.1"); - private final boolean IS_JAVA_1_2 = getJavaVersionMatches("1.2"); - private final boolean IS_JAVA_1_3 = getJavaVersionMatches("1.3"); - private final boolean IS_JAVA_1_4 = getJavaVersionMatches("1.4"); - private final boolean IS_JAVA_1_5 = getJavaVersionMatches("1.5"); - private final boolean IS_JAVA_1_6 = getJavaVersionMatches("1.6"); - private final boolean IS_JAVA_1_7 = getJavaVersionMatches("1.7"); private final boolean IS_JAVA_1_8 = getJavaVersionMatches("1.8"); private final boolean IS_JAVA_9 = getJavaVersionMatches("9"); private final boolean IS_JAVA_10 = getJavaVersionMatches("10"); @@ -175,76 +168,6 @@ public final String getVendorURL() { return JAVA_VENDOR_URL; } - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.1, 则返回true - */ - public final boolean isJava1_1() { - return IS_JAVA_1_1; - } - - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.2, 则返回true - */ - public final boolean isJava1_2() { - return IS_JAVA_1_2; - } - - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.3, 则返回true - */ - public final boolean isJava1_3() { - return IS_JAVA_1_3; - } - - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.4, 则返回true - */ - public final boolean isJava1_4() { - return IS_JAVA_1_4; - } - - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.5, 则返回true - */ - public final boolean isJava1_5() { - return IS_JAVA_1_5; - } - - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.6, 则返回true - */ - public final boolean isJava1_6() { - return IS_JAVA_1_6; - } - - /** - * 判断当前Java的版本 - * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false - * - * @return 如果当前Java版本为1.7, 则返回true - */ - public final boolean isJava1_7() { - return IS_JAVA_1_7; - } - /** * 判断当前Java的版本 * 如果不能取得系统属性java.version(因为Java安全限制),则总是返回 false diff --git a/bus-health/src/main/java/org/aoju/bus/health/builtin/software/AbstractOperatingSystem.java b/bus-health/src/main/java/org/aoju/bus/health/builtin/software/AbstractOperatingSystem.java index f7c8e71875..00176c0b43 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/builtin/software/AbstractOperatingSystem.java +++ b/bus-health/src/main/java/org/aoju/bus/health/builtin/software/AbstractOperatingSystem.java @@ -162,7 +162,7 @@ public List getChildProcesses(int parentPid, Predicate fil // Get this pid and its children List childProcs = queryChildProcesses(parentPid); // Extract the parent from the list - OSProcess parent = childProcs.stream().filter(p -> p.getParentProcessID() == parentPid).findAny().orElse(null); + OSProcess parent = childProcs.stream().filter(p -> p.getProcessID() == parentPid).findAny().orElse(null); // Get the parent's start time long parentStartTime = parent == null ? 0 : parent.getStartTime(); // Get children after parent @@ -180,8 +180,7 @@ public List getDescendantProcesses(int parentPid, Predicate descendantProcs = queryDescendantProcesses(parentPid); // Extract the parent from the list - OSProcess parent = descendantProcs.stream().filter(p -> p.getParentProcessID() == parentPid).findAny() - .orElse(null); + OSProcess parent = descendantProcs.stream().filter(p -> p.getProcessID() == parentPid).findAny().orElse(null); // Get the parent's start time long parentStartTime = parent == null ? 0 : parent.getStartTime(); // Get descendants after parent diff --git a/bus-health/src/main/java/org/aoju/bus/health/linux/hardware/LinuxNetworkIF.java b/bus-health/src/main/java/org/aoju/bus/health/linux/hardware/LinuxNetworkIF.java index abff6f6cd1..3d79837112 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/linux/hardware/LinuxNetworkIF.java +++ b/bus-health/src/main/java/org/aoju/bus/health/linux/hardware/LinuxNetworkIF.java @@ -29,6 +29,7 @@ import com.sun.jna.platform.linux.Udev.UdevContext; import com.sun.jna.platform.linux.Udev.UdevDevice; import org.aoju.bus.core.annotation.ThreadSafe; +import org.aoju.bus.core.lang.Normal; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.health.Builder; import org.aoju.bus.health.builtin.hardware.AbstractNetworkIF; @@ -63,8 +64,8 @@ public final class LinuxNetworkIF extends AbstractNetworkIF { private long collisions; private long speed; private long timeStamp; - private String ifAlias; - private NetworkIF.IfOperStatus ifOperStatus; + private String ifAlias = Normal.EMPTY; + private NetworkIF.IfOperStatus ifOperStatus = NetworkIF.IfOperStatus.UNKNOWN; public LinuxNetworkIF(NetworkInterface netint) throws InstantiationException { super(netint, queryIfModel(netint)); From eb01465387b2b9bbcc0965557273bf21b677833f Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Mon, 20 Jun 2022 08:48:05 +0800 Subject: [PATCH 2/9] bug fix and add method --- .../bus/core/convert/NumberConverter.java | 2 +- .../org/aoju/bus/core/text/csv/CsvData.java | 14 ++++++++++-- .../org/aoju/bus/core/toolkit/ObjectKit.java | 8 +++++-- .../aoju/bus/goalie/filter/FormatFilter.java | 2 +- .../java/org/aoju/bus/health/Builder.java | 22 +++++++++---------- .../java/org/aoju/bus/health/Formats.java | 2 +- .../linux/software/LinuxNetworkParams.java | 2 +- .../java/org/aoju/bus/health/mac/SmcKit.java | 2 +- .../health/mac/software/MacNetworkParams.java | 2 +- .../software/FreeBsdNetworkParams.java | 2 +- .../bus/health/unix/solaris/KstatKit.java | 4 ++-- .../windows/PerfCounterQueryHandler.java | 4 ++-- .../aoju/bus/health/windows/PerfDataKit.java | 10 ++++----- .../bus/http/accord/platform/Platform.java | 3 +-- .../bus/http/metric/http/Http2Reader.java | 7 +++--- .../bus/http/metric/http/Http2Writer.java | 5 ++--- .../main/java/org/aoju/bus/logger/Logger.java | 22 +++++++++---------- .../aoju/bus/socket/security/SslService.java | 2 +- .../bus/socket/security/SslSocketChannel.java | 2 +- .../starter/elastic/ElasticConfiguration.java | 4 ++-- .../mapper/AbstractSqlParserHandler.java | 2 +- .../mapper/ClassPathMapperScanner.java | 4 ++-- 22 files changed, 69 insertions(+), 58 deletions(-) diff --git a/bus-core/src/main/java/org/aoju/bus/core/convert/NumberConverter.java b/bus-core/src/main/java/org/aoju/bus/core/convert/NumberConverter.java index 4bb2dbef68..60120524bb 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/convert/NumberConverter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/convert/NumberConverter.java @@ -257,7 +257,7 @@ protected Number convertInternal(Object value) { @Override protected String convertString(Object value) { String result = StringKit.trim(super.convertString(value)); - if (StringKit.isNotEmpty(result)) { + if (null != result && result.length() > 1) { final char c = Character.toUpperCase(result.charAt(result.length() - 1)); if (c == 'D' || c == 'L' || c == 'F') { // 类型标识形式(例如123.6D) diff --git a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvData.java b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvData.java index ae52267edd..a83c1bd598 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvData.java +++ b/bus-core/src/main/java/org/aoju/bus/core/text/csv/CsvData.java @@ -25,7 +25,9 @@ ********************************************************************************/ package org.aoju.bus.core.text.csv; +import java.io.Serializable; import java.util.Collections; +import java.util.Iterator; import java.util.List; /** @@ -34,7 +36,7 @@ * @author Kimi Liu * @since Java 17+ */ -public final class CsvData { +public final class CsvData implements Iterable, Serializable { private final List header; private final List rows; @@ -65,7 +67,10 @@ public int getRowCount() { * @return 标题行-如果不存在标题,可能是{@code null} */ public List getHeader() { - return header; + if (null == this.header) { + return null; + } + return Collections.unmodifiableList(this.header); } /** @@ -87,6 +92,11 @@ public List getRows() { return Collections.unmodifiableList(rows); } + @Override + public Iterator iterator() { + return this.rows.iterator(); + } + @Override public String toString() { return "CsvData{" + diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java index 652e7ef91f..40786834af 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/ObjectKit.java @@ -62,12 +62,16 @@ public static boolean isNull(Object obj) { /** * 检查对象是否不为null + *
+     * 1. != null
+     * 2. not equals(null)
+     * 
* * @param obj 对象 - * @return 是否为null + * @return 是否为非null */ public static boolean isNotNull(Object obj) { - return false == isNull(obj); + return null != obj && false == obj.equals(null); } /** diff --git a/bus-goalie/src/main/java/org/aoju/bus/goalie/filter/FormatFilter.java b/bus-goalie/src/main/java/org/aoju/bus/goalie/filter/FormatFilter.java index 6318300e85..a2a95c8546 100644 --- a/bus-goalie/src/main/java/org/aoju/bus/goalie/filter/FormatFilter.java +++ b/bus-goalie/src/main/java/org/aoju/bus/goalie/filter/FormatFilter.java @@ -73,7 +73,7 @@ public Mono writeWith(Publisher body) { DataBufferUtils.release(dataBuffer); Message message = JsonKit.toPojo(bodyString, Message.class); String formatBody = context.getFormat().getProvider().serialize(message); - if (Logger.get().isTrace()) { + if (Logger.isTrace()) { Logger.trace("traceId:{},resp <= {}", exchange.getLogPrefix(), formatBody); } return bufferFactory().wrap(formatBody.getBytes()); diff --git a/bus-health/src/main/java/org/aoju/bus/health/Builder.java b/bus-health/src/main/java/org/aoju/bus/health/Builder.java index d69cd0122a..a80f8cd8fa 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/Builder.java +++ b/bus-health/src/main/java/org/aoju/bus/health/Builder.java @@ -1508,7 +1508,7 @@ public static List readFile(String filename) { */ public static List readFile(String filename, boolean reportError) { if (new File(filename).canRead()) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } try { @@ -1547,7 +1547,7 @@ public static byte[] readAllBytes(String filename) { */ public static byte[] readAllBytes(String filename, boolean reportError) { if (new File(filename).canRead()) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } try { @@ -1704,12 +1704,12 @@ public static Pointer readPointerFromBuffer(ByteBuffer buff) { * @return The value contained in the file, if any; otherwise zero */ public static long getLongFromFile(String filename) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } List read = Builder.readFile(filename, false); if (!read.isEmpty()) { - if (Logger.get().isTrace()) { + if (Logger.isTrace()) { Logger.trace(READ_LOG, read.get(0)); } return Builder.parseLongOrDefault(read.get(0), 0L); @@ -1725,12 +1725,12 @@ public static long getLongFromFile(String filename) { * @return The value contained in the file, if any; otherwise zero */ public static long getUnsignedLongFromFile(String filename) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } List read = Builder.readFile(filename, false); if (!read.isEmpty()) { - if (Logger.get().isTrace()) { + if (Logger.isTrace()) { Logger.trace(READ_LOG, read.get(0)); } return Builder.parseUnsignedLongOrDefault(read.get(0), 0L); @@ -1746,13 +1746,13 @@ public static long getUnsignedLongFromFile(String filename) { * @return The value contained in the file, if any; otherwise zero */ public static int getIntFromFile(String filename) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } try { List read = Builder.readFile(filename, false); if (!read.isEmpty()) { - if (Logger.get().isTrace()) { + if (Logger.isTrace()) { Logger.trace(READ_LOG, read.get(0)); } return Integer.parseInt(read.get(0)); @@ -1771,12 +1771,12 @@ public static int getIntFromFile(String filename) { * @return The value contained in the file, if any; otherwise empty string */ public static String getStringFromFile(String filename) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } List read = Builder.readFile(filename, false); if (!read.isEmpty()) { - if (Logger.get().isTrace()) { + if (Logger.isTrace()) { Logger.trace(READ_LOG, read.get(0)); } return read.get(0); @@ -1798,7 +1798,7 @@ public static String getStringFromFile(String filename) { */ public static Map getKeyValueMapFromFile(String filename, String separator) { Map map = new HashMap<>(); - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug(READING_LOG, filename); } List lines = Builder.readFile(filename, false); diff --git a/bus-health/src/main/java/org/aoju/bus/health/Formats.java b/bus-health/src/main/java/org/aoju/bus/health/Formats.java index 1abd08cba0..40481bfcf2 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/Formats.java +++ b/bus-health/src/main/java/org/aoju/bus/health/Formats.java @@ -291,7 +291,7 @@ public static String getProductID(byte[] edid) { */ public static String getSerialNo(byte[] edid) { // Bytes 12-15 are Serial number (last 4 characters) - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("Serial number: {}", Arrays.toString(Arrays.copyOfRange(edid, 12, 16))); } return String.format("%s%s%s%s", getAlphaNumericOrHex(edid[15]), getAlphaNumericOrHex(edid[14]), diff --git a/bus-health/src/main/java/org/aoju/bus/health/linux/software/LinuxNetworkParams.java b/bus-health/src/main/java/org/aoju/bus/health/linux/software/LinuxNetworkParams.java index f2ae59ff0d..bfe7935d80 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/linux/software/LinuxNetworkParams.java +++ b/bus-health/src/main/java/org/aoju/bus/health/linux/software/LinuxNetworkParams.java @@ -71,7 +71,7 @@ public String getDomainName() { PointerByReference ptr = new PointerByReference(); int res = LIBC.getaddrinfo(hostname, null, hint, ptr); if (res > 0) { - if (Logger.get().isError()) { + if (Logger.isError()) { Logger.error("Failed getaddrinfo(): {}", LIBC.gai_strerror(res)); } return ""; diff --git a/bus-health/src/main/java/org/aoju/bus/health/mac/SmcKit.java b/bus-health/src/main/java/org/aoju/bus/health/mac/SmcKit.java index 992672e837..164d5feba1 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/mac/SmcKit.java +++ b/bus-health/src/main/java/org/aoju/bus/health/mac/SmcKit.java @@ -83,7 +83,7 @@ public static IOConnect smcOpen() { smcService.release(); if (result == 0) { return new IOConnect(connPtr.getValue()); - } else if (Logger.get().isError()) { + } else if (Logger.isError()) { Logger.error(String.format("Unable to open connection to AppleSMC service. Error: 0x%08x", result)); } } else { diff --git a/bus-health/src/main/java/org/aoju/bus/health/mac/software/MacNetworkParams.java b/bus-health/src/main/java/org/aoju/bus/health/mac/software/MacNetworkParams.java index 7ac9c6ec25..98ac8b6c0a 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/mac/software/MacNetworkParams.java +++ b/bus-health/src/main/java/org/aoju/bus/health/mac/software/MacNetworkParams.java @@ -69,7 +69,7 @@ public String getDomainName() { PointerByReference ptr = new PointerByReference(); int res = SYS.getaddrinfo(hostname, null, hint, ptr); if (res > 0) { - if (Logger.get().isError()) { + if (Logger.isError()) { Logger.error("Failed getaddrinfo(): {}", SYS.gai_strerror(res)); } return Normal.EMPTY; diff --git a/bus-health/src/main/java/org/aoju/bus/health/unix/freebsd/software/FreeBsdNetworkParams.java b/bus-health/src/main/java/org/aoju/bus/health/unix/freebsd/software/FreeBsdNetworkParams.java index ad378bc1c3..596d709295 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/unix/freebsd/software/FreeBsdNetworkParams.java +++ b/bus-health/src/main/java/org/aoju/bus/health/unix/freebsd/software/FreeBsdNetworkParams.java @@ -58,7 +58,7 @@ public String getDomainName() { PointerByReference ptr = new PointerByReference(); int res = LIBC.getaddrinfo(hostname, null, hint, ptr); if (res > 0) { - if (Logger.get().isError()) { + if (Logger.isError()) { Logger.warn("Failed getaddrinfo(): {}", LIBC.gai_strerror(res)); } return Normal.EMPTY; diff --git a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java index 61c7b27144..8ce3f6e9de 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java +++ b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java @@ -143,7 +143,7 @@ public static long dataLookupLong(Kstat ksp, String name) { } Pointer p = LibKstat.INSTANCE.kstat_data_lookup(ksp, name); if (p == null) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("Failed lo lookup kstat value on {}:{}:{} for key {}", Native.toString(ksp.ks_module, StandardCharsets.US_ASCII), ksp.ks_instance, Native.toString(ksp.ks_name, StandardCharsets.US_ASCII), name); @@ -282,7 +282,7 @@ public boolean read(Kstat ksp) { int retry = 0; while (0 > LibKstat.INSTANCE.kstat_read(localCtlRef, ksp, null)) { if (LibKstat.EAGAIN != Native.getLastError() || 5 <= ++retry) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("Failed to read kstat {}:{}:{}", Native.toString(ksp.ks_module, StandardCharsets.US_ASCII), ksp.ks_instance, Native.toString(ksp.ks_name, StandardCharsets.US_ASCII)); diff --git a/bus-health/src/main/java/org/aoju/bus/health/windows/PerfCounterQueryHandler.java b/bus-health/src/main/java/org/aoju/bus/health/windows/PerfCounterQueryHandler.java index e1115caf04..d7b32cee7c 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/windows/PerfCounterQueryHandler.java +++ b/bus-health/src/main/java/org/aoju/bus/health/windows/PerfCounterQueryHandler.java @@ -135,7 +135,7 @@ public long updateQuery() { */ public long queryCounter(PerfCounter counter) { if (!counterHandleMap.containsKey(counter)) { - if (Logger.get().isWarn()) { + if (Logger.isWarn()) { Logger.warn("Counter {} does not exist to query.", counter.getCounterPath()); } return 0; @@ -143,7 +143,7 @@ public long queryCounter(PerfCounter counter) { long value = counter.isBaseCounter() ? PerfDataKit.querySecondCounter(counterHandleMap.get(counter)) : PerfDataKit.queryCounter(counterHandleMap.get(counter)); if (value < 0) { - if (Logger.get().isWarn()) { + if (Logger.isWarn()) { Logger.warn("Error querying counter {}: {}", counter.getCounterPath(), String.format(Formats.formatError((int) value))); } diff --git a/bus-health/src/main/java/org/aoju/bus/health/windows/PerfDataKit.java b/bus-health/src/main/java/org/aoju/bus/health/windows/PerfDataKit.java index 31ea60e75e..7141167006 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/windows/PerfDataKit.java +++ b/bus-health/src/main/java/org/aoju/bus/health/windows/PerfDataKit.java @@ -87,7 +87,7 @@ public static long updateQueryTimestamp(WinNT.HANDLEByReference query) { : PDH.PdhCollectQueryData(query.getValue()); } if (ret != WinError.ERROR_SUCCESS) { - if (Logger.get().isWarn()) { + if (Logger.isWarn()) { Logger.warn("Failed to update counter. Error code: {}", String.format(Formats.formatError(ret))); } return 0L; @@ -106,7 +106,7 @@ public static long updateQueryTimestamp(WinNT.HANDLEByReference query) { public static boolean openQuery(HANDLEByReference q) { int ret = PDH.PdhOpenQuery(null, PZERO, q); if (ret != WinError.ERROR_SUCCESS) { - if (Logger.get().isError()) { + if (Logger.isError()) { Logger.error("Failed to open PDH Query. Error code: {}", String.format(Formats.formatError(ret))); } return false; @@ -135,7 +135,7 @@ public static long queryCounter(WinNT.HANDLEByReference counter) { PDH_RAW_COUNTER counterValue = new PDH_RAW_COUNTER(); int ret = PDH.PdhGetRawCounterValue(counter.getValue(), PDH_FMT_RAW, counterValue); if (ret != WinError.ERROR_SUCCESS) { - if (Logger.get().isWarn()) { + if (Logger.isWarn()) { Logger.warn("Failed to get counter. Error code: {}", String.format(Formats.formatError(ret))); } return ret; @@ -154,7 +154,7 @@ public static long querySecondCounter(WinNT.HANDLEByReference counter) { PDH_RAW_COUNTER counterValue = new PDH_RAW_COUNTER(); int ret = PDH.PdhGetRawCounterValue(counter.getValue(), PDH_FMT_RAW, counterValue); if (ret != WinError.ERROR_SUCCESS) { - if (Logger.get().isWarn()) { + if (Logger.isWarn()) { Logger.warn("Failed to get counter. Error code: {}", String.format(Formats.formatError(ret))); } return ret; @@ -175,7 +175,7 @@ public static boolean addCounter(WinNT.HANDLEByReference query, String path, Win int ret = IS_VISTA_OR_GREATER ? PDH.PdhAddEnglishCounter(query.getValue(), path, PZERO, p) : PDH.PdhAddCounter(query.getValue(), path, PZERO, p); if (ret != WinError.ERROR_SUCCESS) { - if (Logger.get().isWarn()) { + if (Logger.isWarn()) { Logger.warn("Failed to add PDH Counter: {}, Error code: {}", path, String.format(Formats.formatError(ret))); } diff --git a/bus-http/src/main/java/org/aoju/bus/http/accord/platform/Platform.java b/bus-http/src/main/java/org/aoju/bus/http/accord/platform/Platform.java index 3b49d3f57f..b629dba7a5 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/accord/platform/Platform.java +++ b/bus-http/src/main/java/org/aoju/bus/http/accord/platform/Platform.java @@ -33,7 +33,6 @@ import org.aoju.bus.http.secure.CertificateChainCleaner; import org.aoju.bus.http.secure.TrustRootIndex; import org.aoju.bus.logger.Logger; -import org.aoju.bus.logger.level.Level; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSocket; @@ -234,7 +233,7 @@ public boolean isCleartextTrafficPermitted(String hostname) { * @return 返回一个对象 */ public Object getStackTraceForCloseable(String closer) { - if (Logger.get().isEnabled(Level.DEBUG)) { + if (Logger.isDebug()) { return new Throwable(closer); } return null; diff --git a/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Reader.java b/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Reader.java index e1085bcb81..33f081d86e 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Reader.java +++ b/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Reader.java @@ -30,7 +30,6 @@ import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.http.Settings; import org.aoju.bus.logger.Logger; -import org.aoju.bus.logger.level.Level; import java.io.Closeable; import java.io.IOException; @@ -80,7 +79,7 @@ public void readConnectionPreface(Handler handler) throws IOException { } } else { ByteString connectionPreface = source.readByteString(Http2.CONNECTION_PREFACE.size()); - if (Logger.get().isEnabled(Level.DEBUG)) { + if (Logger.isDebug()) { Logger.warn(StringKit.format("<< CONNECTION %s", connectionPreface.hex())); } if (!Http2.CONNECTION_PREFACE.equals(connectionPreface)) { @@ -106,7 +105,7 @@ public boolean nextFrame(boolean requireSettings, Handler handler) throws IOExce } byte flags = (byte) (source.readByte() & 0xff); int streamId = (source.readInt() & 0x7fffffff); - if (Logger.get().isEnabled(Level.DEBUG)) { + if (Logger.isDebug()) { Logger.warn(Http2.frameLog(true, streamId, length, type, flags)); } @@ -470,7 +469,7 @@ private void readContinuationHeader() throws IOException { length = left = readMedium(source); byte type = (byte) (source.readByte() & 0xff); flags = (byte) (source.readByte() & 0xff); - if (Logger.get().isEnabled(Level.DEBUG)) { + if (Logger.isDebug()) { Logger.warn(Http2.frameLog(true, streamId, length, type, flags)); } streamId = (source.readInt() & 0x7fffffff); diff --git a/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Writer.java b/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Writer.java index 3f6f640fbb..7c42f65be3 100644 --- a/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Writer.java +++ b/bus-http/src/main/java/org/aoju/bus/http/metric/http/Http2Writer.java @@ -31,7 +31,6 @@ import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.http.Settings; import org.aoju.bus.logger.Logger; -import org.aoju.bus.logger.level.Level; import java.io.Closeable; import java.io.IOException; @@ -72,7 +71,7 @@ private static void writeMedium(BufferSink sink, int i) throws IOException { public synchronized void connectionPreface() throws IOException { if (closed) throw new IOException("closed"); if (!client) return; // Nothing to write; servers don't send connection headers! - if (Logger.get().isEnabled(Level.DEBUG)) { + if (Logger.isDebug()) { Logger.warn(StringKit.format(">> CONNECTION %s", Http2.CONNECTION_PREFACE.hex())); } sink.write(Http2.CONNECTION_PREFACE.toByteArray()); @@ -250,7 +249,7 @@ public synchronized void windowUpdate(int streamId, long windowSizeIncrement) th } public void frameHeader(int streamId, int length, byte type, byte flags) throws IOException { - if (Logger.get().isEnabled(Level.DEBUG)) { + if (Logger.isDebug()) { Logger.warn(Http2.frameLog(false, streamId, length, type, flags)); } if (length > maxFrameSize) { diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/Logger.java b/bus-logger/src/main/java/org/aoju/bus/logger/Logger.java index 9ea89f10a6..76137d4a47 100755 --- a/bus-logger/src/main/java/org/aoju/bus/logger/Logger.java +++ b/bus-logger/src/main/java/org/aoju/bus/logger/Logger.java @@ -257,7 +257,7 @@ public static Log get(String name) { * @return 获得日志, 自动判定日志发出者 */ public static Log get() { - return LogFactory.get(CallerKit.getCallers()); + return get(CallerKit.getCallers()); } /** @@ -265,8 +265,8 @@ public static Log get() { * * @return the true/false */ - public boolean isTrace() { - return LogFactory.get(CallerKit.getCallers()).isTrace(); + public static boolean isTrace() { + return get().isTrace(); } /** @@ -274,8 +274,8 @@ public boolean isTrace() { * * @return the true/false */ - public boolean isDebug() { - return LogFactory.get(CallerKit.getCallers()).isDebug(); + public static boolean isDebug() { + return get().isDebug(); } /** @@ -283,8 +283,8 @@ public boolean isDebug() { * * @return the true/false */ - public boolean isInfo() { - return LogFactory.get(CallerKit.getCallers()).isInfo(); + public static boolean isInfo() { + return get().isInfo(); } /** @@ -292,8 +292,8 @@ public boolean isInfo() { * * @return the true/false */ - public boolean isWarn() { - return LogFactory.get(CallerKit.getCallers()).isWarn(); + public static boolean isWarn() { + return get().isWarn(); } /** @@ -301,8 +301,8 @@ public boolean isWarn() { * * @return the true/false */ - public boolean isError() { - return LogFactory.get(CallerKit.getCallers()).isError(); + public static boolean isError() { + return get().isError(); } } diff --git a/bus-socket/src/main/java/org/aoju/bus/socket/security/SslService.java b/bus-socket/src/main/java/org/aoju/bus/socket/security/SslService.java index e63f3ffeda..ce70efdab2 100644 --- a/bus-socket/src/main/java/org/aoju/bus/socket/security/SslService.java +++ b/bus-socket/src/main/java/org/aoju/bus/socket/security/SslService.java @@ -167,7 +167,7 @@ public void doHandshake(HandshakeModel handshakeModel) { } while (!handshakeModel.isFinished()) { handshakeStatus = engine.getHandshakeStatus(); - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.info("握手状态:" + handshakeStatus); } switch (handshakeStatus) { diff --git a/bus-socket/src/main/java/org/aoju/bus/socket/security/SslSocketChannel.java b/bus-socket/src/main/java/org/aoju/bus/socket/security/SslSocketChannel.java index fc8d9d7053..08d87eb14d 100644 --- a/bus-socket/src/main/java/org/aoju/bus/socket/security/SslSocketChannel.java +++ b/bus-socket/src/main/java/org/aoju/bus/socket/security/SslSocketChannel.java @@ -160,7 +160,7 @@ private void doUnWrap() { if (netBuffer.limit() == netBuffer.capacity()) { Logger.warn("BUFFER_UNDERFLOW error"); } else { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("BUFFER_UNDERFLOW,continue read:" + netBuffer); } if (netBuffer.position() > 0) { diff --git a/bus-starter/src/main/java/org/aoju/bus/starter/elastic/ElasticConfiguration.java b/bus-starter/src/main/java/org/aoju/bus/starter/elastic/ElasticConfiguration.java index 605043d3a6..db2508c9dc 100644 --- a/bus-starter/src/main/java/org/aoju/bus/starter/elastic/ElasticConfiguration.java +++ b/bus-starter/src/main/java/org/aoju/bus/starter/elastic/ElasticConfiguration.java @@ -28,6 +28,7 @@ import org.aoju.bus.base.consts.Consts; import org.aoju.bus.core.exception.InstrumentException; import org.aoju.bus.core.lang.Symbol; +import org.aoju.bus.core.toolkit.CollKit; import org.aoju.bus.core.toolkit.StringKit; import org.aoju.bus.logger.Logger; import org.apache.http.HttpHost; @@ -38,7 +39,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.util.CollectionUtils; import java.util.List; @@ -57,7 +57,7 @@ public class ElasticConfiguration { @Bean @ConditionalOnClass public RestClientBuilder restClientBuilder() { - if (CollectionUtils.isEmpty(this.elasticProperties.getHostList())) { + if (CollKit.isEmpty(this.elasticProperties.getHostList())) { Logger.error("[ElasticConfiguration.restClientBuilder] 初始化 RestClient 失败: 未配置集群主机信息"); throw new InstrumentException("初始化 RestClient 失败: 未配置 ElasticSearch 集群主机信息"); } diff --git a/bus-starter/src/main/java/org/aoju/bus/starter/mapper/AbstractSqlParserHandler.java b/bus-starter/src/main/java/org/aoju/bus/starter/mapper/AbstractSqlParserHandler.java index 55eaeafede..86ae74bad5 100644 --- a/bus-starter/src/main/java/org/aoju/bus/starter/mapper/AbstractSqlParserHandler.java +++ b/bus-starter/src/main/java/org/aoju/bus/starter/mapper/AbstractSqlParserHandler.java @@ -99,7 +99,7 @@ public String processParser(Statement statement) { } else if (statement instanceof Delete) { this.processDelete((Delete) statement); } - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("Parser SQL: " + statement.toString()); } return statement.toString(); diff --git a/bus-starter/src/main/java/org/aoju/bus/starter/mapper/ClassPathMapperScanner.java b/bus-starter/src/main/java/org/aoju/bus/starter/mapper/ClassPathMapperScanner.java index 37b74ce97a..b6539729b0 100644 --- a/bus-starter/src/main/java/org/aoju/bus/starter/mapper/ClassPathMapperScanner.java +++ b/bus-starter/src/main/java/org/aoju/bus/starter/mapper/ClassPathMapperScanner.java @@ -118,7 +118,7 @@ private void processBeanDefinitions(Set beanDefinitions) { GenericBeanDefinition definition; for (BeanDefinitionHolder holder : beanDefinitions) { definition = (GenericBeanDefinition) holder.getBeanDefinition(); - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("Creating MapperFactoryBean with name '" + holder.getBeanName() + "' and '" + definition.getBeanClassName() + "' mapperInterface"); } @@ -160,7 +160,7 @@ private void processBeanDefinitions(Set beanDefinitions) { explicitFactoryUsed = true; } if (!explicitFactoryUsed) { - if (Logger.get().isDebug()) { + if (Logger.isDebug()) { Logger.debug("Enabling autowire by type for MapperFactoryBean with name '" + holder.getBeanName() + "'."); } definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_BY_TYPE); From 56b59a0ab57fee160311e9d273e03cd0442b4665 Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Mon, 20 Jun 2022 11:57:02 +0800 Subject: [PATCH 3/9] bug fix and add method --- .../java/org/aoju/bus/base/entity/OAuth2.java | 22 ++++++++++++++----- .../aoju/bus/base/service/BaseService.java | 2 +- .../base/service/impl/BaseServiceImpl.java | 4 ++-- bus-pay/pom.xml | 18 +++++++-------- .../main/java/org/aoju/bus/pay/Secure.java | 4 ++-- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java b/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java index e485080e53..8ee8571967 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java +++ b/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java @@ -58,30 +58,42 @@ public class OAuth2 extends Entity { * 当前用户角色 */ @Transient - private String x_role_id; + protected String x_role_id; /** * 当前用户职称 */ @Transient - private String x_duty_id; + protected String x_duty_id; /** * 当前用户组织 */ @Transient - private String x_org_id; + protected String x_org_id; /** * 当前用户设备 */ @Transient - private String x_device_id; + protected String x_device_id; + + /** + * 应用id: 应用数据隔离 + */ + @Transient + protected String x_app_id; + + /** + * 租户id: 租户数据隔离 + */ + @Transient + protected String x_tenant_id; /** * 扩展参数信息 */ @Transient - private String x_extension; + protected String x_extension; } diff --git a/bus-base/src/main/java/org/aoju/bus/base/service/BaseService.java b/bus-base/src/main/java/org/aoju/bus/base/service/BaseService.java index 6af26ec522..e73404c1a2 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/service/BaseService.java +++ b/bus-base/src/main/java/org/aoju/bus/base/service/BaseService.java @@ -187,7 +187,7 @@ public interface BaseService extends Service { * @param entity 对象参数 * @return 操作结果 */ - Long selectCount(T entity); + int selectCount(T entity); /** * 通用:查询统计数据 diff --git a/bus-base/src/main/java/org/aoju/bus/base/service/impl/BaseServiceImpl.java b/bus-base/src/main/java/org/aoju/bus/base/service/impl/BaseServiceImpl.java index e446bf80c7..a5086777af 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/service/impl/BaseServiceImpl.java +++ b/bus-base/src/main/java/org/aoju/bus/base/service/impl/BaseServiceImpl.java @@ -176,8 +176,8 @@ public int selectCountByWhere(Object object) { } @Override - public Long selectCount(T entity) { - return new Long(mapper.selectCount(entity)); + public int selectCount(T entity) { + return mapper.selectCount(entity); } @Override diff --git a/bus-pay/pom.xml b/bus-pay/pom.xml index 0477ef8b1f..d16f8bd9e1 100644 --- a/bus-pay/pom.xml +++ b/bus-pay/pom.xml @@ -91,6 +91,12 @@ ${fastjson.version} true + + org.bouncycastle + bcprov-jdk15on + ${bouncycastle.version} + true + jakarta.servlet jakarta.servlet-api @@ -98,10 +104,9 @@ true - org.bouncycastle - bcprov-jdk15on - ${bouncycastle.version} - true + com.google.zxing + core + ${zxing.version} @@ -119,11 +124,6 @@ weixin-java-pay ${binarywang.version} - - com.google.zxing - core - ${zxing.version} - diff --git a/bus-pay/src/main/java/org/aoju/bus/pay/Secure.java b/bus-pay/src/main/java/org/aoju/bus/pay/Secure.java index 57e51a0251..c53ab836b8 100644 --- a/bus-pay/src/main/java/org/aoju/bus/pay/Secure.java +++ b/bus-pay/src/main/java/org/aoju/bus/pay/Secure.java @@ -22,8 +22,8 @@ */ public class Secure { - static final int KEY_LENGTH_BYTE = 32; - static final int TAG_LENGTH_BIT = 128; + private static final int KEY_LENGTH_BYTE = 32; + private static final int TAG_LENGTH_BIT = 128; /** * RSA最大加密明文大小 */ From be1952909e32632b7f3dab3736ba64ee30a2bdb8 Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Mon, 20 Jun 2022 12:02:44 +0800 Subject: [PATCH 4/9] bug fix and add method --- .../src/main/java/org/aoju/bus/base/entity/BaseEntity.java | 6 ++++++ bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bus-base/src/main/java/org/aoju/bus/base/entity/BaseEntity.java b/bus-base/src/main/java/org/aoju/bus/base/entity/BaseEntity.java index be71994423..b1685fe61d 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/entity/BaseEntity.java +++ b/bus-base/src/main/java/org/aoju/bus/base/entity/BaseEntity.java @@ -73,6 +73,12 @@ public class BaseEntity extends Tracer { */ protected String modified; + /** + * 搜索参数 + */ + @Transient + protected transient String params; + /** * 分页页码 */ diff --git a/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java b/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java index 8ee8571967..ae3a085d5b 100755 --- a/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java +++ b/bus-base/src/main/java/org/aoju/bus/base/entity/OAuth2.java @@ -79,13 +79,13 @@ public class OAuth2 extends Entity { protected String x_device_id; /** - * 应用id: 应用数据隔离 + * 当前应用 */ @Transient protected String x_app_id; /** - * 租户id: 租户数据隔离 + * 当前租户 */ @Transient protected String x_tenant_id; From 06c8bdd50906d985d31437a9b50dc1e9739a648f Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Wed, 22 Jun 2022 09:50:23 +0800 Subject: [PATCH 5/9] update jar version --- bus-cache/pom.xml | 4 +- bus-extra/pom.xml | 2 +- bus-gitlab/pom.xml | 2 +- bus-limiter/pom.xml | 4 +- bus-logger/pom.xml | 8 +- .../bus/logger/dialect/log4j/Log4jLog.java | 139 ------------------ .../logger/dialect/log4j/Log4jLogFactory.java | 54 ------- .../logger/dialect/log4j/package-info.java | 7 - bus-oauth/pom.xml | 2 +- bus-office/pom.xml | 2 +- bus-pay/pom.xml | 6 +- bus-shade/pom.xml | 2 +- bus-starter/pom.xml | 8 +- bus-storage/pom.xml | 2 +- bus-tracer/pom.xml | 2 +- 15 files changed, 19 insertions(+), 225 deletions(-) delete mode 100755 bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLog.java delete mode 100755 bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLogFactory.java delete mode 100644 bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/package-info.java diff --git a/bus-cache/pom.xml b/bus-cache/pom.xml index 8a4513bdad..af4fa42f3c 100755 --- a/bus-cache/pom.xml +++ b/bus-cache/pom.xml @@ -48,11 +48,11 @@ 4.2.2 2.4.7 3.9.4 - 4.3.0 + 5.2.1 30.1.1-jre 4.0.65 1.2.8 - 8.0.28 + 8.0.29 diff --git a/bus-extra/pom.xml b/bus-extra/pom.xml index ee58fef9a7..f8994a6b1d 100644 --- a/bus-extra/pom.xml +++ b/bus-extra/pom.xml @@ -150,7 +150,7 @@ org.apache.ftpserver ftpserver-core - 1.1.1 + 1.2.0 slf4j-api diff --git a/bus-gitlab/pom.xml b/bus-gitlab/pom.xml index 9546e0a4fa..c9e2181375 100755 --- a/bus-gitlab/pom.xml +++ b/bus-gitlab/pom.xml @@ -43,7 +43,7 @@ UTF-8 17 2.12.4 - 2.35 + 2.36 5.0.0 diff --git a/bus-limiter/pom.xml b/bus-limiter/pom.xml index 1e2108ea71..03e3eeb673 100755 --- a/bus-limiter/pom.xml +++ b/bus-limiter/pom.xml @@ -43,8 +43,8 @@ UTF-8 17 2.7.0 - 4.3.0 - 3.11.2 + 5.2.1 + 3.17.4 30.1.1-jre diff --git a/bus-logger/pom.xml b/bus-logger/pom.xml index 9640322d83..c85667711e 100644 --- a/bus-logger/pom.xml +++ b/bus-logger/pom.xml @@ -43,7 +43,7 @@ UTF-8 17 1.7.36 - 1.2.3 + 1.2.11 1.2.17 2.17.2 1.2 @@ -69,12 +69,6 @@ ${jboss.logging.version} true - - log4j - log4j - ${log4j.version} - true - org.apache.logging.log4j log4j-core diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLog.java b/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLog.java deleted file mode 100755 index 049d02bee1..0000000000 --- a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLog.java +++ /dev/null @@ -1,139 +0,0 @@ -/********************************************************************************* - * * - * The MIT License (MIT) * - * * - * Copyright (c) 2015-2022 aoju.org and other contributors. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy * - * of this software and associated documentation files (the "Software"), to deal * - * in the Software without restriction, including without limitation the rights * - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included in * - * all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * - * THE SOFTWARE. * - * * - ********************************************************************************/ -package org.aoju.bus.logger.dialect.log4j; - -import org.aoju.bus.core.lang.Normal; -import org.aoju.bus.core.toolkit.StringKit; -import org.aoju.bus.logger.AbstractAware; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; - -/** - * Apache Log4J log. - * - * @author Kimi Liu - * @since Java 17+ - */ -public class Log4jLog extends AbstractAware { - - private final Logger logger; - - public Log4jLog(Logger logger) { - this.logger = logger; - } - - public Log4jLog(Class clazz) { - this((null == clazz) ? Normal.NULL : clazz.getName()); - } - - public Log4jLog(String name) { - this(Logger.getLogger(name)); - } - - @Override - public String getName() { - return logger.getName(); - } - - @Override - public boolean isTrace() { - return logger.isTraceEnabled(); - } - - @Override - public void trace(String fqcn, Throwable t, String format, Object... arguments) { - log(fqcn, org.aoju.bus.logger.level.Level.TRACE, t, format, arguments); - } - - @Override - public boolean isDebug() { - return logger.isDebugEnabled(); - } - - @Override - public void debug(String fqcn, Throwable t, String format, Object... arguments) { - log(fqcn, org.aoju.bus.logger.level.Level.DEBUG, t, format, arguments); - } - - @Override - public boolean isInfo() { - return logger.isInfoEnabled(); - } - - @Override - public void info(String fqcn, Throwable t, String format, Object... arguments) { - log(fqcn, org.aoju.bus.logger.level.Level.INFO, t, format, arguments); - } - - @Override - public boolean isWarn() { - return logger.isEnabledFor(Level.WARN); - } - - @Override - public void warn(String fqcn, Throwable t, String format, Object... arguments) { - log(fqcn, org.aoju.bus.logger.level.Level.WARN, t, format, arguments); - } - - @Override - public boolean isError() { - return logger.isEnabledFor(Level.ERROR); - } - - @Override - public void error(String fqcn, Throwable t, String format, Object... arguments) { - log(fqcn, org.aoju.bus.logger.level.Level.ERROR, t, format, arguments); - } - - @Override - public void log(String fqcn, org.aoju.bus.logger.level.Level level, Throwable t, String format, Object... arguments) { - Level log4jLevel; - switch (level) { - case TRACE: - log4jLevel = Level.TRACE; - break; - case DEBUG: - log4jLevel = Level.DEBUG; - break; - case INFO: - log4jLevel = Level.INFO; - break; - case WARN: - log4jLevel = Level.WARN; - break; - case ERROR: - log4jLevel = Level.ERROR; - break; - default: - throw new Error(StringKit.format("Can not identify level: {}", level)); - } - - if (logger.isEnabledFor(log4jLevel)) { - logger.log(fqcn, log4jLevel, StringKit.format(format, arguments), t); - } - } - -} diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLogFactory.java b/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLogFactory.java deleted file mode 100755 index bc413f348f..0000000000 --- a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/Log4jLogFactory.java +++ /dev/null @@ -1,54 +0,0 @@ -/********************************************************************************* - * * - * The MIT License (MIT) * - * * - * Copyright (c) 2015-2022 aoju.org and other contributors. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy * - * of this software and associated documentation files (the "Software"), to deal * - * in the Software without restriction, including without limitation the rights * - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included in * - * all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * - * THE SOFTWARE. * - * * - ********************************************************************************/ -package org.aoju.bus.logger.dialect.log4j; - -import org.aoju.bus.logger.Log; -import org.aoju.bus.logger.LogFactory; - -/** - * Apache Log4J - * - * @author Kimi Liu - * @since Java 17+ - */ -public class Log4jLogFactory extends LogFactory { - - public Log4jLogFactory() { - super("Log4j"); - checkLogExist(org.apache.log4j.Logger.class); - } - - @Override - public Log createLog(String name) { - return new Log4jLog(name); - } - - @Override - public Log createLog(Class clazz) { - return new Log4jLog(clazz); - } - -} diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/package-info.java b/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/package-info.java deleted file mode 100644 index ae771ac541..0000000000 --- a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/log4j/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Log4j的实现封装 - * - * @author Kimi Liu - * @since Java 17++ - */ -package org.aoju.bus.logger.dialect.log4j; \ No newline at end of file diff --git a/bus-oauth/pom.xml b/bus-oauth/pom.xml index dcbba9fd63..1e147672f7 100755 --- a/bus-oauth/pom.xml +++ b/bus-oauth/pom.xml @@ -42,7 +42,7 @@ UTF-8 UTF-8 17 - 4.22.113.ALL + 4.31.24.ALL 1.18.24 1.2.83 diff --git a/bus-office/pom.xml b/bus-office/pom.xml index f99faca5c2..03d5a1313b 100755 --- a/bus-office/pom.xml +++ b/bus-office/pom.xml @@ -42,7 +42,7 @@ UTF-8 UTF-8 17 - 4.1.2 + 5.2.2 2.12.2 4.1.2 diff --git a/bus-pay/pom.xml b/bus-pay/pom.xml index d16f8bd9e1..b74e8bf484 100644 --- a/bus-pay/pom.xml +++ b/bus-pay/pom.xml @@ -50,7 +50,8 @@ 3.5.0 1.70 2.7.0 - 4.1.0 + 4.3.5.B + 4.31.24.ALL @@ -108,11 +109,10 @@ core ${zxing.version} - com.alipay.sdk alipay-sdk-java - 4.22.22.ALL + ${alipay.version} com.paypal.sdk diff --git a/bus-shade/pom.xml b/bus-shade/pom.xml index 979a794e0a..cd2ff2c8c4 100755 --- a/bus-shade/pom.xml +++ b/bus-shade/pom.xml @@ -47,7 +47,7 @@ 2.3.30 1.18.24 1.2.8 - 8.0.28 + 8.0.29 diff --git a/bus-starter/pom.xml b/bus-starter/pom.xml index 7a631d4de8..d711405f3a 100755 --- a/bus-starter/pom.xml +++ b/bus-starter/pom.xml @@ -47,16 +47,16 @@ 1.9.6 2.2 30.1.1-jre - 4.2.3 + 4.3.1 5.0.1 3.5.10 2.0.7 2.0.1.Final 4.2 - 8.0.28 - 3.0.5 + 8.0.29 + 3.0.8 4.0.4 - 7.14.1 + 8.2.3 diff --git a/bus-storage/pom.xml b/bus-storage/pom.xml index 7d99a9e97e..7b2e753313 100755 --- a/bus-storage/pom.xml +++ b/bus-storage/pom.xml @@ -44,7 +44,7 @@ 17 1.18.24 3.15.0 - 0.10.209 + 0.10.212 3.22.3 1.12.226 8.4.1 diff --git a/bus-tracer/pom.xml b/bus-tracer/pom.xml index 3b85c35acc..7c67e9c8f0 100755 --- a/bus-tracer/pom.xml +++ b/bus-tracer/pom.xml @@ -44,7 +44,7 @@ 17 2.7.0 1.18.24 - 3.0.5 + 3.0.8 4.0.4 2.7.18 4.5.13 From a043d0eaebdc7f9f3cb3b0be5c428e8b361e27c1 Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Wed, 22 Jun 2022 10:53:20 +0800 Subject: [PATCH 6/9] v6.5.2 --- README.md | 4 +- bus-all/pom.xml | 2 +- bus-base/pom.xml | 2 +- bus-bom/pom.xml | 2 +- bus-cache/pom.xml | 2 +- bus-core/README.md | 2 +- bus-core/pom.xml | 2 +- .../main/java/org/aoju/bus/core/Version.java | 2 +- .../aoju/bus/core/beans/PathExpression.java | 83 +++--- .../org/aoju/bus/core/date/Converter.java | 2 - .../org/aoju/bus/core/thread/BlockPolicy.java | 38 ++- .../org/aoju/bus/core/toolkit/CollKit.java | 37 +++ .../org/aoju/bus/core/toolkit/NetKit.java | 11 + bus-cron/pom.xml | 2 +- bus-crypto/pom.xml | 2 +- bus-extra/pom.xml | 2 +- bus-gitlab/README.md | 2 +- bus-gitlab/pom.xml | 2 +- bus-goalie/pom.xml | 2 +- bus-health/pom.xml | 2 +- .../main/java/org/aoju/bus/health/Config.java | 4 - .../bus/health/unix/solaris/KstatKit.java | 240 +++++++++--------- .../hardware/SolarisCentralProcessor.java | 2 +- .../solaris/hardware/SolarisPowerSource.java | 4 +- .../software/SolarisOperatingSystem.java | 2 +- .../drivers/LogicalProcessorInformation.java | 6 +- .../registry/HkeyPerformanceDataUtil.java | 16 +- bus-http/pom.xml | 2 +- bus-image/pom.xml | 2 +- bus-limiter/pom.xml | 2 +- bus-logger/pom.xml | 2 +- bus-mapper/pom.xml | 2 +- bus-notify/README.md | 2 +- bus-notify/pom.xml | 2 +- bus-oauth/README.md | 2 +- bus-oauth/pom.xml | 2 +- bus-office/pom.xml | 2 +- bus-opencv/pom.xml | 2 +- bus-pager/README.md | 2 +- bus-pager/pom.xml | 2 +- bus-pay/pom.xml | 2 +- bus-proxy/pom.xml | 2 +- bus-sensitive/pom.xml | 2 +- bus-setting/pom.xml | 2 +- bus-shade/pom.xml | 2 +- bus-socket/pom.xml | 2 +- bus-starter/pom.xml | 2 +- bus-storage/pom.xml | 2 +- bus-tracer/pom.xml | 2 +- bus-validate/pom.xml | 2 +- 50 files changed, 309 insertions(+), 214 deletions(-) diff --git a/README.md b/README.md index b914a6c930..68b153ee16 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

- + @@ -97,7 +97,7 @@ Bus (应用/服务总线) 是一个基础框架、服务套件,它基于Java17 org.aoju bus-all - 6.5.1 + 6.5.2 ``` diff --git a/bus-all/pom.xml b/bus-all/pom.xml index 7eea4f2766..6f02133974 100755 --- a/bus-all/pom.xml +++ b/bus-all/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-all - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-base/pom.xml b/bus-base/pom.xml index ecabc4b586..44a9cd169a 100755 --- a/bus-base/pom.xml +++ b/bus-base/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-base - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-bom/pom.xml b/bus-bom/pom.xml index 80d3810092..244b6f48b0 100755 --- a/bus-bom/pom.xml +++ b/bus-bom/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-bom - 6.5.1 + 6.5.2 pom ${project.artifactId} diff --git a/bus-cache/pom.xml b/bus-cache/pom.xml index af4fa42f3c..cf3d448f58 100755 --- a/bus-cache/pom.xml +++ b/bus-cache/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-cache - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-core/README.md b/bus-core/README.md index 9a2992f2dc..9004bf2e85 100755 --- a/bus-core/README.md +++ b/bus-core/README.md @@ -14,7 +14,7 @@ org.aoju bus-core - 6.5.1 + 6.5.2 ``` diff --git a/bus-core/pom.xml b/bus-core/pom.xml index e3b9143df9..4ea584fb47 100755 --- a/bus-core/pom.xml +++ b/bus-core/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-core - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-core/src/main/java/org/aoju/bus/core/Version.java b/bus-core/src/main/java/org/aoju/bus/core/Version.java index a4757cd0d1..a933fe3f41 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/Version.java +++ b/bus-core/src/main/java/org/aoju/bus/core/Version.java @@ -60,7 +60,7 @@ public class Version { * @return 项目的版本号 */ public static String get() { - return "6.5.1.RELEASE"; + return "6.5.2.RELEASE"; } /** diff --git a/bus-core/src/main/java/org/aoju/bus/core/beans/PathExpression.java b/bus-core/src/main/java/org/aoju/bus/core/beans/PathExpression.java index 3e09a144a6..63815dac82 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/beans/PathExpression.java +++ b/bus-core/src/main/java/org/aoju/bus/core/beans/PathExpression.java @@ -168,20 +168,13 @@ public Object get(final Object bean) { } /** - * 设置表达式指定位置(或filed对应)的值 - * 若表达式指向一个List则设置其坐标对应位置的值,若指向Map则put对应key的值,Bean则设置字段的值 - * 注意: - * - *

-     * 1. 如果为List,如果下标不大于List长度,则替换原有值,否则追加值
-     * 2. 如果为数组,如果下标不大于数组长度,则替换原有值,否则追加值
-     * 
+ * 判断path列表中末尾的标记是否为数字 * - * @param bean Bean、Map或List - * @param value 值 + * @param patternParts path列表 + * @return 是否为数字 */ - public void set(final Object bean, final Object value) { - set(bean, this.patternParts, value); + private static boolean lastIsNumber(List patternParts) { + return MathKit.isInteger(patternParts.get(patternParts.size() - 1)); } @Override @@ -190,27 +183,13 @@ public String toString() { } /** - * 设置表达式指定位置(或filed对应)的值 - * 若表达式指向一个List则设置其坐标对应位置的值,若指向Map则put对应key的值,Bean则设置字段的值 - * 注意: - * - *
-     * 1. 如果为List,如果下标不大于List长度,则替换原有值,否则追加值
-     * 2. 如果为数组,如果下标不大于数组长度,则替换原有值,否则追加值
-     * 
+ * 获取父级路径列表 * - * @param bean Bean、Map或List - * @param patternParts 表达式块列表 - * @param value 值 + * @param patternParts 路径列表 + * @return 父级路径列表 */ - private void set(final Object bean, final List patternParts, final Object value) { - Object subBean = get(patternParts, bean, true); - if (null == subBean) { - set(bean, patternParts.subList(0, patternParts.size() - 1), new HashMap<>()); - //set中有可能做过转换,因此此处重新获取bean - subBean = get(patternParts, bean, true); - } - BeanKit.setFieldValue(subBean, patternParts.get(patternParts.size() - 1), value); + private static List getParentParts(List patternParts) { + return patternParts.subList(0, patternParts.size() - 1); } /** @@ -314,4 +293,46 @@ private void init(final String expression) { this.patternParts = CollKit.unmodifiable(localPatternParts); } + /** + * 设置表达式指定位置(或filed对应)的值 + * 若表达式指向一个List则设置其坐标对应位置的值,若指向Map则put对应key的值,Bean则设置字段的值 + * 注意: + * + *
+     * 1. 如果为List,如果下标不大于List长度,则替换原有值,否则追加值
+     * 2. 如果为数组,如果下标不大于数组长度,则替换原有值,否则追加值
+     * 
+ * + * @param bean Bean、Map或List + * @param value 值 + */ + public void set(final Object bean, final Object value) { + set(bean, this.patternParts, lastIsNumber(this.patternParts), value); + } + + /** + * 设置表达式指定位置(或filed对应)的值 + * 若表达式指向一个List则设置其坐标对应位置的值,若指向Map则put对应key的值,Bean则设置字段的值 + * 注意: + * + *
+     * 1. 如果为List,如果下标不大于List长度,则替换原有值,否则追加值
+     * 2. 如果为数组,如果下标不大于数组长度,则替换原有值,否则追加值
+     * 
+ * + * @param bean Bean、Map或List + * @param patternParts 表达式块列表 + * @param value 值 + */ + private void set(Object bean, List patternParts, boolean nextNumberPart, Object value) { + Object subBean = this.get(patternParts, bean, true); + if (null == subBean) { + final List parentParts = getParentParts(patternParts); + this.set(bean, parentParts, lastIsNumber(parentParts), nextNumberPart ? new ArrayList<>() : new HashMap<>()); + //set中有可能做过转换,因此此处重新获取bean + subBean = this.get(patternParts, bean, true); + } + BeanKit.setFieldValue(subBean, patternParts.get(patternParts.size() - 1), value); + } + } diff --git a/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java b/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java index de7c4af47c..1b4993b0a4 100644 --- a/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java +++ b/bus-core/src/main/java/org/aoju/bus/core/date/Converter.java @@ -302,7 +302,6 @@ public static LocalDate toLocalDate(YearMonth yearMonth, int dayOfMonth) { * @param date {@link Date} * @param zoneId {@link ZoneId} * @return {@link DateTime} - * @see DateTime(Date, ZoneId ) */ public static DateTime toTimeZone(Date date, ZoneId zoneId) { return new DateTime(date, ZoneKit.toTimeZone(zoneId)); @@ -314,7 +313,6 @@ public static DateTime toTimeZone(Date date, ZoneId zoneId) { * @param date {@link Date} * @param timeZone {@link TimeZone} * @return {@link DateTime} - * @see DateTime(Date,ZoneId) */ public static DateTime toTimeZone(Date date, TimeZone timeZone) { return new DateTime(date, timeZone); diff --git a/bus-core/src/main/java/org/aoju/bus/core/thread/BlockPolicy.java b/bus-core/src/main/java/org/aoju/bus/core/thread/BlockPolicy.java index 2ad09a9b19..725540dee7 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/thread/BlockPolicy.java +++ b/bus-core/src/main/java/org/aoju/bus/core/thread/BlockPolicy.java @@ -28,6 +28,7 @@ import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; +import java.util.function.Consumer; /** * 当任务队列过长时处于阻塞状态,直到添加到队列中,如果阻塞过程中被中断,就会抛出{@link InterruptedException}异常 @@ -38,13 +39,42 @@ */ public class BlockPolicy implements RejectedExecutionHandler { + /** + * 线程池关闭时,为避免任务丢失,留下处理方法 + * 如果需要由调用方来运行,可以{@code new BlockPolicy(Runnable::run)} + */ + private final Consumer handler; + + /** + * 构造 + * + * @param handler 线程池关闭后的执行策略 + */ + public BlockPolicy(final Consumer handler) { + this.handler = handler; + } + + /** + * 构造 + */ + public BlockPolicy() { + this(null); + } + @Override public void rejectedExecution(Runnable r, ThreadPoolExecutor e) { - try { - e.getQueue().put(r); - } catch (InterruptedException ex) { - throw new RejectedExecutionException("Task " + r + " rejected from " + e); + // 线程池未关闭时,阻塞等待 + if (false == e.isShutdown()) { + try { + e.getQueue().put(r); + } catch (InterruptedException ex) { + throw new RejectedExecutionException("Task " + r + " rejected from " + e); + } + } else if (null != handler) { + // 当设置了关闭时候的处理 + handler.accept(r); } + // 线程池关闭后,丢弃任务 } } diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java index f2257d233d..d5c075f100 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/CollKit.java @@ -3014,6 +3014,43 @@ public static List setOrAppend(List list, int index, T element) { return list; } + /** + * 在指定位置设置元素。当index小于List的长度时,替换指定位置的值,否则追加{@code null}直到到达index后,设置值 + * + * @param 元素类型 + * @param list List列表 + * @param index 位置 + * @param element 新元素 + * @return 原List + */ + public static List setOrPadding(List list, int index, T element) { + return setOrPadding(list, index, element, null); + } + + /** + * 在指定位置设置元素。当index小于List的长度时,替换指定位置的值,否则追加{@code paddingElement}直到到达index后,设置值 + * + * @param 元素类型 + * @param list List列表 + * @param index 位置 + * @param element 新元素 + * @param paddingElement 填充的值 + * @return 原List + */ + public static List setOrPadding(List list, int index, T element, T paddingElement) { + Assert.notNull(list, "List must be not null !"); + final int size = list.size(); + if (index < size) { + list.set(index, element); + } else { + for (int i = size; i < index; i++) { + list.add(paddingElement); + } + list.add(element); + } + return list; + } + /** * 将页数和每页条目数转换为开始位置和结束位置 * 此方法用于不包括结束位置的分页方法 diff --git a/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java b/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java index f19093ccb5..ffe8bbe659 100755 --- a/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java +++ b/bus-core/src/main/java/org/aoju/bus/core/toolkit/NetKit.java @@ -98,6 +98,17 @@ public static long ipv4ToLong(String strIP) { throw new IllegalArgumentException("Invalid IPv4 address!"); } + /** + * 根据ip地址(xxx.xxx.xxx.xxx)计算出long型的数据, 如果格式不正确返回 defaultValue + * + * @param strIP IP V4 地址 + * @param defaultValue 默认值 + * @return long值 + */ + public static long ipv4ToLong(String strIP, long defaultValue) { + return Validator.isIpv4(strIP) ? ipv4ToLong(strIP) : defaultValue; + } + /** * 将匹配到的Ipv4地址的4个分组分别处理 * diff --git a/bus-cron/pom.xml b/bus-cron/pom.xml index 4591e09b67..0ff5f5bf42 100755 --- a/bus-cron/pom.xml +++ b/bus-cron/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-cron - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-crypto/pom.xml b/bus-crypto/pom.xml index 714772b096..815fef1d34 100755 --- a/bus-crypto/pom.xml +++ b/bus-crypto/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-crypto - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-extra/pom.xml b/bus-extra/pom.xml index f8994a6b1d..7e744fb1c6 100644 --- a/bus-extra/pom.xml +++ b/bus-extra/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-extra - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-gitlab/README.md b/bus-gitlab/README.md index e63a97d83b..0af8fba165 100755 --- a/bus-gitlab/README.md +++ b/bus-gitlab/README.md @@ -70,7 +70,7 @@ dependencies { org.aoju bus-gitlab - 6.5.1 + 6.5.2 ``` diff --git a/bus-gitlab/pom.xml b/bus-gitlab/pom.xml index c9e2181375..91d6d19f36 100755 --- a/bus-gitlab/pom.xml +++ b/bus-gitlab/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-gitlab - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-goalie/pom.xml b/bus-goalie/pom.xml index 41f618ae6e..10ce91a048 100644 --- a/bus-goalie/pom.xml +++ b/bus-goalie/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-goalie - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-health/pom.xml b/bus-health/pom.xml index 7ea11db569..db1dd1dbf5 100755 --- a/bus-health/pom.xml +++ b/bus-health/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-health - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-health/src/main/java/org/aoju/bus/health/Config.java b/bus-health/src/main/java/org/aoju/bus/health/Config.java index cb5f436fc4..cf54cdeddf 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/Config.java +++ b/bus-health/src/main/java/org/aoju/bus/health/Config.java @@ -45,7 +45,6 @@ public final class Config { public static final String MACOS_VERSIONS_PROPERTIES = "bus.health.macos.version.properties"; public static final String VM_MAC_ADDR_PROPERTIES = "bus.health.vmmacaddr.properties"; public static final String ARCHITECTURE_PROPERTIES = "bus.health.architecture.properties"; - public static final String MEMOIZER_EXPIRATION = "bus.health.memoizer.expiration"; public static final String WMI_TIMEOUT = "bus.health.wmi.timeout"; public static final String PROC_PATH = "bus.health.proc.path"; @@ -57,13 +56,10 @@ public final class Config { public static final String OS_WINDOWS_HKEYPERFDATA = "bus.health.os.windows.hkeyperfdata"; public static final String OSHI_OS_WINDOWS_LOADAVERAGE = "bus.health.os.windows.loadaverage"; public static final String OS_WINDOWS_CPU_UTILITY = "bus.health.os.windows.cpu.utility"; - public static final String OS_WINDOWS_PERFDISK_DIABLED = "bus.os.windows.perfdisk.disabled"; public static final String OS_WINDOWS_PERFOS_DIABLED = "bus.os.windows.perfos.disabled"; public static final String OS_WINDOWS_PERFPROC_DIABLED = "bus.os.windows.perfproc.disabled"; - public static final String OS_UNIX_WHOCOMMAND = "bus.health.os.unix.whoCommand"; - private static final Properties CONFIG = readProperties(PROPERTIES); /** diff --git a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java index 8ce3f6e9de..f68f9c6a40 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java +++ b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/KstatKit.java @@ -69,6 +69,125 @@ private KstatKit() { } + /** + * A copy of the Kstat chain, encapsulating a {@code kstat_ctl_t} object. Only + * one thread may actively use this object at any time. + *

+ * The chain is created once calling {@link LibKstat#kstat_open} and then this + * object is instantiated using the {@link KstatKit#openChain} method. + * Instantiating this object updates the chain using + * {@link LibKstat#kstat_chain_update}. The control object should be closed with + * {@link #close}, which releases the lock and allows another instance to be + * instantiated. + */ + public static final class KstatChain implements AutoCloseable { + + private final KstatCtl localCtlRef; + + private KstatChain(KstatCtl ctl) { + this.localCtlRef = ctl; + update(); + } + + /** + * Convenience method for {@link LibKstat#kstat_read} which gets data from the + * kernel for the kstat pointed to by {@code ksp}. {@code ksp.ks_data} is + * automatically allocated (or reallocated) to be large enough to hold all of + * the data. {@code ksp.ks_ndata} is set to the number of data fields, + * {@code ksp.ks_data_size} is set to the total size of the data, and + * ksp.ks_snaptime is set to the high-resolution time at which the data snapshot + * was taken. + * + * @param ksp The kstat from which to retrieve data + * @return {@code true} if successful; {@code false} otherwise + */ + @GuardeBy("CHAIN") + public boolean read(Kstat ksp) { + int retry = 0; + while (0 > LibKstat.INSTANCE.kstat_read(localCtlRef, ksp, null)) { + if (LibKstat.EAGAIN != Native.getLastError() || 5 <= ++retry) { + if (Logger.isDebug()) { + Logger.debug("Failed to read kstat {}:{}:{}", + Native.toString(ksp.ks_module, StandardCharsets.US_ASCII), ksp.ks_instance, + Native.toString(ksp.ks_name, StandardCharsets.US_ASCII)); + } + return false; + } + ThreadKit.sleep(8 << retry); + } + return true; + } + + /** + * Convenience method for {@link LibKstat#kstat_lookup}. Traverses the kstat + * chain, searching for a kstat with the same {@code module}, {@code instance}, + * and {@code name} fields; this triplet uniquely identifies a kstat. If + * {@code module} is {@code null}, {@code instance} is -1, or {@code name} is + * {@code null}, then those fields will be ignored in the search. + * + * @param module The module, or null to ignore + * @param instance The instance, or -1 to ignore + * @param name The name, or null to ignore + * @return The first match of the requested Kstat structure if found, or + * {@code null} + */ + @GuardeBy("CHAIN") + public Kstat lookup(String module, int instance, String name) { + return LibKstat.INSTANCE.kstat_lookup(localCtlRef, module, instance, name); + } + + /** + * Convenience method for {@link LibKstat#kstat_lookup}. Traverses the kstat + * chain, searching for all kstats with the same {@code module}, + * {@code instance}, and {@code name} fields; this triplet uniquely identifies a + * kstat. If {@code module} is {@code null}, {@code instance} is -1, or + * {@code name} is {@code null}, then those fields will be ignored in the + * search. + * + * @param module The module, or null to ignore + * @param instance The instance, or -1 to ignore + * @param name The name, or null to ignore + * @return All matches of the requested Kstat structure if found, or an empty + * list otherwise + */ + @GuardeBy("CHAIN") + public List lookupAll(String module, int instance, String name) { + List kstats = new ArrayList<>(); + for (Kstat ksp = LibKstat.INSTANCE.kstat_lookup(localCtlRef, module, instance, name); ksp != null; ksp = ksp + .next()) { + if ((module == null || module.equals(Native.toString(ksp.ks_module, StandardCharsets.US_ASCII))) + && (instance < 0 || instance == ksp.ks_instance) + && (name == null || name.equals(Native.toString(ksp.ks_name, StandardCharsets.US_ASCII)))) { + kstats.add(ksp); + } + } + return kstats; + } + + /** + * Convenience method for {@link LibKstat#kstat_chain_update}. Brings this kstat + * header chain in sync with that of the kernel. + *

+ * This function compares the kernel's current kstat chain ID(KCID), which is + * incremented every time the kstat chain changes, to this object's KCID. + * + * @return the new KCID if the kstat chain has changed, 0 if it hasn't, or -1 on + * failure. + */ + @GuardeBy("CHAIN") + public int update() { + return LibKstat.INSTANCE.kstat_chain_update(localCtlRef); + } + + /** + * Release the lock on the chain. + */ + @Override + public void close() { + CHAIN.unlock(); + } + } + /** * Lock the Kstat chain for use by this object until it's closed. * @@ -245,123 +364,4 @@ public static List queryKstat2List(String beforeStr, String afterStr, return results; } - /** - * A copy of the Kstat chain, encapsulating a {@code kstat_ctl_t} object. Only - * one thread may actively use this object at any time. - *

- * The chain is created once calling {@link LibKstat#kstat_open} and then this - * object is instantiated using the {@link KstatKit#openChain} method. - * Instantiating this object updates the chain using - * {@link LibKstat#kstat_chain_update}. The control object should be closed with - * {@link #close}, which releases the lock and allows another instance to be - * instantiated. - */ - public static final class KstatChain implements AutoCloseable { - - private final KstatCtl localCtlRef; - - private KstatChain(KstatCtl ctl) { - this.localCtlRef = ctl; - update(); - } - - /** - * Convenience method for {@link LibKstat#kstat_read} which gets data from the - * kernel for the kstat pointed to by {@code ksp}. {@code ksp.ks_data} is - * automatically allocated (or reallocated) to be large enough to hold all of - * the data. {@code ksp.ks_ndata} is set to the number of data fields, - * {@code ksp.ks_data_size} is set to the total size of the data, and - * ksp.ks_snaptime is set to the high-resolution time at which the data snapshot - * was taken. - * - * @param ksp The kstat from which to retrieve data - * @return {@code true} if successful; {@code false} otherwise - */ - @GuardeBy("CHAIN") - public boolean read(Kstat ksp) { - int retry = 0; - while (0 > LibKstat.INSTANCE.kstat_read(localCtlRef, ksp, null)) { - if (LibKstat.EAGAIN != Native.getLastError() || 5 <= ++retry) { - if (Logger.isDebug()) { - Logger.debug("Failed to read kstat {}:{}:{}", - Native.toString(ksp.ks_module, StandardCharsets.US_ASCII), ksp.ks_instance, - Native.toString(ksp.ks_name, StandardCharsets.US_ASCII)); - } - return false; - } - ThreadKit.sleep(8 << retry); - } - return true; - } - - /** - * Convenience method for {@link LibKstat#kstat_lookup}. Traverses the kstat - * chain, searching for a kstat with the same {@code module}, {@code instance}, - * and {@code name} fields; this triplet uniquely identifies a kstat. If - * {@code module} is {@code null}, {@code instance} is -1, or {@code name} is - * {@code null}, then those fields will be ignored in the search. - * - * @param module The module, or null to ignore - * @param instance The instance, or -1 to ignore - * @param name The name, or null to ignore - * @return The first match of the requested Kstat structure if found, or - * {@code null} - */ - @GuardeBy("CHAIN") - public Kstat lookup(String module, int instance, String name) { - return LibKstat.INSTANCE.kstat_lookup(localCtlRef, module, instance, name); - } - - /** - * Convenience method for {@link LibKstat#kstat_lookup}. Traverses the kstat - * chain, searching for all kstats with the same {@code module}, - * {@code instance}, and {@code name} fields; this triplet uniquely identifies a - * kstat. If {@code module} is {@code null}, {@code instance} is -1, or - * {@code name} is {@code null}, then those fields will be ignored in the - * search. - * - * @param module The module, or null to ignore - * @param instance The instance, or -1 to ignore - * @param name The name, or null to ignore - * @return All matches of the requested Kstat structure if found, or an empty - * list otherwise - */ - @GuardeBy("CHAIN") - public List lookupAll(String module, int instance, String name) { - List kstats = new ArrayList<>(); - for (Kstat ksp = LibKstat.INSTANCE.kstat_lookup(localCtlRef, module, instance, name); ksp != null; ksp = ksp - .next()) { - if ((module == null || module.equals(Native.toString(ksp.ks_module, StandardCharsets.US_ASCII))) - && (instance < 0 || instance == ksp.ks_instance) - && (name == null || name.equals(Native.toString(ksp.ks_name, StandardCharsets.US_ASCII)))) { - kstats.add(ksp); - } - } - return kstats; - } - - /** - * Convenience method for {@link LibKstat#kstat_chain_update}. Brings this kstat - * header chain in sync with that of the kernel. - *

- * This function compares the kernel's current kstat chain ID(KCID), which is - * incremented every time the kstat chain changes, to this object's KCID. - * - * @return the new KCID if the kstat chain has changed, 0 if it hasn't, or -1 on - * failure. - */ - @GuardeBy("CHAIN") - public int update() { - return LibKstat.INSTANCE.kstat_chain_update(localCtlRef); - } - - /** - * Release the lock on the chain. - */ - @Override - public void close() { - CHAIN.unlock(); - } - } - -} +} \ No newline at end of file diff --git a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisCentralProcessor.java b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisCentralProcessor.java index 1ab8a38696..a77cc00ce0 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisCentralProcessor.java +++ b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisCentralProcessor.java @@ -302,7 +302,7 @@ public long[] queryCurrentFreq() { try (KstatKit.KstatChain kc = KstatKit.openChain()) { for (int i = 0; i < freqs.length; i++) { for (Kstat ksp : kc.lookupAll(CPU_INFO, i, null)) { - if (kc.read(ksp)) { + if (ksp != null && kc.read(ksp)) { freqs[i] = KstatKit.dataLookupLong(ksp, "current_clock_Hz"); } } diff --git a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisPowerSource.java b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisPowerSource.java index e316aa71aa..10bf631552 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisPowerSource.java +++ b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/hardware/SolarisPowerSource.java @@ -111,7 +111,7 @@ private static SolarisPowerSource getPowerSource(String name) { // Get kstat for the battery information try (KstatKit.KstatChain kc = KstatKit.openChain()) { Kstat ksp = kc.lookup(KSTAT_BATT_MOD[KSTAT_BATT_IDX], 0, "battery BIF0"); - if (ksp != null) { + if (ksp != null && kc.read(ksp)) { // Predicted battery capacity when fully charged. long energyFull = KstatKit.dataLookupLong(ksp, "bif_last_cap"); if (energyFull == 0xffffffff || energyFull <= 0) { @@ -134,7 +134,7 @@ private static SolarisPowerSource getPowerSource(String name) { // Get kstat for the battery state ksp = kc.lookup(KSTAT_BATT_MOD[KSTAT_BATT_IDX], 0, "battery BST0"); - if (ksp != null) { + if (ksp != null && kc.read(ksp)) { // estimated remaining battery capacity long energyNow = KstatKit.dataLookupLong(ksp, "bst_rem_cap"); if (energyNow >= 0) { diff --git a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/software/SolarisOperatingSystem.java b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/software/SolarisOperatingSystem.java index 6c92e153ac..f552ae3246 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/software/SolarisOperatingSystem.java +++ b/bus-health/src/main/java/org/aoju/bus/health/unix/solaris/software/SolarisOperatingSystem.java @@ -124,7 +124,7 @@ private static long querySystemUptime() { } try (KstatKit.KstatChain kc = KstatKit.openChain()) { Kstat ksp = kc.lookup("unix", 0, "system_misc"); - if (ksp != null) { + if (ksp != null && kc.read(ksp)) { // Snap Time is in nanoseconds; divide for seconds return ksp.ks_snaptime / 1_000_000_000L; } diff --git a/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/LogicalProcessorInformation.java b/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/LogicalProcessorInformation.java index c528592f35..192c3f89d7 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/LogicalProcessorInformation.java +++ b/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/LogicalProcessorInformation.java @@ -94,10 +94,10 @@ public static Pair, List> getLogicalPr } // Windows doesn't define core and package numbers, so we define our own for // consistent use across the API. Here we sort so core and package numbers - // increment consistently with processor umbers/bitmasks, ordered in groups. - cores.sort(Comparator.comparing(c -> c.group * 64L + c.mask.longValue())); + // increment consistently with processor numbers/bitmasks, ordered in groups. + cores.sort(Comparator.comparing(c -> c.group * 64L + Long.numberOfTrailingZeros(c.mask.longValue()))); // if package in multiple groups will still use first group for sorting - packages.sort(Comparator.comparing(p -> p[0].group * 64L + p[0].mask.longValue())); + packages.sort(Comparator.comparing(p -> p[0].group * 64L + Long.numberOfTrailingZeros(p[0].mask.longValue()))); // Iterate Logical Processors and use bitmasks to match packages, cores, // and NUMA nodes. Perfmon instances are numa node + processor number, so we diff --git a/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/registry/HkeyPerformanceDataUtil.java b/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/registry/HkeyPerformanceDataUtil.java index 1aac8976d0..ff14212a55 100644 --- a/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/registry/HkeyPerformanceDataUtil.java +++ b/bus-health/src/main/java/org/aoju/bus/health/windows/drivers/registry/HkeyPerformanceDataUtil.java @@ -55,6 +55,8 @@ public final class HkeyPerformanceDataUtil { private static final String COUNTER = "Counter"; private static final Map COUNTER_INDEX_MAP = mapCounterIndicesFromRegistry(); + private static int maxPerfBufferSize = 4096; + /** * Reads and parses a block of performance data from the registry. * @@ -234,14 +236,14 @@ private static & PerfCounterWildcardQuery.PdhCounterWildcardP * {@link #COUNTER_INDEX_MAP}. * @return A buffer containing the data if successful, null otherwise. */ - private static Memory readPerfDataBuffer(String objectName) { + private static synchronized Memory readPerfDataBuffer(String objectName) { // Need this index as a string String objectIndexStr = Integer.toString(COUNTER_INDEX_MAP.get(objectName)); // Now load the data from the regsitry. - int bufferSize = 4096; - IntByReference lpcbData = new IntByReference(bufferSize); - Memory pPerfData = new Memory(bufferSize); + + IntByReference lpcbData = new IntByReference(maxPerfBufferSize); + Memory pPerfData = new Memory(maxPerfBufferSize); int ret = Advapi32.INSTANCE.RegQueryValueEx(WinReg.HKEY_PERFORMANCE_DATA, objectIndexStr, 0, null, pPerfData, lpcbData); if (ret != WinError.ERROR_SUCCESS && ret != WinError.ERROR_MORE_DATA) { @@ -250,9 +252,9 @@ private static Memory readPerfDataBuffer(String objectName) { } // Grow buffer as needed to fit the data while (ret == WinError.ERROR_MORE_DATA) { - bufferSize += 4096; - lpcbData.setValue(bufferSize); - pPerfData = new Memory(bufferSize); + maxPerfBufferSize += 4096; + lpcbData.setValue(maxPerfBufferSize); + pPerfData = new Memory(maxPerfBufferSize); ret = Advapi32.INSTANCE.RegQueryValueEx(WinReg.HKEY_PERFORMANCE_DATA, objectIndexStr, 0, null, pPerfData, lpcbData); } diff --git a/bus-http/pom.xml b/bus-http/pom.xml index b395f22a9f..974cfc1c0b 100755 --- a/bus-http/pom.xml +++ b/bus-http/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-http - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-image/pom.xml b/bus-image/pom.xml index c66cd6c04e..8f32a6f07c 100755 --- a/bus-image/pom.xml +++ b/bus-image/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-image - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-limiter/pom.xml b/bus-limiter/pom.xml index 03e3eeb673..f4d03822d3 100755 --- a/bus-limiter/pom.xml +++ b/bus-limiter/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-limiter - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-logger/pom.xml b/bus-logger/pom.xml index c85667711e..c518228abc 100644 --- a/bus-logger/pom.xml +++ b/bus-logger/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-logger - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-mapper/pom.xml b/bus-mapper/pom.xml index c423f7fbab..84b3d0162f 100755 --- a/bus-mapper/pom.xml +++ b/bus-mapper/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-mapper - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-notify/README.md b/bus-notify/README.md index 44b88ab10b..e8ee1f31b6 100755 --- a/bus-notify/README.md +++ b/bus-notify/README.md @@ -11,7 +11,7 @@ org.aoju bus-notify - 6.5.1 + 6.5.2 ``` diff --git a/bus-notify/pom.xml b/bus-notify/pom.xml index 1676c4a377..eea110897f 100755 --- a/bus-notify/pom.xml +++ b/bus-notify/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-notify - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-oauth/README.md b/bus-oauth/README.md index f1657a2906..fc477dbedf 100755 --- a/bus-oauth/README.md +++ b/bus-oauth/README.md @@ -16,7 +16,7 @@ org.aoju bus-oauth - 6.5.1 + 6.5.2 ``` diff --git a/bus-oauth/pom.xml b/bus-oauth/pom.xml index 1e147672f7..41ce7ba6c1 100755 --- a/bus-oauth/pom.xml +++ b/bus-oauth/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-oauth - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-office/pom.xml b/bus-office/pom.xml index 03d5a1313b..d6cddb9e0e 100755 --- a/bus-office/pom.xml +++ b/bus-office/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-office - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-opencv/pom.xml b/bus-opencv/pom.xml index bc0e6295a5..6b8246bf37 100755 --- a/bus-opencv/pom.xml +++ b/bus-opencv/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-opencv - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-pager/README.md b/bus-pager/README.md index 827404f310..b2b61e2ccd 100755 --- a/bus-pager/README.md +++ b/bus-pager/README.md @@ -42,7 +42,7 @@ org.aoju bus-pager - 6.5.1 + 6.5.2 ``` diff --git a/bus-pager/pom.xml b/bus-pager/pom.xml index 03450fcaf7..8307ecc51e 100755 --- a/bus-pager/pom.xml +++ b/bus-pager/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-pager - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-pay/pom.xml b/bus-pay/pom.xml index b74e8bf484..26186cacb2 100644 --- a/bus-pay/pom.xml +++ b/bus-pay/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-pay - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-proxy/pom.xml b/bus-proxy/pom.xml index 85e15c368d..49132b4533 100755 --- a/bus-proxy/pom.xml +++ b/bus-proxy/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-proxy - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-sensitive/pom.xml b/bus-sensitive/pom.xml index 832a551036..bef8bd208d 100755 --- a/bus-sensitive/pom.xml +++ b/bus-sensitive/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-sensitive - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-setting/pom.xml b/bus-setting/pom.xml index b815fc7267..c7be60f76b 100755 --- a/bus-setting/pom.xml +++ b/bus-setting/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-setting - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-shade/pom.xml b/bus-shade/pom.xml index cd2ff2c8c4..daa64dce9b 100755 --- a/bus-shade/pom.xml +++ b/bus-shade/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-shade - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-socket/pom.xml b/bus-socket/pom.xml index 012a0fb2a1..9032ad2dbe 100755 --- a/bus-socket/pom.xml +++ b/bus-socket/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-socket - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-starter/pom.xml b/bus-starter/pom.xml index d711405f3a..a2f345f61e 100755 --- a/bus-starter/pom.xml +++ b/bus-starter/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-starter - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-storage/pom.xml b/bus-storage/pom.xml index 7b2e753313..d9c668ab6f 100755 --- a/bus-storage/pom.xml +++ b/bus-storage/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-storage - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-tracer/pom.xml b/bus-tracer/pom.xml index 7c67e9c8f0..da4e10c50d 100755 --- a/bus-tracer/pom.xml +++ b/bus-tracer/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-tracer - 6.5.1 + 6.5.2 jar ${project.artifactId} diff --git a/bus-validate/pom.xml b/bus-validate/pom.xml index ff4d41434b..8eb9000624 100755 --- a/bus-validate/pom.xml +++ b/bus-validate/pom.xml @@ -6,7 +6,7 @@ org.aoju bus-validate - 6.5.1 + 6.5.2 jar ${project.artifactId} From e8183746b4d90b90ae6dad4a57b360e252b737ad Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Wed, 22 Jun 2022 10:58:36 +0800 Subject: [PATCH 7/9] v6.5.2 --- .../org/aoju/bus/logger/GlobalFactory.java | 3 -- .../commons/ApacheCommonsLog4JLog.java | 52 ------------------- .../commons/ApacheCommonsLogFactory.java | 12 +---- 3 files changed, 2 insertions(+), 65 deletions(-) delete mode 100755 bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLog4JLog.java diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/GlobalFactory.java b/bus-logger/src/main/java/org/aoju/bus/logger/GlobalFactory.java index 2146c6da3e..eb26f2b5a2 100755 --- a/bus-logger/src/main/java/org/aoju/bus/logger/GlobalFactory.java +++ b/bus-logger/src/main/java/org/aoju/bus/logger/GlobalFactory.java @@ -28,7 +28,6 @@ import org.aoju.bus.logger.dialect.commons.ApacheCommonsLogFactory; import org.aoju.bus.logger.dialect.console.ConsoleLogFactory; import org.aoju.bus.logger.dialect.jdk.JdkLogFactory; -import org.aoju.bus.logger.dialect.log4j.Log4jLogFactory; import org.aoju.bus.logger.dialect.log4j2.Log4j2LogFactory; import org.aoju.bus.logger.dialect.slf4j.Slf4jLogFactory; @@ -66,7 +65,6 @@ public static LogFactory get() { * @param logFactoryClass 日志工厂类 * @return 自定义的日志工厂类 * @see Slf4jLogFactory - * @see Log4jLogFactory * @see Log4j2LogFactory * @see ApacheCommonsLogFactory * @see JdkLogFactory @@ -86,7 +84,6 @@ public static LogFactory set(Class logFactoryClass) { * @param logFactory 日志工厂类对象 * @return 自定义的日志工厂类 * @see Slf4jLogFactory - * @see Log4jLogFactory * @see Log4j2LogFactory * @see ApacheCommonsLogFactory * @see JdkLogFactory diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLog4JLog.java b/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLog4JLog.java deleted file mode 100755 index 9b8618b127..0000000000 --- a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLog4JLog.java +++ /dev/null @@ -1,52 +0,0 @@ -/********************************************************************************* - * * - * The MIT License (MIT) * - * * - * Copyright (c) 2015-2022 aoju.org and other contributors. * - * * - * Permission is hereby granted, free of charge, to any person obtaining a copy * - * of this software and associated documentation files (the "Software"), to deal * - * in the Software without restriction, including without limitation the rights * - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * - * copies of the Software, and to permit persons to whom the Software is * - * furnished to do so, subject to the following conditions: * - * * - * The above copyright notice and this permission notice shall be included in * - * all copies or substantial portions of the Software. * - * * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * - * THE SOFTWARE. * - * * - ********************************************************************************/ -package org.aoju.bus.logger.dialect.commons; - -import org.aoju.bus.logger.dialect.log4j.Log4jLog; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.impl.Log4JLogger; - -/** - * Apache Commons Logging for Log4j - * - * @author Kimi Liu - * @since Java 17+ - */ -public class ApacheCommonsLog4JLog extends Log4jLog { - - public ApacheCommonsLog4JLog(Log logger) { - super(((Log4JLogger) logger).getLogger()); - } - - public ApacheCommonsLog4JLog(Class clazz) { - super(clazz); - } - - public ApacheCommonsLog4JLog(String name) { - super(name); - } - -} diff --git a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLogFactory.java b/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLogFactory.java index 6e4e3f94f3..6f841490b6 100755 --- a/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLogFactory.java +++ b/bus-logger/src/main/java/org/aoju/bus/logger/dialect/commons/ApacheCommonsLogFactory.java @@ -43,20 +43,12 @@ public ApacheCommonsLogFactory() { @Override public Log createLog(String name) { - try { - return new ApacheCommonsLog4JLog(name); - } catch (Exception e) { - return new ApacheCommonsLog(name); - } + return new ApacheCommonsLog(name); } @Override public Log createLog(Class clazz) { - try { - return new ApacheCommonsLog4JLog(clazz); - } catch (Exception e) { - return new ApacheCommonsLog(clazz); - } + return new ApacheCommonsLog(clazz); } @Override From dc1f3464ccb5d1f06f5ae9c9c1c39d541cdee128 Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Wed, 22 Jun 2022 11:22:45 +0800 Subject: [PATCH 8/9] v6.5.2 --- .../aoju/bus/limiter/support/rate/redis/RedisRatelimiter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus-limiter/src/main/java/org/aoju/bus/limiter/support/rate/redis/RedisRatelimiter.java b/bus-limiter/src/main/java/org/aoju/bus/limiter/support/rate/redis/RedisRatelimiter.java index a7acbcc22f..81db1b1743 100755 --- a/bus-limiter/src/main/java/org/aoju/bus/limiter/support/rate/redis/RedisRatelimiter.java +++ b/bus-limiter/src/main/java/org/aoju/bus/limiter/support/rate/redis/RedisRatelimiter.java @@ -73,7 +73,7 @@ public RateLimiterRedission(Config config) { } public RedisRatelimiterObject getRedisRatelimiterObject(String name) { - return new RedisRatelimiterObject(connectionManager.getCommandExecutor(), name); + return new RedisRatelimiterObject(commandExecutor, name); } } From 43a07873200e8d3283f71c99024e46ab34652820 Mon Sep 17 00:00:00 2001 From: Kimi Liu <839536@qq.com> Date: Wed, 22 Jun 2022 11:54:37 +0800 Subject: [PATCH 9/9] v6.5.2 --- bus-starter/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus-starter/pom.xml b/bus-starter/pom.xml index a2f345f61e..75ff47598c 100755 --- a/bus-starter/pom.xml +++ b/bus-starter/pom.xml @@ -56,7 +56,7 @@ 8.0.29 3.0.8 4.0.4 - 8.2.3 + 7.17.4