-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
webadmin: avoid NPE on null rx, tx drops
Bug-Url: http://bugzilla.redhat.com/2180230 Change-Id: Iee6fa946f52481091a431a6ef0f173d74f9e37f2 Signed-off-by: Eitan Raviv <eraviv@redhat.com>
- Loading branch information
1 parent
f78c60f
commit 31c8256
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/renderer/RxTxDropRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.ovirt.engine.ui.common.widget.renderer; | ||
|
||
import java.math.BigInteger; | ||
|
||
import com.google.gwt.text.shared.AbstractRenderer; | ||
|
||
/** | ||
* Renderer for Rx/Tx drop rates. | ||
*/ | ||
public class RxTxDropRenderer extends AbstractRenderer<BigInteger[]> { | ||
|
||
private static final String ZERO_VALUE = "0"; //$NON-NLS-1$ | ||
|
||
@Override | ||
public String render(BigInteger[] values) { | ||
if (values.length != 2 || values[0] == null && values[1] == null) { | ||
return ZERO_VALUE; | ||
} else if (values[0] == null) { | ||
return String.valueOf(values[1]); | ||
} else if (values[1] == null) { | ||
return String.valueOf(values[0]); | ||
} else { | ||
return String.valueOf(values[0].add(values[1])); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters