FISCO-BCOS / FISCO-BCOS/java-sdk

ProposalInfo() no-arg constructor throws NumberFormatException (new Address(""))

Open
#948 0 comments 1 reaction 2 assignees Claimed by @kyonRay View on GitHub
bug
Dominant language
Java
Stars
58
Forks
62
PR merge metrics
No merged PRs in 30d

Description

### Description
`org.fisco.bcos.sdk.v3.contract.auth.po.ProposalInfo`'s no-arg constructor cannot be used — it always throws `NumberFormatException`.

### Cause
The no-arg constructor calls `super(new Address(""), ...)`. `Address(String)` → `Numeric.toBigInt("")` → `new BigInteger("", 16)`, which throws `NumberFormatException: Zero length BigInteger`.

```java
public ProposalInfo() {
super(
new Address(""), // Address("") -> Numeric.toBigInt("") -> NumberFormatException
new Uint8(0),
new Uint256(0),
new Uint8(0),
new DynamicArray<>(Address.class),
new DynamicArray<>(Address.class));
}
```

### Impact
Any code that default-constructs `ProposalInfo` (e.g. as a decode template) throws at construction time.

### Suggested fix
Use a valid zero address in the no-arg constructor, e.g. `new Address(BigInteger.ZERO)` (or `Address.DEFAULT`) instead of `new Address("")`. Other `DynamicStruct` PO subclasses with the same pattern should be checked too.

### Found via
A unit test constructing `new ProposalInfo()`, during the test-coverage work in #947.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.