Satish K
Committed by Gerrit Code Review

bridgeUuid not null check further lead to Null access in fall through function call - Fix

Change-Id: I184491d5b4550e6c21f7649e0168c9308a7e16a0
...@@ -43,6 +43,7 @@ import org.onosproject.ovsdb.controller.OvsdbRowStore; ...@@ -43,6 +43,7 @@ import org.onosproject.ovsdb.controller.OvsdbRowStore;
43 import org.onosproject.ovsdb.controller.OvsdbStore; 43 import org.onosproject.ovsdb.controller.OvsdbStore;
44 import org.onosproject.ovsdb.controller.OvsdbTableStore; 44 import org.onosproject.ovsdb.controller.OvsdbTableStore;
45 import org.onosproject.ovsdb.controller.OvsdbTunnel; 45 import org.onosproject.ovsdb.controller.OvsdbTunnel;
46 +import org.onosproject.ovsdb.rfc.exception.BridgeCreateException;
46 import org.onosproject.ovsdb.rfc.jsonrpc.Callback; 47 import org.onosproject.ovsdb.rfc.jsonrpc.Callback;
47 import org.onosproject.ovsdb.rfc.message.OperationResult; 48 import org.onosproject.ovsdb.rfc.message.OperationResult;
48 import org.onosproject.ovsdb.rfc.message.TableUpdates; 49 import org.onosproject.ovsdb.rfc.message.TableUpdates;
...@@ -479,6 +480,9 @@ public class DefaultOvsdbClient ...@@ -479,6 +480,9 @@ public class DefaultOvsdbClient
479 insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid, 480 insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid,
480 port.getRow()); 481 port.getRow());
481 } 482 }
483 + } else {
484 + String message = BridgeCreateException.createMessage(ovsUuid);
485 + throw new BridgeCreateException(message);
482 } 486 }
483 487
484 } else { 488 } else {
...@@ -545,6 +549,9 @@ public class DefaultOvsdbClient ...@@ -545,6 +549,9 @@ public class DefaultOvsdbClient
545 insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid, 549 insertConfig(OvsdbConstant.PORT, "_uuid", "Bridge", "ports", bridgeUuid,
546 port.getRow()); 550 port.getRow());
547 } 551 }
552 + } else {
553 + String message = BridgeCreateException.createMessage(ovsUuid);
554 + throw new BridgeCreateException(message);
548 } 555 }
549 556
550 } else { 557 } else {
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.ovsdb.rfc.exception;
17 +
18 +import static com.google.common.base.MoreObjects.toStringHelper;
19 +
20 +/**
21 + * This exception is thrown when Bridge creation fails.
22 + */
23 +public class BridgeCreateException extends RuntimeException {
24 + private static final long serialVersionUID = 1377521646616825676L;
25 +
26 + /**
27 + * Constructs a BridgeCreateException object.
28 + * @param message error message
29 + */
30 + public BridgeCreateException(String message) {
31 + super(message);
32 + }
33 +
34 + /**
35 + * Constructs a BridgeCreateException object.
36 + * @param message error message
37 + * @param cause Throwable
38 + */
39 + public BridgeCreateException(String message, Throwable cause) {
40 + super(message, cause);
41 + }
42 +
43 + /**
44 + * Create error message.
45 + * @param ovsUuid ovs uuid name
46 + * @return message
47 + */
48 + public static String createMessage(String ovsUuid) {
49 + String message = toStringHelper("BridgeCreateException")
50 + .addValue("Create new bridge failed for " + ovsUuid).toString();
51 + return message;
52 + }
53 +}