From 98ffca81bf4e82d772f4bdab6ca98087d9efe932 Mon Sep 17 00:00:00 2001 From: Sho SHIMIZU Date: Mon, 11 May 2015 08:39:24 -0700 Subject: [PATCH] Save memory consumption by avoding unnecessary instantiation Change-Id: I7ce66c11136653fabc490aa7f33fdadf4454d2cc --- .../grouphandler/PolicyGroupHandler.java | 20 ++++----- .../net/intent/PathIntentTest.java | 3 +- .../net/group/impl/GroupManager.java | 10 ++--- .../LinkCollectionIntentCompiler.java | 4 +- .../impl/compiler/MplsPathIntentCompiler.java | 4 +- ...MultiPointToSinglePointIntentCompiler.java | 4 +- .../compiler/OpticalPathIntentCompiler.java | 5 ++- .../impl/compiler/PathIntentCompiler.java | 4 +- ...SinglePointToMultiPointIntentCompiler.java | 4 +- .../net/flow/impl/FlowRuleManagerTest.java | 3 +- .../net/group/impl/GroupManagerTest.java | 42 +++++++++---------- .../net/intent/impl/IntentManagerTest.java | 3 +- .../PointToPointIntentCompilerTest.java | 16 +++---- .../net/intent/impl/phase/CompilingTest.java | 6 +-- .../flow/impl/DistributedFlowRuleStore.java | 5 +-- .../impl/NewDistributedFlowRuleStore.java | 5 +-- .../trivial/impl/SimpleGroupStoreTest.java | 3 +- .../driver/pipeline/SpringOpenTTP.java | 5 +-- 18 files changed, 73 insertions(+), 73 deletions(-) diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java index d141ed1a52..c7ce295bcc 100644 --- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java +++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/PolicyGroupHandler.java @@ -18,7 +18,7 @@ package org.onosproject.segmentrouting.grouphandler; import static org.slf4j.LoggerFactory.getLogger; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -95,8 +95,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { new GroupBucketIdentifier(label, sp); PolicyGroupIdentifier key = new PolicyGroupIdentifier(id, - Arrays.asList(param), - Arrays.asList(bucketId)); + Collections.singletonList(param), + Collections.singletonList(bucketId)); TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder(); tBuilder.setOutput(sp) @@ -122,8 +122,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { previousGroupkey); PolicyGroupIdentifier key = new PolicyGroupIdentifier(id, - Arrays.asList(param), - Arrays.asList(bucketId)); + Collections.singletonList(param), + Collections.singletonList(bucketId)); // Add to group dependency list dependentGroups.put(previousGroupkey, key); previousGroupkey = key; @@ -283,8 +283,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { new GroupBucketIdentifier(label, sp); PolicyGroupIdentifier key = new PolicyGroupIdentifier(id, - Arrays.asList(param), - Arrays.asList(bucketId)); + Collections.singletonList(param), + Collections.singletonList(bucketId)); previousGroupkey = key; } else { // Intermediate Groups @@ -293,8 +293,8 @@ public class PolicyGroupHandler extends DefaultGroupHandler { previousGroupkey); PolicyGroupIdentifier key = new PolicyGroupIdentifier(id, - Arrays.asList(param), - Arrays.asList(bucketId)); + Collections.singletonList(param), + Collections.singletonList(bucketId)); previousGroupkey = key; } } @@ -348,4 +348,4 @@ public class PolicyGroupHandler extends DefaultGroupHandler { } } -} \ No newline at end of file +} diff --git a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java index b195a54881..dfbc1846de 100644 --- a/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java +++ b/core/api/src/test/java/org/onosproject/net/intent/PathIntentTest.java @@ -16,6 +16,7 @@ package org.onosproject.net.intent; import java.util.Arrays; +import java.util.Collections; import org.junit.Test; import org.onosproject.net.ConnectPoint; @@ -93,7 +94,7 @@ public class PathIntentTest extends ConnectivityIntentTest { .appId(APPID) .selector(MATCH) .treatment(NOP) - .path(new DefaultPath(provider1, Arrays.asList(link1), cost)) + .path(new DefaultPath(provider1, Collections.singletonList(link1), cost)) .build(); } diff --git a/core/net/src/main/java/org/onosproject/net/group/impl/GroupManager.java b/core/net/src/main/java/org/onosproject/net/group/impl/GroupManager.java index 6601cbf500..3c1d77cd95 100644 --- a/core/net/src/main/java/org/onosproject/net/group/impl/GroupManager.java +++ b/core/net/src/main/java/org/onosproject/net/group/impl/GroupManager.java @@ -17,8 +17,8 @@ package org.onosproject.net.group.impl; import static org.slf4j.LoggerFactory.getLogger; -import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Iterator; import java.util.Set; @@ -261,7 +261,7 @@ public class GroupManager group.type(), group.buckets()); groupOps = new GroupOperations( - Arrays.asList(groupAddOp)); + Collections.singletonList(groupAddOp)); groupProvider.performGroupOperation(group.deviceId(), groupOps); break; @@ -273,7 +273,7 @@ public class GroupManager group.type(), group.buckets()); groupOps = new GroupOperations( - Arrays.asList(groupModifyOp)); + Collections.singletonList(groupModifyOp)); groupProvider.performGroupOperation(group.deviceId(), groupOps); break; @@ -284,7 +284,7 @@ public class GroupManager createDeleteGroupOperation(group.id(), group.type()); groupOps = new GroupOperations( - Arrays.asList(groupDeleteOp)); + Collections.singletonList(groupDeleteOp)); groupProvider.performGroupOperation(group.deviceId(), groupOps); break; @@ -335,7 +335,7 @@ public class GroupManager group.type(), group.buckets()); GroupOperations groupOps = new GroupOperations( - Arrays.asList(groupAddOp)); + Collections.singletonList(groupAddOp)); gp.performGroupOperation(group.deviceId(), groupOps); break; default: diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java index e4f144d37a..94f85bde11 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/LinkCollectionIntentCompiler.java @@ -44,7 +44,7 @@ import org.onosproject.net.intent.LinkCollectionIntent; import org.onosproject.net.resource.LinkResourceAllocations; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -104,7 +104,7 @@ public class LinkCollectionIntentCompiler implements IntentCompiler createRules(LinkCollectionIntent intent, DeviceId deviceId, diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java index 557365de6c..9f835cfa5c 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MplsPathIntentCompiler.java @@ -52,7 +52,7 @@ import org.onosproject.net.resource.ResourceAllocation; import org.onosproject.net.resource.ResourceType; import org.slf4j.Logger; -import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -86,7 +86,7 @@ public class MplsPathIntentCompiler implements IntentCompiler { LinkResourceAllocations allocations = assignMplsLabel(intent); List rules = generateRules(intent, allocations); - return Arrays.asList(new FlowRuleIntent(appId, rules, intent.resources())); + return Collections.singletonList(new FlowRuleIntent(appId, rules, intent.resources())); } @Activate diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java index 6a5a1f3652..d004d6fb93 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/MultiPointToSinglePointIntentCompiler.java @@ -15,7 +15,7 @@ */ package org.onosproject.net.intent.impl.compiler; -import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -110,7 +110,7 @@ public class MultiPointToSinglePointIntentCompiler .constraints(intent.constraints()) .build(); - return Arrays.asList(result); + return Collections.singletonList(result); } /** diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java index e6a20f7527..2cf4ccb336 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalPathIntentCompiler.java @@ -46,7 +46,7 @@ import org.onosproject.net.resource.ResourceAllocation; import org.onosproject.net.resource.ResourceType; import org.onosproject.net.topology.TopologyService; -import java.util.Arrays; +import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Set; @@ -88,7 +88,8 @@ public class OpticalPathIntentCompiler implements IntentCompiler resources) { LinkResourceAllocations allocations = assignWavelength(intent); - return Arrays.asList(new FlowRuleIntent(appId, createRules(intent, allocations), intent.resources())); + return Collections.singletonList( + new FlowRuleIntent(appId, createRules(intent, allocations), intent.resources())); } private LinkResourceAllocations assignWavelength(OpticalPathIntent intent) { diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java index d78d6af23a..61c13e797f 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/PathIntentCompiler.java @@ -38,7 +38,7 @@ import org.onosproject.net.intent.PathIntent; import org.onosproject.net.resource.LinkResourceAllocations; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -80,7 +80,7 @@ public class PathIntentCompiler implements IntentCompiler { rules.add(rule); } - return Arrays.asList(new FlowRuleIntent(appId, null, rules, intent.resources())); + return Collections.singletonList(new FlowRuleIntent(appId, null, rules, intent.resources())); } private FlowRule createFlowRule(TrafficSelector originalSelector, TrafficTreatment originalTreatment, diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java index 46e6c66e66..0021cd2d74 100644 --- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java +++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/SinglePointToMultiPointIntentCompiler.java @@ -15,7 +15,7 @@ */ package org.onosproject.net.intent.impl.compiler; -import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -77,6 +77,6 @@ public class SinglePointToMultiPointIntentCompiler .constraints(intent.constraints()) .build(); - return Arrays.asList(result); + return Collections.singletonList(result); } } diff --git a/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java b/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java index 8634fb32b8..c8a32f039d 100644 --- a/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java +++ b/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java @@ -63,7 +63,6 @@ import org.onosproject.net.provider.ProviderId; import org.onosproject.store.trivial.impl.SimpleFlowRuleStore; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -412,7 +411,7 @@ public class FlowRuleManagerTest { @Override public Iterable getDevices() { - return Arrays.asList(DEV); + return Collections.singletonList(DEV); } @Override diff --git a/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java b/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java index 9a0ae89510..6b5929a424 100644 --- a/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java +++ b/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java @@ -258,9 +258,9 @@ public class GroupManagerTest { DID, Group.Type.SELECT, createdGroup.buckets()); - List groupEntries = Arrays.asList(createdGroup); + List groupEntries = Collections.singletonList(createdGroup); providerService.pushGroupMetrics(DID, groupEntries); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_ADDED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADDED)); } // Test group add bucket operations @@ -296,15 +296,15 @@ public class GroupManagerTest { addKey, appId); GroupBuckets updatedBuckets = new GroupBuckets(buckets); - List expectedGroupOps = Arrays.asList( - GroupOperation.createModifyGroupOperation(createdGroup.id(), - Group.Type.SELECT, - updatedBuckets)); + List expectedGroupOps = Collections.singletonList( + GroupOperation.createModifyGroupOperation(createdGroup.id(), + Group.Type.SELECT, + updatedBuckets)); internalProvider.validate(DID, expectedGroupOps); Group existingGroup = groupService.getGroup(DID, addKey); - List groupEntries = Arrays.asList(existingGroup); + List groupEntries = Collections.singletonList(existingGroup); providerService.pushGroupMetrics(DID, groupEntries); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED)); } // Test group remove bucket operations @@ -340,15 +340,15 @@ public class GroupManagerTest { removeKey, appId); GroupBuckets updatedBuckets = new GroupBuckets(buckets); - List expectedGroupOps = Arrays.asList( - GroupOperation.createModifyGroupOperation(createdGroup.id(), - Group.Type.SELECT, - updatedBuckets)); + List expectedGroupOps = Collections.singletonList( + GroupOperation.createModifyGroupOperation(createdGroup.id(), + Group.Type.SELECT, + updatedBuckets)); internalProvider.validate(DID, expectedGroupOps); Group existingGroup = groupService.getGroup(DID, removeKey); - List groupEntries = Arrays.asList(existingGroup); + List groupEntries = Collections.singletonList(existingGroup); providerService.pushGroupMetrics(DID, groupEntries); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED)); } // Test group remove operations @@ -356,13 +356,13 @@ public class GroupManagerTest { GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes()); Group existingGroup = groupService.getGroup(DID, currKey); groupService.removeGroup(DID, currKey, appId); - List expectedGroupOps = Arrays.asList( - GroupOperation.createDeleteGroupOperation(existingGroup.id(), - Group.Type.SELECT)); + List expectedGroupOps = Collections.singletonList( + GroupOperation.createDeleteGroupOperation(existingGroup.id(), + Group.Type.SELECT)); internalProvider.validate(DID, expectedGroupOps); List groupEntries = Collections.emptyList(); providerService.pushGroupMetrics(DID, groupEntries); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_REMOVED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVED)); } /** @@ -423,7 +423,7 @@ public class GroupManagerTest { createdGroup.type(), createdGroup.buckets()); providerService.groupOperationFailed(DID, groupAddOp); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_ADD_FAILED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADD_FAILED)); // Group Mod failure test groupService.addGroup(newGroupDesc); @@ -435,7 +435,7 @@ public class GroupManagerTest { createdGroup.type(), createdGroup.buckets()); providerService.groupOperationFailed(DID, groupModOp); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATE_FAILED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATE_FAILED)); // Group Delete failure test groupService.addGroup(newGroupDesc); @@ -446,7 +446,7 @@ public class GroupManagerTest { createDeleteGroupOperation(createdGroup.id(), createdGroup.type()); providerService.groupOperationFailed(DID, groupDelOp); - internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_REMOVE_FAILED)); + internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVE_FAILED)); } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java index 2512fee602..66bf476b3a 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java @@ -46,7 +46,6 @@ import org.onosproject.net.intent.Key; import org.onosproject.net.resource.LinkResourceAllocations; import org.onosproject.store.trivial.impl.SimpleIntentStore; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -151,7 +150,7 @@ public class IntentManagerTest { private static class MockInstallableIntent extends FlowRuleIntent { public MockInstallableIntent() { - super(APPID, Arrays.asList(new MockFlowRule(100))); + super(APPID, Collections.singletonList(new MockFlowRule(100))); } } diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java index 00fcf44cb1..32d917f065 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java @@ -38,7 +38,7 @@ import org.onosproject.net.resource.BandwidthResource; import org.onosproject.net.resource.LambdaResource; import org.onosproject.net.resource.LinkResourceService; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import static org.hamcrest.CoreMatchers.instanceOf; @@ -228,8 +228,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0); - final List constraints = Arrays.asList( - new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); + final List constraints = + Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); final PointToPointIntent intent = makeIntent("s1", "s3", constraints); @@ -250,8 +250,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); - final List constraints = Arrays.asList( - new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); + final List constraints = + Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0)))); try { final PointToPointIntent intent = makeIntent("s1", "s3", constraints); @@ -274,7 +274,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { @Test public void testLambdaConstrainedIntentSuccess() { - final List constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1))); + final List constraints = + Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeLambdaResourceService(1); @@ -297,7 +298,8 @@ public class PointToPointIntentCompilerTest extends AbstractIntentTest { @Test public void testLambdaConstrainedIntentFailure() { - final List constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1))); + final List constraints = + Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1))); final LinkResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); try { diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java index 742b4e237c..c15ecaeca4 100644 --- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java +++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java @@ -40,7 +40,7 @@ import org.onosproject.net.intent.impl.IntentProcessor; import org.onosproject.net.provider.ProviderId; import org.onosproject.store.Timestamp; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Optional; @@ -70,7 +70,7 @@ public class CompilingTest { private final ConnectPoint cp3 = new ConnectPoint(deviceId("2"), portNumber(1)); private final ConnectPoint cp4 = new ConnectPoint(deviceId("2"), portNumber(2)); - private final List links = Arrays.asList(new DefaultLink(pid, cp2, cp4, DIRECT)); + private final List links = Collections.singletonList(new DefaultLink(pid, cp2, cp4, DIRECT)); private final Path path = new DefaultPath(pid, links, 10); private PointToPointIntent input; @@ -118,7 +118,7 @@ public class CompilingTest { public void testMoveToNextPhaseWithoutError() { IntentData pending = new IntentData(input, INSTALL_REQ, version); - expect(processor.compile(input, null)).andReturn(Arrays.asList(compiled)); + expect(processor.compile(input, null)).andReturn(Collections.singletonList(compiled)); replay(processor); Compiling sut = new Compiling(processor, pending, Optional.empty()); diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java index f1ac1f8ca6..8b7be9a9dc 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/DistributedFlowRuleStore.java @@ -78,7 +78,6 @@ import org.osgi.service.component.ComponentContext; import org.slf4j.Logger; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.Dictionary; import java.util.HashSet; @@ -388,7 +387,7 @@ public class DistributedFlowRuleStore @Override public void storeFlowRule(FlowRule rule) { storeBatch(new FlowRuleBatchOperation( - Arrays.asList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), + Collections.singletonList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), rule.deviceId(), idGenerator.getNewId())); } @@ -516,7 +515,7 @@ public class DistributedFlowRuleStore public void deleteFlowRule(FlowRule rule) { storeBatch( new FlowRuleBatchOperation( - Arrays.asList( + Collections.singletonList( new FlowRuleBatchEntry( FlowRuleOperation.REMOVE, rule)), rule.deviceId(), idGenerator.getNewId())); diff --git a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java index 8bfab64104..56c4dfb84c 100644 --- a/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java +++ b/core/store/dist/src/main/java/org/onosproject/store/flow/impl/NewDistributedFlowRuleStore.java @@ -71,7 +71,6 @@ import org.onosproject.store.serializers.impl.DistributedStoreSerializers; import org.osgi.service.component.ComponentContext; import org.slf4j.Logger; -import java.util.Arrays; import java.util.Collections; import java.util.Dictionary; import java.util.HashSet; @@ -378,7 +377,7 @@ public class NewDistributedFlowRuleStore @Override public void storeFlowRule(FlowRule rule) { storeBatch(new FlowRuleBatchOperation( - Arrays.asList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), + Collections.singletonList(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule)), rule.deviceId(), idGenerator.getNewId())); } @@ -484,7 +483,7 @@ public class NewDistributedFlowRuleStore public void deleteFlowRule(FlowRule rule) { storeBatch( new FlowRuleBatchOperation( - Arrays.asList( + Collections.singletonList( new FlowRuleBatchEntry( FlowRuleOperation.REMOVE, rule)), rule.deviceId(), idGenerator.getNewId())); diff --git a/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleGroupStoreTest.java b/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleGroupStoreTest.java index 3cf2af3509..88e30e5f69 100644 --- a/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleGroupStoreTest.java +++ b/core/store/trivial/src/test/java/org/onosproject/store/trivial/impl/SimpleGroupStoreTest.java @@ -20,6 +20,7 @@ import static org.onosproject.net.DeviceId.deviceId; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Optional; @@ -307,7 +308,7 @@ public class SimpleGroupStoreTest { PortNumber[] newNeighborPorts = {PortNumber.portNumber(41), PortNumber.portNumber(42)}; List newOutPorts = new ArrayList(); - newOutPorts.addAll(Arrays.asList(newNeighborPorts[0])); + newOutPorts.addAll(Collections.singletonList(newNeighborPorts[0])); List toAddBuckets = new ArrayList(); for (PortNumber portNumber: newOutPorts) { diff --git a/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java b/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java index 1ce438121b..5424558ded 100644 --- a/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java +++ b/drivers/src/main/java/org/onosproject/driver/pipeline/SpringOpenTTP.java @@ -73,7 +73,6 @@ import org.onosproject.net.group.GroupService; import org.slf4j.Logger; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -313,7 +312,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour log.warn("Unsupported Group type {}", group.type()); return; } - GroupBuckets bucketsToAdd = new GroupBuckets(Arrays.asList(bucket)); + GroupBuckets bucketsToAdd = new GroupBuckets(Collections.singletonList(bucket)); groupService.addBucketsToGroup(deviceId, key, bucketsToAdd, key, appId); } @@ -339,7 +338,7 @@ public class SpringOpenTTP extends AbstractHandlerBehaviour log.warn("Unsupported Group type {}", group.type()); return; } - GroupBuckets removeBuckets = new GroupBuckets(Arrays.asList(bucket)); + GroupBuckets removeBuckets = new GroupBuckets(Collections.singletonList(bucket)); groupService.removeBucketsFromGroup(deviceId, key, removeBuckets, key, appId); } }