From 21e44f9673e03245340291298869b27bf671497f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jonas=20M=C3=A5rtensson?= Date: Wed, 2 Nov 2022 10:05:07 +0000 Subject: [PATCH] Handle missing spanloss in PCE without crashing MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If spanloss is missing from OMS attributes in any span in the topology, the PCE code crashes due to NullPointerException. - Check for null before accessing spanloss when calculating OSNR - Set the link to not valid when analyzing the network for path computation. JIRA: TRNSPRTPCE-710 Signed-off-by: Jonas MÃ¥rtensson Change-Id: I746cdefc0dd79e914ea235e5ad7801b2c73fc121 --- .../transportpce/pce/networkanalyzer/PceLink.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java index 9e28aa9bd..2d05a3e09 100644 --- a/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java +++ b/pce/src/main/java/org/opendaylight/transportpce/pce/networkanalyzer/PceLink.java @@ -173,6 +173,10 @@ public class PceLink implements Serializable { if (!linkConcatenationiterator.hasNext()) { return 0L; } + if (this.omsAttributesSpan.getSpanlossCurrent() == null) { + LOG.error("in PceLink : Spanloss is null"); + return 0L; + } // power on the output of the previous ROADM (dBm) double pout = retrievePower(linkConcatenationiterator.next().augmentation(LinkConcatenation1.class) .getFiberType()); @@ -300,9 +304,14 @@ public class PceLink implements Serializable { LOG.error("PceLink: No Link type or opposite link is available. Link is ignored {}", linkId); } isValid = checkParams(); - if ((this.omsAttributesSpan == null) && (this.linkType == OpenroadmLinkType.ROADMTOROADM)) { - isValid = false; - LOG.error("PceLink: Error reading Span for OMS link. Link is ignored {}", linkId); + if (this.linkType == OpenroadmLinkType.ROADMTOROADM) { + if (this.omsAttributesSpan == null) { + isValid = false; + LOG.error("PceLink: Error reading Span for OMS link. Link is ignored {}", linkId); + } else if (this.omsAttributesSpan.getSpanlossCurrent() == null) { + isValid = false; + LOG.error("PceLink: Error reading Spanloss for OMS link. Link is ignored {}", linkId); + } } if ((this.srlgList != null) && (this.srlgList.isEmpty())) { isValid = false; -- 2.36.6