Skip to content

Commit

Permalink
core: make SecretValue Serializable + snapshot overview NPE fixes (Fixes
Browse files Browse the repository at this point in the history
: oVirt#900)

Since the SecretValue structure is used in GWT, it should implement Serializable interface.

Also add a couple of null checks to avoid NPE in the scenario explained in oVirt#900.

Signed-off-by: Stepan Ermakov <[email protected]>
  • Loading branch information
sermakov-orion authored Jan 9, 2025
1 parent 9cd7eb8 commit 36a3073
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.ovirt.engine.core.common.utils;

import java.io.Serializable;
import java.util.Objects;

public class SecretValue<T> {
public class SecretValue<T> implements Serializable {
private static final long serialVersionUID = -7894728002078425194L;

private T value;

public T getValue() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package org.ovirt.engine.ui.common.widget.uicommon.vm;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;

import org.gwtbootstrap3.client.ui.Label;
import org.ovirt.engine.core.common.businessentities.network.NetworkInterface;
import org.ovirt.engine.core.common.businessentities.network.NetworkStatistics;
import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType;
import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
import org.ovirt.engine.core.common.businessentities.storage.Disk;
Expand Down Expand Up @@ -266,8 +270,10 @@ protected Double getSpeed(VmNetworkInterface object) {
AbstractTextColumn<VmNetworkInterface> dropsColumn = new AbstractSumUpColumn<VmNetworkInterface>() {
@Override
protected Double[] getRawValue(VmNetworkInterface object) {
Double receiveDrops = object != null ? object.getStatistics().getReceiveDrops().doubleValue() : null;
Double transmitDrops = object != null ? object.getStatistics().getTransmitDrops().doubleValue() : null;
Double receiveDrops = Optional.ofNullable(object).map(NetworkInterface::getStatistics)
.map(NetworkStatistics::getReceiveDrops).map(BigInteger::doubleValue).orElse(null);
Double transmitDrops = Optional.ofNullable(object).map(NetworkInterface::getStatistics)
.map(NetworkStatistics::getTransmitDrops).map(BigInteger::doubleValue).orElse(null);
return new Double[] { receiveDrops, transmitDrops };
}
};
Expand Down

0 comments on commit 36a3073

Please sign in to comment.