Skip to content

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

Description

@kyonRay

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.

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.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions