mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
0df74202c2
commit
1ad628f944
@ -11,8 +11,8 @@ hutool版本: 5.X.X(请确保最新尝试是否还有问题)
|
||||
Console.log("报错了");
|
||||
```
|
||||
|
||||
2. 堆栈信息
|
||||
1. 堆栈信息
|
||||
|
||||
3. 测试涉及到的文件(注意脱密)
|
||||
2. 测试涉及到的文件(注意脱密)
|
||||
|
||||
比如报错的Excel文件,有问题的图片等。
|
4
.github/ISSUE_TEMPLATE.md
vendored
4
.github/ISSUE_TEMPLATE.md
vendored
@ -11,8 +11,8 @@ hutool版本: 5.X.X(请确保最新尝试是否还有问题)
|
||||
Console.log("报错了");
|
||||
```
|
||||
|
||||
2. 堆栈信息
|
||||
1. 堆栈信息
|
||||
|
||||
3. 测试涉及到的文件(注意脱密)
|
||||
2. 测试涉及到的文件(注意脱密)
|
||||
|
||||
比如报错的Excel文件,有问题的图片等。
|
@ -176,10 +176,10 @@ cd ${hutool}
|
||||
|
||||
Hutool's source code is divided into two branches:
|
||||
|
||||
| branch | description |
|
||||
|-----------|---------------------------------------------------------------|
|
||||
| branch | description |
|
||||
|-----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| v6-master | The master branch, the branch used by the release version, is the same as the jar committed to the central repository and does not receive any pr or modifications. |
|
||||
| v6-dev | Development branch, which defaults to the next SNAPSHOT version, accepts modifications or pr |
|
||||
| v6-dev | Development branch, which defaults to the next SNAPSHOT version, accepts modifications or pr |
|
||||
|
||||
### 🐞Provide feedback or suggestions on bugs
|
||||
|
||||
|
@ -180,10 +180,10 @@ implementation 'cn.hutool:hutool-all:6.0.0.M1'
|
||||
|
||||
Hutool的源码分为两个分支,功能如下:
|
||||
|
||||
| 分支 | 作用 |
|
||||
|-----------|---------------------------------------------------------------|
|
||||
| 分支 | 作用 |
|
||||
|-----------|--------------------------------------------|
|
||||
| v6-master | 主分支,release版本使用的分支,与中央库提交的jar一致,不接收任何pr或修改 |
|
||||
| v6-dev | 开发分支,默认为下个版本的SNAPSHOT版本,接受修改或pr |
|
||||
| v6-dev | 开发分支,默认为下个版本的SNAPSHOT版本,接受修改或pr |
|
||||
|
||||
### 🐞提供bug反馈或建议
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
## Supported Versions(支持的版本)
|
||||
|
||||
| Version | Supported |
|
||||
|---------| ------------------ |
|
||||
|---------|--------------------|
|
||||
| 6.x.x | :white_check_mark: |
|
||||
|
||||
## Reporting a Vulnerability(报告漏洞)
|
||||
|
@ -12,7 +12,7 @@ echo "当前路径:${pwd}"
|
||||
|
||||
if [ -n "$1" ];then
|
||||
new_version="$1"
|
||||
old_version=`cat ${pwd}/bin/version.txt`
|
||||
old_version=$(cat "${pwd}"/bin/version.txt)
|
||||
echo "$old_version 替换为新版本 $new_version"
|
||||
else
|
||||
# 参数错误,退出
|
||||
@ -20,16 +20,16 @@ else
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -n "$old_version" ]; then
|
||||
if [ -z "$old_version" ]; then
|
||||
echo "ERROR: 旧版本不存在,请确认bin/version.txt中信息正确"
|
||||
exit
|
||||
fi
|
||||
|
||||
# 替换README.md中的版本
|
||||
sed -i "s/${old_version}/${new_version}/g" $pwd/README.md
|
||||
sed -i "s/${old_version}/${new_version}/g" $pwd/README-EN.md
|
||||
sed -i "s/${old_version}/${new_version}/g" "$pwd"/README.md
|
||||
sed -i "s/${old_version}/${new_version}/g" "$pwd"/README-EN.md
|
||||
# 替换docs/js/version.js中的版本
|
||||
sed -i "s/${old_version}/${new_version}/g" $pwd/docs/js/version.js
|
||||
sed -i "s/${old_version}/${new_version}/g" "$pwd"/docs/js/version.js
|
||||
|
||||
# 保留新版本号
|
||||
echo "$new_version" > $pwd/bin/version.txt
|
||||
echo "$new_version" > "$pwd"/bin/version.txt
|
||||
|
@ -28,7 +28,7 @@ public interface AnnotationMapping<T extends Annotation> extends Annotation {
|
||||
T getAnnotation();
|
||||
|
||||
/**
|
||||
* 根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致的合成注解,该注解相对原生注解:
|
||||
* 根据当前映射对象,通过动态代理生成一个类型与被包装注解对象一致地合成注解,该注解相对原生注解:
|
||||
* <ul>
|
||||
* <li>支持同注解内通过{@link Alias}构建的别名机制;</li>
|
||||
* <li>支持子注解对元注解的同名同类型属性覆盖机制;</li>
|
||||
|
@ -73,7 +73,7 @@ public class BetweenFormatter implements Serializable {
|
||||
final int level = this.level.ordinal();
|
||||
int levelCount = 0;
|
||||
|
||||
if (isLevelCountValid(levelCount) && 0 != day && level >= Level.DAY.ordinal()) {
|
||||
if (isLevelCountValid(levelCount) && 0 != day) {
|
||||
sb.append(day).append(Level.DAY.name);
|
||||
levelCount++;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -246,7 +247,7 @@ public class FileReader extends FileWrapper {
|
||||
*/
|
||||
public BufferedInputStream getInputStream() throws IORuntimeException {
|
||||
try {
|
||||
return new BufferedInputStream(new FileInputStream(this.file));
|
||||
return new BufferedInputStream(Files.newInputStream(this.file.toPath()));
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@ -123,6 +123,7 @@ public class ResourceUtil {
|
||||
*
|
||||
* @param resource 资源(相对Classpath的路径)
|
||||
* @return 资源URL
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public static URL getResourceUrl(final String resource) throws IORuntimeException {
|
||||
return getResourceUrl(resource, null);
|
||||
|
@ -24,7 +24,7 @@ import java.util.function.Predicate;
|
||||
* </table>
|
||||
*
|
||||
* <p>空区间</p>
|
||||
* <p>根据数学定义,当区间中无任何实数时,认为该区间代表的集合为空集,
|
||||
* <p>根据数学定义,当区间中无任何实数时,认为该区间 代表的集合为空集,
|
||||
* 用户可通过{@link #isEmpty}确认当前实例是否为空区间。<br>
|
||||
* 若实例上界<em>a</em>,下界为<em>b</em>,则当实例满足下述任意条件时,认为其为一个空区间:
|
||||
* <ul>
|
||||
|
@ -254,6 +254,7 @@ public interface TerminableWrappedStream<T, S extends TerminableWrappedStream<T,
|
||||
* @param predicate 断言
|
||||
* @return 与给定断言匹配的第一个元素的下标,如果不存在则返回-1
|
||||
*/
|
||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||
default int findFirstIdx(final Predicate<? super T> predicate) {
|
||||
Objects.requireNonNull(predicate);
|
||||
if (isParallel()) {
|
||||
@ -263,7 +264,7 @@ public interface TerminableWrappedStream<T, S extends TerminableWrappedStream<T,
|
||||
unwrap().filter(e -> {
|
||||
index.increment();
|
||||
return predicate.test(e);
|
||||
}).findFirst();
|
||||
}).findFirst();// 此处只做计数,不需要值
|
||||
return index.get();
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ public class AntPathMatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* Test whether or not a string matches against a pattern.
|
||||
* Test whether a string matches against a pattern.
|
||||
*
|
||||
* @param pattern the pattern to match against (never {@code null})
|
||||
* @param str the String which must be matched against the pattern (never {@code null})
|
||||
|
@ -89,7 +89,7 @@ public class ArrayUtil extends PrimitiveArrayUtil {
|
||||
* 数组是否为非空<br>
|
||||
* 此方法会匹配单一对象,如果此对象为{@code null}则返回false<br>
|
||||
* 如果此对象为非数组,理解为此对象为数组的第一个元素,则返回true<br>
|
||||
* 如果此对象为数组对象,数组长度大于0情况下返回true,否则返回false
|
||||
* 如果此对象为数组对象,数组长度大于0的情况下返回true,否则返回false
|
||||
*
|
||||
* @param array 数组
|
||||
* @return 是否为非空
|
||||
|
@ -280,6 +280,7 @@ public class StrUtilTest {
|
||||
Assert.assertEquals("ghigh", pre);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SimplifiableAssertion")
|
||||
@Test
|
||||
public void subPreTest() {
|
||||
Assert.assertEquals(StrUtil.subPre(null, 3), null);
|
||||
|
@ -216,7 +216,7 @@ public class ArrayUtilTest {
|
||||
final String[] a = {"1", "2", "3", "4"};
|
||||
final String[] b = {"a", "b", "c"};
|
||||
|
||||
// 在-1位置插入,相当于在3位置插入
|
||||
// 在-1的位置插入,相当于在3的位置插入
|
||||
String[] result = ArrayUtil.insert(a, -1, b);
|
||||
Assert.assertArrayEquals(new String[]{"1", "2", "3", "a", "b", "c", "4"}, result);
|
||||
|
||||
@ -232,7 +232,7 @@ public class ArrayUtilTest {
|
||||
result = ArrayUtil.insert(a, 4, b);
|
||||
Assert.assertArrayEquals(new String[]{"1", "2", "3", "4", "a", "b", "c"}, result);
|
||||
|
||||
// 在第5个位置插入,由于数组长度为4,因此补null
|
||||
// 在第5个位置插入,由于数组长度为4,因此补充null
|
||||
result = ArrayUtil.insert(a, 5, b);
|
||||
Assert.assertArrayEquals(new String[]{"1", "2", "3", "4", null, "a", "b", "c"}, result);
|
||||
}
|
||||
@ -472,7 +472,7 @@ public class ArrayUtilTest {
|
||||
final String[] a = {"1", "2", "3", "4"};
|
||||
final String[] b = {"a", "b", "c"};
|
||||
|
||||
// 在小于0的位置,-1位置插入,返回b+a,新数组
|
||||
// 在小于0的位置,-1的位置插入,返回b+a,新数组
|
||||
String[] result = ArrayUtil.replace(a, -1, b);
|
||||
Assert.assertArrayEquals(new String[]{"a", "b", "c", "1", "2", "3", "4"}, result);
|
||||
|
||||
|
@ -2,8 +2,8 @@ package cn.hutool.core.util;
|
||||
|
||||
import cn.hutool.core.compress.ZipReader;
|
||||
import cn.hutool.core.compress.ZipUtil;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.io.file.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import org.junit.Assert;
|
||||
@ -11,11 +11,12 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipFile;
|
||||
@ -156,7 +157,7 @@ public class ZipUtilTest {
|
||||
//https://github.com/dromara/hutool/issues/944
|
||||
final String dir = "d:/test";
|
||||
final String zip = "d:/test.zip";
|
||||
try (final OutputStream out = new FileOutputStream(zip)){
|
||||
try (final OutputStream out = Files.newOutputStream(Paths.get(zip))){
|
||||
//实际应用中, out 为 HttpServletResponse.getOutputStream
|
||||
ZipUtil.zip(out, Charset.defaultCharset(), false, null, new File(dir));
|
||||
} catch (final IOException e) {
|
||||
|
@ -34,7 +34,7 @@ import java.security.spec.ECPublicKeySpec;
|
||||
public class BCUtil {
|
||||
|
||||
/**
|
||||
* 只获取私钥里的d,32字节
|
||||
* 只获取私钥里的d,32位字节
|
||||
*
|
||||
* @param privateKey {@link PublicKey},必须为org.bouncycastle.jcajce.provider.asymmetric.ec.BCECPrivateKey
|
||||
* @return 压缩得到的X
|
||||
|
@ -3,11 +3,11 @@ package cn.hutool.crypto.symmetric;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* https://gitee.com/dromara/hutool/issues/I4EMST
|
||||
@ -29,8 +29,8 @@ public class Sm4StreamTest {
|
||||
}
|
||||
|
||||
public static void encrypt(final String source, final String target) {
|
||||
try (final InputStream input = new FileInputStream(source);
|
||||
final OutputStream out = new FileOutputStream(target)) {
|
||||
try (final InputStream input = Files.newInputStream(Paths.get(source));
|
||||
final OutputStream out = Files.newOutputStream(Paths.get(target))) {
|
||||
sm4.encrypt(input, out, IS_CLOSE);
|
||||
System.out.println("============encrypt end");
|
||||
} catch (final IOException e) {
|
||||
@ -39,8 +39,8 @@ public class Sm4StreamTest {
|
||||
}
|
||||
|
||||
public static void decrypt(final String source, final String target) {
|
||||
try (final InputStream input = new FileInputStream(source);
|
||||
final OutputStream out = new FileOutputStream(target)) {
|
||||
try (final InputStream input = Files.newInputStream(Paths.get(source));
|
||||
final OutputStream out = Files.newOutputStream(Paths.get(target))) {
|
||||
sm4.decrypt(input, out, IS_CLOSE);
|
||||
System.out.println("============decrypt end");
|
||||
} catch (final IOException e) {
|
||||
|
@ -37,7 +37,7 @@ initialSize = 10
|
||||
maxActive = 100
|
||||
# (int) 最大空闲连接: 连接池中容许保持空闲状态的最大连接数量, 超过的空闲连接将被释放, 如果设置为负数表示不限制 如果启用,将定期检查限制连接,如果空闲时间超过minEvictableIdleTimeMillis 则释放连接 ( 参考testWhileIdle )
|
||||
maxIdle = 8
|
||||
# (int) 最小空闲连接: 连接池中容许保持空闲状态的最小连接数量, 低于这个数量将创建新的连接, 如果设置为0 则不创建 如果连接验证失败将缩小这个值( 参考testWhileIdle )
|
||||
# (int) 最小空闲连接: 连接池中容许保持空闲状态的最小连接数量, 低于这个数量将创建新连接, 如果设置为0 则不创建 如果连接验证失败将缩小这个值( 参考testWhileIdle )
|
||||
minIdle = 0
|
||||
# (int) 最大等待时间: 当没有可用连接时, 连接池等待连接被归还的最大时间( 以毫秒计数), 超过时间则抛出异常, 如果设置为-1 表示无限等待
|
||||
maxWait = 30000
|
||||
@ -48,4 +48,4 @@ testOnBorrow = false
|
||||
# (boolean) 指明是否在归还到池中前进行检验 注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
|
||||
testOnReturn = false
|
||||
# (boolean) 指明连接是否被空闲连接回收器( 如果有) 进行检验。 如果检测失败, 则连接将被从池中去除。注意: 设置为true 后如果要生效,validationQuery 参数必须设置为非空字符串
|
||||
testWhileIdle = false
|
||||
testWhileIdle = false
|
||||
|
@ -32,10 +32,16 @@ public class JdkInterceptor implements InvocationHandler, Serializable {
|
||||
this.aspect = aspect;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目标对象
|
||||
*
|
||||
* @return 目标对象
|
||||
*/
|
||||
public Object getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousInvocationHandlerImplementation")
|
||||
@Override
|
||||
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
|
||||
final Object target = this.target;
|
||||
|
@ -29,7 +29,7 @@ public class CpuTicks {
|
||||
public CpuTicks(final CentralProcessor processor, final long waitingTime) {
|
||||
// CPU信息
|
||||
final long[] prevTicks = processor.getSystemCpuLoadTicks();
|
||||
// 这里必须要设置延迟
|
||||
// 这里必须设置延迟
|
||||
Util.sleep(waitingTime);
|
||||
final long[] ticks = processor.getSystemCpuLoadTicks();
|
||||
|
||||
|
@ -4,12 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* CSV中一行的表示
|
||||
@ -146,7 +141,6 @@ public final class CsvRow implements List<String> {
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(final T[] a) {
|
||||
//noinspection SuspiciousToArrayCall
|
||||
return this.fields.toArray(a);
|
||||
}
|
||||
|
||||
@ -162,7 +156,7 @@ public final class CsvRow implements List<String> {
|
||||
|
||||
@Override
|
||||
public boolean containsAll(final Collection<?> c) {
|
||||
return this.fields.containsAll(c);
|
||||
return new HashSet<>(this.fields).containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -320,7 +320,7 @@ public final class CsvWriter implements Closeable, Flushable, Serializable {
|
||||
Assert.notNull(this.config.commentCharacter, "Comment is disable!");
|
||||
try {
|
||||
if(isFirstLine){
|
||||
// 首行不补换行符
|
||||
// 首行不补充换行符
|
||||
isFirstLine = false;
|
||||
}else {
|
||||
writer.write(config.lineDelimiter);
|
||||
|
@ -40,7 +40,7 @@ public class BackgroundRemoval {
|
||||
* 将 "纯色背景的图片" 还原成 "透明背景的图片"
|
||||
* 将纯色背景的图片转成矢量图
|
||||
* 取图片边缘的像素点和获取到的图片主题色作为要替换的背景色
|
||||
* 再加入一定的容差值,然后将所有像素点与该颜色进行比较
|
||||
* 再加入一定地容差值,然后将所有像素点与该颜色进行比较
|
||||
* 发现相同则将颜色不透明度设置为0,使颜色完全透明.
|
||||
*
|
||||
* @param inputPath 要处理图片的路径
|
||||
@ -58,7 +58,7 @@ public class BackgroundRemoval {
|
||||
* 将 "纯色背景的图片" 还原成 "透明背景的图片"
|
||||
* 将纯色背景的图片转成矢量图
|
||||
* 取图片边缘的像素点和获取到的图片主题色作为要替换的背景色
|
||||
* 再加入一定的容差值,然后将所有像素点与该颜色进行比较
|
||||
* 再加入一定地容差值,然后将所有像素点与该颜色进行比较
|
||||
* 发现相同则将颜色不透明度设置为0,使颜色完全透明.
|
||||
*
|
||||
* @param input 需要进行操作的图片
|
||||
@ -76,7 +76,7 @@ public class BackgroundRemoval {
|
||||
* 将 "纯色背景的图片" 还原成 "透明背景的图片"
|
||||
* 将纯色背景的图片转成矢量图
|
||||
* 取图片边缘的像素点和获取到的图片主题色作为要替换的背景色
|
||||
* 再加入一定的容差值,然后将所有像素点与该颜色进行比较
|
||||
* 再加入一定地容差值,然后将所有像素点与该颜色进行比较
|
||||
* 发现相同则将颜色不透明度设置为0,使颜色完全透明.
|
||||
*
|
||||
* @param input 需要进行操作的图片
|
||||
@ -106,7 +106,7 @@ public class BackgroundRemoval {
|
||||
* 将 "纯色背景的图片" 还原成 "透明背景的图片"
|
||||
* 将纯色背景的图片转成矢量图
|
||||
* 取图片边缘的像素点和获取到的图片主题色作为要替换的背景色
|
||||
* 再加入一定的容差值,然后将所有像素点与该颜色进行比较
|
||||
* 再加入一定地容差值,然后将所有像素点与该颜色进行比较
|
||||
* 发现相同则将颜色不透明度设置为0,使颜色完全透明.
|
||||
*
|
||||
* @param bufferedImage 需要进行处理的图片流
|
||||
@ -152,7 +152,7 @@ public class BackgroundRemoval {
|
||||
* 将 "纯色背景的图片" 还原成 "透明背景的图片"
|
||||
* 将纯色背景的图片转成矢量图
|
||||
* 取图片边缘的像素点和获取到的图片主题色作为要替换的背景色
|
||||
* 再加入一定的容差值,然后将所有像素点与该颜色进行比较
|
||||
* 再加入一定地容差值,然后将所有像素点与该颜色进行比较
|
||||
* 发现相同则将颜色不透明度设置为0,使颜色完全透明.
|
||||
*
|
||||
* @param outputStream 需要进行处理的图片字节数组流
|
||||
|
Loading…
x
Reference in New Issue
Block a user