Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2b97284
ci: use Maven 4 wrapper for feature/3.0.x
loong10k Oct 31, 2026
dc3dcde
fix: handle missing network interface and indexed bean arrays
loong10k Oct 31, 2026
7e85e97
fix: handle missing network interface and indexed bean arrays
loong10k Oct 31, 2026
5ae1a13
test: make assertions independent of host files and network
loong10k Oct 31, 2026
a137bfe
test: make assertions independent of host files and network
loong10k Oct 31, 2026
7afd400
test: make assertions independent of host files and network
loong10k Oct 31, 2026
bf657f3
test: use temporary files for compression round trips
loong10k Oct 31, 2026
92a8359
test: use temporary files for compression round trips
loong10k Oct 31, 2026
0b919ee
fix: preserve source filename in compression round trips
loong10k Oct 31, 2026
e2c3e84
fix: preserve source filename in compression round trips
loong10k Oct 31, 2026
42bd0a8
build: package file type signatures as runtime resource
loong10k Oct 31, 2026
0485ed6
build: remove unbundled file type signatures
loong10k Oct 31, 2026
fd816f0
test: add loopback SMTP server for mail client tests
loong10k Oct 31, 2026
987e32a
build: retain Spring Mail runtime dependencies
loong10k Oct 31, 2026
0d441b9
fix: avoid passing empty recipient lists to Commons Email
loong10k Oct 31, 2026
4d85e9c
test: verify mail delivery against local SMTP server
loong10k Oct 31, 2026
0cfb8f3
test: verify mail delivery against local SMTP server
loong10k Oct 31, 2026
c208cad
build: provide Jakarta Activation implementation for MIME mail
loong10k Oct 31, 2026
99817ae
test: stop mutating system mail settings and use local SMTP
loong10k Oct 31, 2026
68679cf
test: set Jakarta Mail SMTP transport port
loong10k Oct 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# - push / pull_request on the feature/3.0.x branch
# - manual workflow_dispatch
#
# Runs `mvn -B clean verify` which includes the JaCoCo coverage gate
# Runs `sh ./mvnw -B clean verify` which includes the JaCoCo coverage gate
# (90% line coverage, haltOnFailure=false) configured in the POM.
name: CI

Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
cache: maven

- name: Build and verify with JaCoCo coverage gate
run: mvn -B --no-transfer-progress clean verify
run: sh ./mvnw -B --no-transfer-progress clean verify

