Committed by
Gerrit Code Review
[ONOS-4986] [ONOS-4985] Json defect fix
Change-Id: I50876404fa75ca0dd9d30ab255ae800430147fae
Showing
3 changed files
with
9 additions
and
3 deletions
... | @@ -47,7 +47,7 @@ public class PceUpdatePathCommand extends AbstractShellCommand { | ... | @@ -47,7 +47,7 @@ public class PceUpdatePathCommand extends AbstractShellCommand { |
47 | 47 | ||
48 | @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).", | 48 | @Option(name = "-c", aliases = "--cost", description = "The cost attribute IGP cost (1) or TE cost (2).", |
49 | required = false, multiValued = false) | 49 | required = false, multiValued = false) |
50 | - int cost = -1; | 50 | + Integer cost = null; |
51 | 51 | ||
52 | @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. " | 52 | @Option(name = "-b", aliases = "--bandwidth", description = "The bandwidth attribute of path. " |
53 | + "Data rate unit is in Bps.", required = false, multiValued = false) | 53 | + "Data rate unit is in Bps.", required = false, multiValued = false) |
... | @@ -66,7 +66,7 @@ public class PceUpdatePathCommand extends AbstractShellCommand { | ... | @@ -66,7 +66,7 @@ public class PceUpdatePathCommand extends AbstractShellCommand { |
66 | } | 66 | } |
67 | 67 | ||
68 | // Cost validation | 68 | // Cost validation |
69 | - if (cost != -1) { | 69 | + if (cost != null) { |
70 | if ((cost < 1) || (cost > 2)) { | 70 | if ((cost < 1) || (cost > 2)) { |
71 | error("The cost attribute value is either IGP cost(1) or TE cost(2)."); | 71 | error("The cost attribute value is either IGP cost(1) or TE cost(2)."); |
72 | return; | 72 | return; | ... | ... |
... | @@ -508,7 +508,7 @@ public class PceManager implements PceService { | ... | @@ -508,7 +508,7 @@ public class PceManager implements PceService { |
508 | } | 508 | } |
509 | 509 | ||
510 | if (existingBwValue != null) { | 510 | if (existingBwValue != null) { |
511 | - if (bwConstraintValue == 0 && bwConstraint != null) { | 511 | + if (bwConstraint == null) { |
512 | bwConstraintValue = existingBwValue.bps(); | 512 | bwConstraintValue = existingBwValue.bps(); |
513 | } | 513 | } |
514 | //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation | 514 | //If bandwidth constraints not specified , take existing bandwidth for shared bandwidth calculation | ... | ... |
... | @@ -101,6 +101,9 @@ public class PcePathWebResource extends AbstractWebResource { | ... | @@ -101,6 +101,9 @@ public class PcePathWebResource extends AbstractWebResource { |
101 | Tunnel tunnel = nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)), | 101 | Tunnel tunnel = nullIsNotFound(get(PceService.class).queryPath(TunnelId.valueOf(id)), |
102 | PCE_PATH_NOT_FOUND); | 102 | PCE_PATH_NOT_FOUND); |
103 | PcePath path = DefaultPcePath.builder().of(tunnel).build(); | 103 | PcePath path = DefaultPcePath.builder().of(tunnel).build(); |
104 | + if (path == null) { | ||
105 | + return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build(); | ||
106 | + } | ||
104 | ObjectNode result = mapper().createObjectNode(); | 107 | ObjectNode result = mapper().createObjectNode(); |
105 | result.set("path", codec(PcePath.class).encode(path, this)); | 108 | result.set("path", codec(PcePath.class).encode(path, this)); |
106 | return ok(result.toString()).build(); | 109 | return ok(result.toString()).build(); |
... | @@ -175,6 +178,9 @@ public class PcePathWebResource extends AbstractWebResource { | ... | @@ -175,6 +178,9 @@ public class PcePathWebResource extends AbstractWebResource { |
175 | ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); | 178 | ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream); |
176 | JsonNode pathNode = jsonTree.get("path"); | 179 | JsonNode pathNode = jsonTree.get("path"); |
177 | PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this); | 180 | PcePath path = codec(PcePath.class).decode((ObjectNode) pathNode, this); |
181 | + if (path == null) { | ||
182 | + return Response.status(OK).entity(PCE_SETUP_PATH_FAILED).build(); | ||
183 | + } | ||
178 | List<Constraint> constrntList = new LinkedList<Constraint>(); | 184 | List<Constraint> constrntList = new LinkedList<Constraint>(); |
179 | // Assign bandwidth | 185 | // Assign bandwidth |
180 | if (path.bandwidthConstraint() != null) { | 186 | if (path.bandwidthConstraint() != null) { | ... | ... |
-
Please register or login to post a comment