Narrow exceptions to be caught
Change-Id: I72d3153d8451e82bf2889d3fb983fdc9b5a37e6c
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
index da8796b..d51ddd0 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentLinkResourceStore.java
@@ -68,7 +68,6 @@
import com.google.common.collect.Sets;
import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
import static org.slf4j.LoggerFactory.getLogger;
import static org.onosproject.net.AnnotationKeys.BANDWIDTH;
@@ -295,6 +294,9 @@
intentAllocs.put(allocations.intentId(), allocations);
allocations.links().forEach(link -> allocateLinkResource(tx, link, allocations));
tx.commit();
+ } catch (TransactionException | ResourceAllocationException e) {
+ log.error("Exception thrown, rolling back", e);
+ tx.abort();
} catch (Exception e) {
log.error("Exception thrown, rolling back", e);
tx.abort();
@@ -312,9 +314,7 @@
if (req instanceof BandwidthResourceAllocation) {
// check if allocation should be accepted
if (avail.isEmpty()) {
- checkState(!avail.isEmpty(),
- "There's no Bandwidth resource on %s?",
- link);
+ throw new ResourceAllocationException(String.format("There's no Bandwidth resource on %s?", link));
}
BandwidthResourceAllocation bw = (BandwidthResourceAllocation) avail.iterator().next();
double bwLeft = bw.bandwidth().toDouble();