Adding field and consequently removing another field from state class doesn't work

Description

In our documentation we say fields can be added to a state class (via @DeprecatedConstructorForDeserialization). We also say that nullable fields can be removed from the state class.

Doing both of these on one state class doesn't work. The EvolutionObjectBuilder gets very confused and throws array index out of bound error. The stack trace seems to get swallowed.

This is the doc I’m refering to: https://docs.corda.r3.com/releases/master/serialization-default-evolution.html

Here’s what I did:

  1. Start with this state class

  1. Put a state on the ledger

  2. Then update the state class to this (add field)

  1. Run vault query, it will come back as expected

  2. Then update the state class to this (remove field)

  1. Run vault query, you will get an error

RPC failed: net.corda.core.CordaRuntimeException: java.lang.ArrayIndexOutOfBoundsException: net.corda.core.contracts.TransactionState (erased) -> data(net.corda.core.contracts.ContractState) -> com.template.states.TemplateState -> 2

Assignee

ryan.fowler

Reporter

Alex Koller

Sprint

None

Epic Link

None

Priority

Highest

Engineering Teams

Kernel

Fix versions

Affects versions

Ported to...

Corda 4.4
Corda Enterprise 4.4

Story Points / Dev Days

None

Build cut

None

Feature Team

Kernel Group
Configure