Merge pull request #1896 from vanelsberg/fixErosPodstate

Fixing issue with EROS Pod state causing pod not being discarded properly
This commit is contained in:
Milos Kozak 2022-07-08 09:22:25 +02:00 committed by GitHub
commit 33f3c4df59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,24 +49,38 @@ public abstract class ErosPodStateManager {
this.gsonInstance = createGson();
}
/**
* Discard Pod state
*/
public final void discardState() {
this.podState = new PodState(this.podState.address);
// Change on commit 4cea57acf6d74baffef83e1f04376b10bb5c1978 Nov 2021
// As by commit, keep podState object but wipe address to 0x0 to signal hasPodState()
// there is no state ( = no Pod address).
this.podState = new PodState(0x0);
storePodState();
}
/**
* Init Pod state but only if it has valid state.
* @param address New Pod address
*/
public final void initState(int address) {
if (hasPodState()) {
throw new IllegalStateException("Can not init a new pod state: podState <> null");
throw new IllegalStateException("Can not init a new pod state: State is " +
"null or discarded?");
}
podState = new PodState(address);
storePodState();
}
/**
* @return true if we have a Pod state (which at least contains an address), indicating it is legal to call getters on PodStateManager
* @return true if we have a Pod state (which at least contains an valid address), indicating
* it is legal to call getters on PodStateManager
*/
public final boolean hasPodState() {
return podState != null;
return this.podState != null
&& this.podState.getAddress() != 0x0; // 0x0=discarded
}
/**