From 6d7ec8b9fdf2c724adb43ef7f6e199c7cbd6f2ab Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 12 Feb 2020 17:22:41 +0100 Subject: [PATCH] Fix incorrect statement ordering in augment 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 --- .../stmt/augment/AbstractAugmentStatementSupport.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java index 87b690388d..4bb11bb9c3 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java @@ -129,14 +129,9 @@ abstract class AbstractAugmentStatementSupport } 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); } -- 2.36.6