- name: Upload JaCoCo coverage report
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,36 +244,25 @@ public static void setProperty(Object bean, String name, Object value,
String name3 = matcher.group(1);
int index = Integer.parseInt(matcher.group(2));
System.out.println(matcher.group(0));
Object value3 = BeanUtils.getProperty(propertyVlaue, name3);
if (value3 != null) {
if (value3 instanceof Collection) {
ArrayList<Object> values = new ArrayList<Object>();
Iterator<Object> items = ((Collection<Object>) value).iterator();
while (items.hasNext()) {
Object item = items.next();
if (item == null) {
values.add(null);
} else {
values.add(item);
}
}
BeanUtils.setProperty(propertyVlaue, name3,values);
} else if (value.getClass().isArray()) {
int length = Array.getLength(value);
Object[] results = new Object[length];
for (int i = 0; i < length; i++) {
Object item = Array.get(value, i);
if (item == null) {
results[i] = null;
} else {
results[i] = item;
}
}
BeanUtils.setProperty(propertyVlaue, name3,results);
} else {
BeanUtils.setProperty(propertyVlaue, name3,value);
Object current = getPropertyUtils().getProperty(propertyVlaue, name3);
Class<?> fieldType = getPropertyUtils().getPropertyType(propertyVlaue, name3);
if (fieldType != null && fieldType.isArray()) {
int length = current == null ? 0 : Array.getLength(current);
Object array = Array.newInstance(fieldType.getComponentType(), Math.max(length, index + 1));
if (length > 0) {
System.arraycopy(current, 0, array, 0, length);
}
}
Array.set(array, index, value);
getPropertyUtils().setProperty(propertyVlaue, name3, array);
} else if (current instanceof List) {
List<Object> list = (List<Object>) current;
while (list.size() <= index) {
list.add(null);
}
list.set(index, value);
} else {
BeanUtils.setProperty(propertyVlaue, name2, value);
}
} else {
BeanUtils.setProperty(propertyVlaue,name2,value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void compress(File file) throws IOException {
* @throws Exception
*/
public static void compress(File srcFile, boolean delete) throws IOException {
File destFile = new File(srcFile.getParentFile(), FilenameUtils.getBaseName(srcFile.getName()) + EXT);
File destFile = new File(srcFile.getParentFile(), srcFile.getName() + EXT);
// 压缩
BZip2Utils.compress(srcFile, destFile);
if (delete) {
Expand Down Expand Up @@ -175,7 +175,7 @@ public static void decompress(File srcFile, boolean delete) throws IOException {
}

public static void decompress(File srcFile, File destDir) throws IOException {
File destFile = new File(destDir, FilenameUtils.getBaseName(srcFile.getName()) + EXT);
File destFile = new File(destDir, FilenameUtils.getBaseName(srcFile.getName()));
try(InputStream input = new FileInputStream(srcFile);
OutputStream output = new FileOutputStream(destFile);) {
BZip2Utils.decompress(input, output);
Expand Down
4 changes: 2 additions & 2 deletions hitool-core/src/main/java/hitool/core/compress/GZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static void compress(File file) throws IOException {
* @throws Exception
*/
public static void compress(File srcFile, boolean delete) throws IOException {
File destFile = new File(srcFile.getParentFile(), FilenameUtils.getBaseName(srcFile.getName()) + EXT);
File destFile = new File(srcFile.getParentFile(), srcFile.getName() + EXT);
// 压缩
GZipUtils.compress(srcFile, destFile);
if (delete) {
Expand Down Expand Up @@ -193,7 +193,7 @@ public static void decompress(File srcFile, boolean delete) throws IOException {
}

public static void decompress(File srcFile, File destDir) throws IOException {
File destFile = new File(destDir, FilenameUtils.getBaseName(srcFile.getName()) + EXT);
File destFile = new File(destDir, FilenameUtils.getBaseName(srcFile.getName()));
try (InputStream input = new FileInputStream(srcFile);
OutputStream output = new FileOutputStream(destFile);){
GZipUtils.decompress(input, output);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,11 @@ public static String getHostMacAddress(String host) {
// 获得网络接口对象(即网卡),并得到mac地址,mac地址存在于一个byte数组中。
byte[] mac = null;
try {
mac = NetworkInterface.getByInetAddress(InetAddress.getByName(host)).getHardwareAddress();
NetworkInterface networkInterface = NetworkInterface.getByInetAddress(InetAddress.getByName(host));
if (networkInterface == null) {
return null;
}
mac = networkInterface.getHardwareAddress();
} catch (SocketException e) {
e.printStackTrace();
} catch (UnknownHostException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void testUtils() {
BeanPropertyUtils.populate(entity, source, true);
// System.out.println(entity.getMethodName());
System.out.println("===========================RESULT================================");
System.out.println(entity.getProxyBean().getArray()[0]);
System.out.println("proxyBean.proxyBean.methodName:"+entity.getProxyBean().getProxyBean().getMethodName());
org.junit.Assert.assertEquals("测试名称1", entity.getProxyBean().getArray()[1]);
org.junit.Assert.assertEquals("测试名称1", entity.getProxyBean().getProxyBean().getMethodName());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,20 @@ public final void testDataCompress() throws Exception {
@Test
public final void testFileCompress() throws Exception {

FileOutputStream fos = new FileOutputStream("d:/f.txt");
File inputFile = File.createTempFile("hitool-compress-", ".txt");
inputFile.deleteOnExit();
new File(inputFile.getAbsolutePath() + ".bz2").deleteOnExit();
FileOutputStream fos = new FileOutputStream(inputFile);

fos.write(inputStr.getBytes());
fos.flush();
fos.close();

BZip2Utils.compress("d:/f.txt");
BZip2Utils.compress(inputFile.getAbsolutePath());

BZip2Utils.decompress("d:/f.txt.bz2");
BZip2Utils.decompress(inputFile.getAbsolutePath() + ".bz2");

File file = new File("d:/f.txt");
File file = new File(inputFile.getAbsolutePath());

FileInputStream fis = new FileInputStream(file);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@ public final void testDataCompress() throws Exception {
@Test
public final void testFileCompress() throws Exception {

FileOutputStream fos = new FileOutputStream("d:/f.txt");
File inputFile = File.createTempFile("hitool-compress-", ".txt");
inputFile.deleteOnExit();
new File(inputFile.getAbsolutePath() + ".gz").deleteOnExit();
FileOutputStream fos = new FileOutputStream(inputFile);

fos.write(inputStr.getBytes());
fos.flush();
fos.close();

GZipUtils.compress("d:/f.txt", false);
GZipUtils.compress(inputFile.getAbsolutePath(), false);

GZipUtils.decompress("d:/f.txt.gz", false);
GZipUtils.decompress(inputFile.getAbsolutePath() + ".gz", false);

File file = new File("d:/f.txt");
File file = new File(inputFile.getAbsolutePath());

FileInputStream fis = new FileInputStream(file);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class FiletypeUtils_Test extends TestCase {
public void testname() throws Exception {


assertSame(FiletypeUtils.getFileType(new File("D://cos.jar")), "jar");
byte[] jarHeader = new byte[] {0x50, 0x4B, 0x03, 0x04, 0x0A, 0, 0, 0, 0, 0, 0};
assertEquals("jar", FiletypeUtils.getFileType(jarHeader));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testRemoteMacAddr_4() {
}

public void testRemoteMacAddr_3() {
System.out.println("HostMacAddress is : " + MacAddressUtils.getHostMacAddress("192.168.31.1"));
assertNull(MacAddressUtils.getHostMacAddress("127.0.0.1"));
}

}
16 changes: 6 additions & 10 deletions hitool-mail/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.angus</groupId>
<artifactId>angus-activation</artifactId>
<version>2.0.2</version>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.mail/jakarta.mail -->
<dependency>
<groupId>com.sun.mail</groupId>
Expand Down Expand Up @@ -81,16 +87,6 @@
<artifactId>spring-context-support</artifactId>
<optional>true</optional>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>spring-beans</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected void sendMail(EmailBody email,boolean isHtml) throws Exception{
}

// 设置收件人的名片和地址
if(email.getMailto() != null){
if(email.getMailto() != null && !email.getMailto().isEmpty()){
List<String> mailtoList = new ArrayList<String>();
for (String mailto : email.getMailto().keySet()) {
// 添加一个收件人
Expand All @@ -138,7 +138,7 @@ protected void sendMail(EmailBody email,boolean isHtml) throws Exception{
}

// 设置抄送的名片和地址
if(email.getMailcc() != null){
if(email.getMailcc() != null && !email.getMailcc().isEmpty()){
List<String> mailccList = new ArrayList<String>();
for (String mailcc : email.getMailcc().keySet()) {
// 添加一个抄送
Expand All @@ -149,7 +149,7 @@ protected void sendMail(EmailBody email,boolean isHtml) throws Exception{
}

// 设置密送的名片和地址
if(email.getMailBcc() != null){
if(email.getMailBcc() != null && !email.getMailBcc().isEmpty()){
List<String> mailBccList = new ArrayList<String>();
for (String mailcc : email.getMailBcc().keySet()) {
// 添加一个密送
Expand Down
Loading
Loading