Committed by
Gerrit Code Review
Fix some compiler warnings about unchecked types
Change-Id: Ib360aa05fd0e194a65bbc0b624447e4bdb4ced93
Showing
5 changed files
with
26 additions
and
11 deletions
| ... | @@ -241,6 +241,16 @@ public class BgpSessionManagerTest { | ... | @@ -241,6 +241,16 @@ public class BgpSessionManagerTest { |
| 241 | return new BgpRouteEntryAndPeerMatcher(bgpRouteEntry); | 241 | return new BgpRouteEntryAndPeerMatcher(bgpRouteEntry); |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | + @SuppressWarnings("unchecked") | ||
| 245 | + private Dictionary<String, String> | ||
| 246 | + getDictionaryMock(ComponentContext componentContext) { | ||
| 247 | + Dictionary<String, String> dictionary = createMock(Dictionary.class); | ||
| 248 | + expect(dictionary.get("bgpPort")).andReturn("0"); | ||
| 249 | + replay(dictionary); | ||
| 250 | + expect(componentContext.getProperties()).andReturn(dictionary); | ||
| 251 | + return dictionary; | ||
| 252 | + } | ||
| 253 | + | ||
| 244 | @Before | 254 | @Before |
| 245 | public void setUp() throws Exception { | 255 | public void setUp() throws Exception { |
| 246 | peer1 = new TestBgpPeer(BGP_PEER1_ID); | 256 | peer1 = new TestBgpPeer(BGP_PEER1_ID); |
| ... | @@ -258,10 +268,7 @@ public class BgpSessionManagerTest { | ... | @@ -258,10 +268,7 @@ public class BgpSessionManagerTest { |
| 258 | bgpSessionManager = new BgpSessionManager(); | 268 | bgpSessionManager = new BgpSessionManager(); |
| 259 | // NOTE: We use port 0 to bind on any available port | 269 | // NOTE: We use port 0 to bind on any available port |
| 260 | ComponentContext componentContext = createMock(ComponentContext.class); | 270 | ComponentContext componentContext = createMock(ComponentContext.class); |
| 261 | - Dictionary<String, String> dictionary = createMock(Dictionary.class); | 271 | + Dictionary<String, String> dictionary = getDictionaryMock(componentContext); |
| 262 | - expect(dictionary.get("bgpPort")).andReturn("0"); | ||
| 263 | - replay(dictionary); | ||
| 264 | - expect(componentContext.getProperties()).andReturn(dictionary); | ||
| 265 | replay(componentContext); | 272 | replay(componentContext); |
| 266 | bgpSessionManager.activate(componentContext); | 273 | bgpSessionManager.activate(componentContext); |
| 267 | bgpSessionManager.start(dummyRouteListener); | 274 | bgpSessionManager.start(dummyRouteListener); |
| ... | @@ -288,7 +295,7 @@ public class BgpSessionManagerTest { | ... | @@ -288,7 +295,7 @@ public class BgpSessionManagerTest { |
| 288 | BgpRouteEntry.PathSegment pathSegment1 = | 295 | BgpRouteEntry.PathSegment pathSegment1 = |
| 289 | new BgpRouteEntry.PathSegment(pathSegmentType1, segmentAsNumbers1); | 296 | new BgpRouteEntry.PathSegment(pathSegmentType1, segmentAsNumbers1); |
| 290 | pathSegments.add(pathSegment1); | 297 | pathSegments.add(pathSegment1); |
| 291 | - asPathShort = new BgpRouteEntry.AsPath(new ArrayList(pathSegments)); | 298 | + asPathShort = new BgpRouteEntry.AsPath(new ArrayList<>(pathSegments)); |
| 292 | // | 299 | // |
| 293 | byte pathSegmentType2 = (byte) BgpConstants.Update.AsPath.AS_SET; | 300 | byte pathSegmentType2 = (byte) BgpConstants.Update.AsPath.AS_SET; |
| 294 | ArrayList<Long> segmentAsNumbers2 = new ArrayList<>(); | 301 | ArrayList<Long> segmentAsNumbers2 = new ArrayList<>(); | ... | ... |
| ... | @@ -56,6 +56,7 @@ public class DefaultTransactionContext implements TransactionContext { | ... | @@ -56,6 +56,7 @@ public class DefaultTransactionContext implements TransactionContext { |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | @Override | 58 | @Override |
| 59 | + @SuppressWarnings("unchecked") | ||
| 59 | public <K, V> TransactionalMap<K, V> createTransactionalMap(String mapName, | 60 | public <K, V> TransactionalMap<K, V> createTransactionalMap(String mapName, |
| 60 | Serializer serializer) { | 61 | Serializer serializer) { |
| 61 | checkNotNull(mapName, "map name is null"); | 62 | checkNotNull(mapName, "map name is null"); |
| ... | @@ -69,6 +70,7 @@ public class DefaultTransactionContext implements TransactionContext { | ... | @@ -69,6 +70,7 @@ public class DefaultTransactionContext implements TransactionContext { |
| 69 | return txMaps.get(mapName); | 70 | return txMaps.get(mapName); |
| 70 | } | 71 | } |
| 71 | 72 | ||
| 73 | + @SuppressWarnings("unchecked") | ||
| 72 | @Override | 74 | @Override |
| 73 | public void commit() { | 75 | public void commit() { |
| 74 | checkState(isOpen, TX_NOT_OPEN_ERROR); | 76 | checkState(isOpen, TX_NOT_OPEN_ERROR); | ... | ... |
| ... | @@ -155,6 +155,11 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -155,6 +155,11 @@ public class EventuallyConsistentMapImplTest { |
| 155 | ecMap.destroy(); | 155 | ecMap.destroy(); |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | + @SuppressWarnings("unchecked") | ||
| 159 | + private EventuallyConsistentMapListener<String, String> getListener() { | ||
| 160 | + return createMock(EventuallyConsistentMapListener.class); | ||
| 161 | + } | ||
| 162 | + | ||
| 158 | @Test | 163 | @Test |
| 159 | public void testSize() throws Exception { | 164 | public void testSize() throws Exception { |
| 160 | expectAnyMessage(clusterCommunicator); | 165 | expectAnyMessage(clusterCommunicator); |
| ... | @@ -262,7 +267,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -262,7 +267,7 @@ public class EventuallyConsistentMapImplTest { |
| 262 | // Set up expectations of external events to be sent to listeners during | 267 | // Set up expectations of external events to be sent to listeners during |
| 263 | // the test. These don't use timestamps so we can set them all up at once. | 268 | // the test. These don't use timestamps so we can set them all up at once. |
| 264 | EventuallyConsistentMapListener<String, String> listener | 269 | EventuallyConsistentMapListener<String, String> listener |
| 265 | - = createMock(EventuallyConsistentMapListener.class); | 270 | + = getListener(); |
| 266 | listener.event(new EventuallyConsistentMapEvent<>( | 271 | listener.event(new EventuallyConsistentMapEvent<>( |
| 267 | EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); | 272 | EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); |
| 268 | listener.event(new EventuallyConsistentMapEvent<>( | 273 | listener.event(new EventuallyConsistentMapEvent<>( |
| ... | @@ -313,7 +318,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -313,7 +318,7 @@ public class EventuallyConsistentMapImplTest { |
| 313 | // Set up expectations of external events to be sent to listeners during | 318 | // Set up expectations of external events to be sent to listeners during |
| 314 | // the test. These don't use timestamps so we can set them all up at once. | 319 | // the test. These don't use timestamps so we can set them all up at once. |
| 315 | EventuallyConsistentMapListener<String, String> listener | 320 | EventuallyConsistentMapListener<String, String> listener |
| 316 | - = createMock(EventuallyConsistentMapListener.class); | 321 | + = getListener(); |
| 317 | listener.event(new EventuallyConsistentMapEvent<>( | 322 | listener.event(new EventuallyConsistentMapEvent<>( |
| 318 | EventuallyConsistentMapEvent.Type.REMOVE, KEY1, null)); | 323 | EventuallyConsistentMapEvent.Type.REMOVE, KEY1, null)); |
| 319 | expectLastCall().times(2); | 324 | expectLastCall().times(2); |
| ... | @@ -384,7 +389,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -384,7 +389,7 @@ public class EventuallyConsistentMapImplTest { |
| 384 | 389 | ||
| 385 | // Set up the listener with our expected events | 390 | // Set up the listener with our expected events |
| 386 | EventuallyConsistentMapListener<String, String> listener | 391 | EventuallyConsistentMapListener<String, String> listener |
| 387 | - = createMock(EventuallyConsistentMapListener.class); | 392 | + = getListener(); |
| 388 | listener.event(new EventuallyConsistentMapEvent<>( | 393 | listener.event(new EventuallyConsistentMapEvent<>( |
| 389 | EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); | 394 | EventuallyConsistentMapEvent.Type.PUT, KEY1, VALUE1)); |
| 390 | listener.event(new EventuallyConsistentMapEvent<>( | 395 | listener.event(new EventuallyConsistentMapEvent<>( |
| ... | @@ -412,7 +417,7 @@ public class EventuallyConsistentMapImplTest { | ... | @@ -412,7 +417,7 @@ public class EventuallyConsistentMapImplTest { |
| 412 | @Test | 417 | @Test |
| 413 | public void testClear() throws Exception { | 418 | public void testClear() throws Exception { |
| 414 | EventuallyConsistentMapListener<String, String> listener | 419 | EventuallyConsistentMapListener<String, String> listener |
| 415 | - = createMock(EventuallyConsistentMapListener.class); | 420 | + = getListener(); |
| 416 | listener.event(new EventuallyConsistentMapEvent<>( | 421 | listener.event(new EventuallyConsistentMapEvent<>( |
| 417 | EventuallyConsistentMapEvent.Type.REMOVE, KEY1, null)); | 422 | EventuallyConsistentMapEvent.Type.REMOVE, KEY1, null)); |
| 418 | listener.event(new EventuallyConsistentMapEvent<>( | 423 | listener.event(new EventuallyConsistentMapEvent<>( | ... | ... |
| ... | @@ -421,7 +421,7 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { | ... | @@ -421,7 +421,7 @@ public class OFSwitchImplSpringOpenTTP extends AbstractOpenFlowSwitch { |
| 421 | // executed - if there is an action to output/group in the action | 421 | // executed - if there is an action to output/group in the action |
| 422 | // set | 422 | // set |
| 423 | // the packet will be sent there, otherwise it will be dropped. | 423 | // the packet will be sent there, otherwise it will be dropped. |
| 424 | - instructions = (List<OFInstruction>) Collections.EMPTY_LIST; | 424 | + instructions = Collections.<OFInstruction>emptyList(); |
| 425 | } | 425 | } |
| 426 | 426 | ||
| 427 | OFMessage tableMissEntry = factory.buildFlowAdd() | 427 | OFMessage tableMissEntry = factory.buildFlowAdd() | ... | ... |
| ... | @@ -46,7 +46,7 @@ public class KshortestPathSearch<V extends Vertex, E extends Edge<V>> { | ... | @@ -46,7 +46,7 @@ public class KshortestPathSearch<V extends Vertex, E extends Edge<V>> { |
| 46 | // Initialize the graph. | 46 | // Initialize the graph. |
| 47 | public KshortestPathSearch(Graph<V, E> graph) { | 47 | public KshortestPathSearch(Graph<V, E> graph) { |
| 48 | immutableGraph = graph; | 48 | immutableGraph = graph; |
| 49 | - mutableGraph = new MutableAdjacencyListsGraph(graph.getVertexes(), | 49 | + mutableGraph = new MutableAdjacencyListsGraph<>(graph.getVertexes(), |
| 50 | graph.getEdges()); | 50 | graph.getEdges()); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| ... | @@ -136,6 +136,7 @@ public class KshortestPathSearch<V extends Vertex, E extends Edge<V>> { | ... | @@ -136,6 +136,7 @@ public class KshortestPathSearch<V extends Vertex, E extends Edge<V>> { |
| 136 | } | 136 | } |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | + @SuppressWarnings({ "rawtypes", "unchecked" }) | ||
| 139 | private List<E> searchShortestPath(Graph<V, E> graph, V src, V dst) { | 140 | private List<E> searchShortestPath(Graph<V, E> graph, V src, V dst) { |
| 140 | // Determine the shortest path from the source to the destination by using the Dijkstra algorithm. | 141 | // Determine the shortest path from the source to the destination by using the Dijkstra algorithm. |
| 141 | DijkstraGraphSearch dijkstraAlg = new DijkstraGraphSearch(); | 142 | DijkstraGraphSearch dijkstraAlg = new DijkstraGraphSearch(); | ... | ... |
-
Please register or login to post a comment