Skip to content

Commit fb236d4

Browse files
authored
change Nan value to No value into logs (#261)
Signed-off-by: Maissa SOUISSI <[email protected]>
1 parent 0038a34 commit fb236d4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/java/org/gridsuite/modification/server/modifications/ModificationUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public final class ModificationUtils {
3939

4040
public static final String DISCONNECTOR = "disconnector_";
4141
public static final String BREAKER = "breaker_";
42+
public static final String NO_VALUE = "No value";
4243

4344
private ModificationUtils() {
4445
}
@@ -418,8 +419,10 @@ public <T> Report buildModificationReport(T oldValue, T newValue, String fieldNa
418419
}
419420

420421
public <T> Report buildModificationReportWithIndentation(T oldValue, T newValue, String fieldName, int indentationLevel) {
421-
String oldValueString = oldValue == null ? "NaN" : oldValue.toString();
422-
String newValueString = newValue == null ? "NaN" : newValue.toString();
422+
boolean isOldValueDoubleNaN = (oldValue instanceof Double) && Double.isNaN((Double) oldValue);
423+
String oldValueString = (oldValue == null || isOldValueDoubleNaN) ? NO_VALUE : oldValue.toString();
424+
boolean isNewValueDoubleNaN = (newValue instanceof Double) && Double.isNaN((Double) newValue);
425+
String newValueString = (newValue == null || isNewValueDoubleNaN) ? NO_VALUE : newValue.toString();
423426
StringBuilder indentation = new StringBuilder();
424427
for (int i = 0; i < indentationLevel; i++) {
425428
indentation.append(" ");
@@ -518,7 +521,7 @@ public void setCurrentLimits(CurrentLimitsInfos currentLimitsInfos, CurrentLimit
518521
}
519522

520523
public <T> Report buildCreationReport(T value, String fieldName) {
521-
String newValueString = value == null ? "NaN" : value.toString();
524+
String newValueString = value == null ? NO_VALUE : value.toString();
522525
return Report.builder()
523526
.withKey("Creation" + fieldName)
524527
.withDefaultMessage(" ${fieldName} : ${value}")

0 commit comments

Comments
 (0)