From ca597e5390e6472f7e6e4b96e47b5a5342bedc0d Mon Sep 17 00:00:00 2001 From: owent Date: Thu, 22 Jan 2026 12:16:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HISTORY.md | 5 ++++ .../xresloader/core/data/dst/DataDstImpl.java | 25 +++++++++++++++++++ .../xresloader/core/data/dst/DataDstJava.java | 16 +++++++----- .../xresloader/core/data/dst/DataDstPb.java | 16 ++++++------ 4 files changed, 49 insertions(+), 13 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 726d5107..96df4ab1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,10 @@ # 更新记录 +## Unreleased + +1. 修复plain模式下,有oneof时。字段数量检查失败的输出信息错误的问题。 +2. 优化plain模式失败的提示输出。 + ## 2.23.3 1. 通过 `-Dlog4j.configurationFile=log4j2.xml` 重定向日志输出,可能导致stdout被关闭的问题。 diff --git a/src/org/xresloader/core/data/dst/DataDstImpl.java b/src/org/xresloader/core/data/dst/DataDstImpl.java index 6e09059f..d6117908 100644 --- a/src/org/xresloader/core/data/dst/DataDstImpl.java +++ b/src/org/xresloader/core/data/dst/DataDstImpl.java @@ -821,4 +821,29 @@ static public String getPlainOneofSeparator(DataDstWriterNode.DataDstOneofDescri return oneof.mutableExtension().plainSeparator; } + + static public String joinPlainInputHint(String sep, String[] inputs) { + if (inputs == null || inputs.length <= 0) { + return ""; + } + + if (sep == null || sep.isEmpty()) { + sep = ProgramOptions.getInstance().defaultFieldSeparator; + } + for (char c : sep.toCharArray()) { + boolean valid = true; + for (int i = 0; i < inputs.length; ++i) { + if (inputs[i].indexOf(c) != -1) { + valid = false; + break; + } + } + if (valid) { + sep = String.valueOf(c); + break; + } + } + + return String.join(sep, inputs); + } } diff --git a/src/org/xresloader/core/data/dst/DataDstJava.java b/src/org/xresloader/core/data/dst/DataDstJava.java index 7d50815e..fffc10b1 100644 --- a/src/org/xresloader/core/data/dst/DataDstJava.java +++ b/src/org/xresloader/core/data/dst/DataDstJava.java @@ -1171,7 +1171,7 @@ private ParseResult parsePlainDataMessage(String[] inputs, IdentifyDescriptor id int usedInputIdx = 0; int fieldSize = 0; - int atLeastFieldSize = 0; + int atLeastFieldSize = field.getTypeDescriptor().getSortedOneofs().size(); HashMap missingFields = new HashMap<>(); for (int i = 0; i < children.size(); ++i) { DataDstFieldDescriptor child = children.get(i); @@ -1183,10 +1183,11 @@ private ParseResult parsePlainDataMessage(String[] inputs, IdentifyDescriptor id if (child.getReferOneof().allowMissingInPlainMode()) { continue; } + + atLeastFieldSize += 1; } missingFields.put(child.getIndex(), child); - atLeastFieldSize += 1; } for (int i = 0; i < children.size(); ++i) { @@ -1259,7 +1260,7 @@ && dumpPlainField(ret.value, field.getTypeDescriptor(), null, children.get(i), n if (!missingFields.isEmpty()) { String message = String.format( - "Try to convert %s need at least %d fields, at most %d fields, but only provide %d fields.%s > File: %s, Table: %s, Row: %d, Column: %d(%s)%s > Missing fields: %s", + "Try to convert %s need at least %d fields, at most %d fields, but only provide %d fields.%s > File: %s, Table: %s, Row: %d, Column: %d(%s)%s > Missing fields: %s%s > Data: %s", field.getTypeDescriptor().getFullName(), atLeastFieldSize, fieldSize, inputs.length, ProgramOptions.getEndl(), rowContext.fileName, rowContext.tableName, @@ -1268,13 +1269,16 @@ && dumpPlainField(ret.value, field.getTypeDescriptor(), null, children.get(i), n ExcelEngine.getColumnName(DataSrcImpl.getOurInstance().getLastColumnNum() + 1), ProgramOptions.getEndl(), String.join(",", missingFields.values().stream().map(DataDstFieldDescriptor::getName) - .collect(Collectors.toList()))); + .collect(Collectors.toList())), + ProgramOptions.getEndl(), + joinPlainInputHint(field.getTypeDescriptor().mutableExtension().plainSeparator, inputs)); ProgramOptions.getLoger().warn(message); } else if (inputs.length > fieldSize) { String message = String.format( - "Try to convert %s need at least %d fields, at most %d fields, but provide %d fields.", + "Try to convert %s need at least %d fields, at most %d fields, but provide %d fields.%s > Data: %s", field.getTypeDescriptor().getFullName(), atLeastFieldSize, fieldSize, inputs.length, - ProgramOptions.getEndl()); + ProgramOptions.getEndl(), + joinPlainInputHint(field.getTypeDescriptor().mutableExtension().plainSeparator, inputs)); throw new ConvException(message); } diff --git a/src/org/xresloader/core/data/dst/DataDstPb.java b/src/org/xresloader/core/data/dst/DataDstPb.java index fa959cde..36a90dce 100644 --- a/src/org/xresloader/core/data/dst/DataDstPb.java +++ b/src/org/xresloader/core/data/dst/DataDstPb.java @@ -37,7 +37,6 @@ import org.xresloader.core.data.vfy.DataVerifyImpl.ValidatorTokens; import org.xresloader.core.data.vfy.DataVerifyPbEnum; import org.xresloader.core.data.vfy.DataVerifyPbEnumValue; -import org.xresloader.core.data.vfy.DataVerifyPbMsgOneField; import org.xresloader.core.data.vfy.DataVerifyPbMsgField; import org.xresloader.core.data.vfy.DataVerifyPbMsgOneField; import org.xresloader.core.data.vfy.DataVerifyPbOneof; @@ -2808,7 +2807,7 @@ private ParseResult parsePlainDataMessage(String[] inputs, IdentifyDescriptor id int usedInputIdx = 0; int fieldSize = 0; - int atLeastFieldSize = 0; + int atLeastFieldSize = field.getTypeDescriptor().getSortedOneofs().size(); HashMap missingFields = new HashMap<>(); for (int i = 0; i < children.size(); ++i) { DataDstFieldDescriptor child = children.get(i); @@ -2820,10 +2819,10 @@ private ParseResult parsePlainDataMessage(String[] inputs, IdentifyDescriptor id if (child.getReferOneof().allowMissingInPlainMode()) { continue; } + atLeastFieldSize += 1; } missingFields.put(child.getIndex(), child); - atLeastFieldSize += 1; } for (int i = 0; i < children.size(); ++i) { @@ -2897,7 +2896,7 @@ && dumpPlainField(builder, null, child, null, inputs[usedInputIdx], rowContext, if (!missingFields.isEmpty()) { String message = String.format( - "Try to convert %s need at least %d fields, at most %d fields, but only provide %d fields.%s > File: %s, Table: %s, Row: %d, Column: %d(%s)%s > Missing fields: %s", + "Try to convert %s need at least %d fields, at most %d fields, but only provide %d fields.%s > File: %s, Table: %s, Row: %d, Column: %d(%s)%s > Missing fields: %s%s > Data: %s", field.getTypeDescriptor().getFullName(), atLeastFieldSize, fieldSize, inputs.length, ProgramOptions.getEndl(), rowContext.fileName, rowContext.tableName, @@ -2906,13 +2905,16 @@ && dumpPlainField(builder, null, child, null, inputs[usedInputIdx], rowContext, ExcelEngine.getColumnName(DataSrcImpl.getOurInstance().getLastColumnNum() + 1), ProgramOptions.getEndl(), String.join(",", missingFields.values().stream().map(DataDstFieldDescriptor::getName) - .collect(Collectors.toList()))); + .collect(Collectors.toList())), + ProgramOptions.getEndl(), + joinPlainInputHint(field.getTypeDescriptor().mutableExtension().plainSeparator, inputs)); ProgramOptions.getLoger().warn(message); } else if (inputs.length > fieldSize) { String message = String.format( - "Try to convert %s need at least %d fields, at most %d fields, but provide %d fields.", + "Try to convert %s need at least %d fields, at most %d fields, but provide %d fields.%s > Data: %s", field.getTypeDescriptor().getFullName(), atLeastFieldSize, fieldSize, inputs.length, - ProgramOptions.getEndl()); + ProgramOptions.getEndl(), ProgramOptions.getEndl(), + joinPlainInputHint(field.getTypeDescriptor().mutableExtension().plainSeparator, inputs)); throw new ConvException(message); } From dcbd95854169983037ff1f1a210797555e88b798 Mon Sep 17 00:00:00 2001 From: owent Date: Fri, 30 Jan 2026 15:21:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=87=B3=202.23.4=20?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8DPlain=E6=A8=A1=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复Plain模式下处理oneof字段数量检查的错误信息,并优化失败提示。 同时升级了多个核心依赖库,包括Protobuf、POI、Msgpack、Log4j和JUnit。 --- HISTORY.md | 10 +++++++++- build.gradle | 16 ++++++++-------- pom.xml | 8 ++++---- sample/proto_v2/role_cfg.bin | Bin 1397 -> 1397 bytes sample/proto_v3/role_cfg.bin | Bin 1397 -> 1397 bytes 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 96df4ab1..5be8f379 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,9 +1,17 @@ # 更新记录 -## Unreleased +## 2.23.4 1. 修复plain模式下,有oneof时。字段数量检查失败的输出信息错误的问题。 2. 优化plain模式失败的提示输出。 +3. 更新依赖库 + + `com.google.protobuf:protobuf-java` -> 4.33.5 + + `org.apache.poi:poi` -> 5.5.1 + + `org.apache.poi:poi-ooxml` -> 5.5.1 + + `org.msgpack:msgpack-core` -> 0.9.11 + + `org.junit.jupiter:junit-jupiter` -> 6.0.2 + + `org.junit.platform:junit-platform-launcher` -> 6.0.2 + + `com.gradleup.shadow` (gradle plugin) -> 9.3.1 ## 2.23.3 diff --git a/build.gradle b/build.gradle index 90dc77ef..9d3906e4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ plugins { id 'java' id 'jacoco' - id 'com.gradleup.shadow' version '9.2.2' + id 'com.gradleup.shadow' version '9.3.1' } group = 'org.xresloader' -version = '2.23.3' +version = '2.23.4' description = 'xresloader' buildDir = 'target' @@ -14,19 +14,19 @@ ext { targetJavaVersion = JavaVersion.toVersion(targetJava) versions = [ nashorn : '15.7', - protobuf : '4.33.1', - poi : '5.5.0', - log4j : '2.25.2', + protobuf : '4.33.5', + poi : '5.5.1', + log4j : '2.25.3', commonsCli : '1.11.0', commonsCodec : '1.20.0', ini4j : '0.5.4', - msgpack : '0.9.10', + msgpack : '0.9.11', json : '20250517', dom4j : '2.2.0', commonsCsv : '1.14.1', snakeyamlEngine: '3.0.1', - junitJupiter : '6.0.1', - junitPlatform : '6.0.1' + junitJupiter : '6.0.2', + junitPlatform : '6.0.2' ] } diff --git a/pom.xml b/pom.xml index 62b8be5e..acf31674 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.xresloader xresloader - 2.23.3 + 2.23.4 jar xresloader @@ -14,8 +14,8 @@ UTF-8 17 15.7 - 4.33.1 - 5.5.0 + 4.33.5 + 5.5.1 2.25.3 1.11.0 1.20.0 @@ -30,7 +30,7 @@ 3.5.4 3.6.1 3.6.1 - 6.0.1 + 6.0.2 22.3.3 1.8.0 diff --git a/sample/proto_v2/role_cfg.bin b/sample/proto_v2/role_cfg.bin index e55dc8320439dc517a921b3b42263bd90bf0999e..1649730df19269e7e48fad15ea7b4ac132785690 100755 GIT binary patch delta 19 acmey$^_7c@tDcL^NYBVv&txN4HY)%)h6MBg delta 19 acmey$^_7c@tDcL^NYBVv&tM~0HY)%)as==I diff --git a/sample/proto_v3/role_cfg.bin b/sample/proto_v3/role_cfg.bin index 8fe8c340f904496517d0ea2a6259640f872a4d42..c2fa4ad5fd9a04d586dbb9be96ac35dca5a885f1 100755 GIT binary patch delta 19 acmey$^_7c@tDcL^NYBVv&txN4HY)%)h6MBg delta 19 acmey$^_7c@tDcL^NYBVv&tM~0HY)%)as==I