Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# 更新记录

## 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

1. 通过 `-Dlog4j.configurationFile=log4j2.xml` 重定向日志输出,可能导致stdout被关闭的问题。
Expand Down
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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'
]
}

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

<groupId>org.xresloader</groupId>
<artifactId>xresloader</artifactId>
<version>2.23.3</version>
<version>2.23.4</version>
<packaging>jar</packaging>
<name>xresloader</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.target.javaVersion>17</project.target.javaVersion>
<nashorn.version>15.7</nashorn.version>
<protobuf.version>4.33.1</protobuf.version>
<poi.version>5.5.0</poi.version>
<protobuf.version>4.33.5</protobuf.version>
<poi.version>5.5.1</poi.version>
<log4j.version>2.25.3</log4j.version>
<commons-cli.version>1.11.0</commons-cli.version>
<commons-codec.version>1.20.0</commons-codec.version>
Expand All @@ -30,7 +30,7 @@
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
<maven-shade-plugin.version>3.6.1</maven-shade-plugin.version>
<build-helper-maven-plugin.version>3.6.1</build-helper-maven-plugin.version>
<junit-jupiter.version>6.0.1</junit-jupiter.version>
<junit-jupiter.version>6.0.2</junit-jupiter.version>

<graalvm.version>22.3.3</graalvm.version>
<rhino.version>1.8.0</rhino.version>
Expand Down
Binary file modified sample/proto_v2/role_cfg.bin
Binary file not shown.
Binary file modified sample/proto_v3/role_cfg.bin
Binary file not shown.
25 changes: 25 additions & 0 deletions src/org/xresloader/core/data/dst/DataDstImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
16 changes: 10 additions & 6 deletions src/org/xresloader/core/data/dst/DataDstJava.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Integer, DataDstFieldDescriptor> missingFields = new HashMap<>();
for (int i = 0; i < children.size(); ++i) {
DataDstFieldDescriptor child = children.get(i);
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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);
}

Expand Down
16 changes: 9 additions & 7 deletions src/org/xresloader/core/data/dst/DataDstPb.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Integer, DataDstFieldDescriptor> missingFields = new HashMap<>();
for (int i = 0; i < children.size(); ++i) {
DataDstFieldDescriptor child = children.get(i);
Expand All @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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(),
Copy link

Copilot AI Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format string has only 2 %s placeholders after the numeric placeholders, but 3 string arguments are provided (two calls to ProgramOptions.getEndl() on lines 2916, plus the result of joinPlainInputHint on line 2917). This will cause an IllegalFormatException at runtime.

The correct fix would be to remove one of the ProgramOptions.getEndl() calls, keeping only one between the field count and the data hint, as is done in the similar code in DataDstJava.java at line 1280.

Suggested change
ProgramOptions.getEndl(), ProgramOptions.getEndl(),
ProgramOptions.getEndl(),

Copilot uses AI. Check for mistakes.
joinPlainInputHint(field.getTypeDescriptor().mutableExtension().plainSeparator, inputs));
throw new ConvException(message);
}

Expand Down
Loading