This is a day-0 bug pointed out by SpotBugs: the increment here is
ineffective, as the Integer is unboxed, incremented and the result
is thrown away -- leading to a dead store and incorrect operation.
Fix this by separating the variables, making it clear what is going
on.
Change-Id: I1393fcdf0e95394fd5a18cf8d843ce2f9e07f898
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
}
private void updateAugmentOrder(final StatementContextBase<?, ?, ?> augmentSourceCtx) {
- Integer currentOrder = augmentSourceCtx.getFromNamespace(StmtOrderingNamespace.class,
+ final Integer prev = augmentSourceCtx.getFromNamespace(StmtOrderingNamespace.class,
YangStmtMapping.AUGMENT);
- if (currentOrder == null) {
- currentOrder = 1;
- } else {
- currentOrder++;
- }
-
+ final int currentOrder = prev == null ? 1 : prev + 1;
augmentSourceCtx.addToNs(StmtOrderingNamespace.class, YangStmtMapping.AUGMENT, currentOrder);
}