Fix some compiler warnings about unchecked types
Change-Id: Ib360aa05fd0e194a65bbc0b624447e4bdb4ced93
diff --git a/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java b/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
index f85a89d..24c69d2 100644
--- a/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
+++ b/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
@@ -241,6 +241,16 @@
return new BgpRouteEntryAndPeerMatcher(bgpRouteEntry);
}
+ @SuppressWarnings("unchecked")
+ private Dictionary<String, String>
+ getDictionaryMock(ComponentContext componentContext) {
+ Dictionary<String, String> dictionary = createMock(Dictionary.class);
+ expect(dictionary.get("bgpPort")).andReturn("0");
+ replay(dictionary);
+ expect(componentContext.getProperties()).andReturn(dictionary);
+ return dictionary;
+ }
+
@Before
public void setUp() throws Exception {
peer1 = new TestBgpPeer(BGP_PEER1_ID);
@@ -258,10 +268,7 @@
bgpSessionManager = new BgpSessionManager();
// NOTE: We use port 0 to bind on any available port
ComponentContext componentContext = createMock(ComponentContext.class);
- Dictionary<String, String> dictionary = createMock(Dictionary.class);
- expect(dictionary.get("bgpPort")).andReturn("0");
- replay(dictionary);
- expect(componentContext.getProperties()).andReturn(dictionary);
+ Dictionary<String, String> dictionary = getDictionaryMock(componentContext);
replay(componentContext);
bgpSessionManager.activate(componentContext);
bgpSessionManager.start(dummyRouteListener);
@@ -288,7 +295,7 @@
BgpRouteEntry.PathSegment pathSegment1 =
new BgpRouteEntry.PathSegment(pathSegmentType1, segmentAsNumbers1);
pathSegments.add(pathSegment1);
- asPathShort = new BgpRouteEntry.AsPath(new ArrayList(pathSegments));
+ asPathShort = new BgpRouteEntry.AsPath(new ArrayList<>(pathSegments));
//
byte pathSegmentType2 = (byte) BgpConstants.Update.AsPath.AS_SET;
ArrayList<Long> segmentAsNumbers2 = new ArrayList<>();
diff --git a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultTransactionContext.java b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultTransactionContext.java
index 5103348..40c3a5f 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultTransactionContext.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/consistent/impl/DefaultTransactionContext.java
@@ -56,6 +56,7 @@
}
@Override
+ @SuppressWarnings("unchecked")
public <K, V> TransactionalMap<K, V> createTransactionalMap(String mapName,
Serializer serializer) {
checkNotNull(mapName, "map name is null");
@@ -69,6 +70,7 @@
return txMaps.get(mapName);
}
+ @SuppressWarnings("unchecked")
@Override
public void commit() {
checkState(isOpen, TX_NOT_OPEN_ERROR);
diff --git a/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java b/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java
index 951f18e..fc85795 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/ecmap/EventuallyConsistentMapImplTest.java
@@ -155,6 +155,11 @@
ecMap.destroy();
}
+ @SuppressWarnings("unchecked")
+ private EventuallyConsistentMapListener<String, String> getListener() {
+ return createMock(EventuallyConsistentMapListener.class);
+ }
+
@Test
public void testSize() throws Exception {
expectAnyMessage(clusterCommunicator);
@@ -262,7 +267,7 @@
// Set up expectations of external events to be sent to listeners during
// the test. These don't use timestamps so we can set them all up at once.
EventuallyConsistentMapListener<String, String> listener
- = createMock(EventuallyConsistentMapListener.class);
+ = getListener();
listener.event(new EventuallyConsistentMapEvent<>(
EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1));
listener.event(new EventuallyConsistentMapEvent<>(
@@ -313,7 +318,7 @@
// Set up expectations of external events to be sent to listeners during
// the test. These don't use timestamps so we can set them all up at once.
EventuallyConsistentMapListener<String, String> listener
- = createMock(EventuallyConsistentMapListener.class);
+ = getListener();
listener.event(new EventuallyConsistentMapEvent<>(
EventuallyConsistentMapEvent.Type.REMOVE, KEY1, null));
expectLastCall().times(2);
@@ -384,7 +389,7 @@
// Set up the listener with our expected events
EventuallyConsistentMapListener<String, String> listener
- = createMock(EventuallyConsistentMapListener.class);
+ = getListener();
listener.event(new EventuallyConsistentMapEvent<>(
EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1));
listener.event(new EventuallyConsistentMapEvent<>(
@@ -412,7 +417,7 @@
@Test
public void testClear() throws Exception {
EventuallyConsistentMapListener<String, String> listener
- = createMock(EventuallyConsistentMapListener.class);
+ = getListener();
listener.event(new EventuallyConsistentMapEvent<>(
EventuallyConsistentMapEvent.Type.REMOVE, KEY1, null));
listener.event(new EventuallyConsistentMapEvent<>(
diff --git a/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTP.java b/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTP.java
index 441cd72..cd6bfef 100644
--- a/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTP.java
+++ b/openflow/drivers/src/main/java/org/onosproject/openflow/drivers/OFSwitchImplSpringOpenTTP.java
@@ -421,7 +421,7 @@
// executed - if there is an action to output/group in the action
// set
// the packet will be sent there, otherwise it will be dropped.
- instructions = (List<OFInstruction>) Collections.EMPTY_LIST;
+ instructions = Collections.<OFInstruction>emptyList();
}
OFMessage tableMissEntry = factory.buildFlowAdd()
diff --git a/utils/misc/src/main/java/org/onlab/graph/KshortestPathSearch.java b/utils/misc/src/main/java/org/onlab/graph/KshortestPathSearch.java
index db8402d..31e2523 100644
--- a/utils/misc/src/main/java/org/onlab/graph/KshortestPathSearch.java
+++ b/utils/misc/src/main/java/org/onlab/graph/KshortestPathSearch.java
@@ -46,7 +46,7 @@
// Initialize the graph.
public KshortestPathSearch(Graph<V, E> graph) {
immutableGraph = graph;
- mutableGraph = new MutableAdjacencyListsGraph(graph.getVertexes(),
+ mutableGraph = new MutableAdjacencyListsGraph<>(graph.getVertexes(),
graph.getEdges());
}
@@ -136,6 +136,7 @@
}
}
+ @SuppressWarnings({ "rawtypes", "unchecked" })
private List<E> searchShortestPath(Graph<V, E> graph, V src, V dst) {
// Determine the shortest path from the source to the destination by using the Dijkstra algorithm.
DijkstraGraphSearch dijkstraAlg = new DijkstraGraphSearch();