Merge pull request #20 from amichair/refactorings
Little refactorings and code cleanup
diff --git a/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java b/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
index 790b01b..f043383 100644
--- a/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
+++ b/discovery/config/src/test/java/org/apache/aries/rsa/discovery/config/PropertyValidatorTest.java
@@ -42,7 +42,7 @@
public class PropertyValidatorTest {
@Test
public void testToMap() throws Exception {
- Dictionary<String, String> dic = new Hashtable<String, String>();
+ Dictionary<String, String> dic = new Hashtable<>();
dic.put("key", "value");
assertThat(toMap(dic).size(), is(1));
@@ -55,7 +55,7 @@
@Test
public void testFilterConfigAdminProperties() throws Exception {
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<>();
map.put(Constants.SERVICE_PID, "testPid");
map.put(ConfigurationAdmin.SERVICE_FACTORYPID, "factoryPid");
map.put(ConfigurationAdmin.SERVICE_BUNDLELOCATION, "bundleLocation");
@@ -73,18 +73,18 @@
@Test
public void testValidatePropertyTypes_objectClass() throws Exception {
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<>();
map.put(Constants.OBJECTCLASS, "test");
Map<String, Object> config = validatePropertyTypes(map);
assertThat(config.containsKey(Constants.OBJECTCLASS), is(true));
assertThat(config.get(Constants.OBJECTCLASS), Is.<Object>is(new String[]{"test"}));
- map = new HashMap<String, Object>();
+ map = new HashMap<>();
map.put(Constants.OBJECTCLASS, new String[]{"test"});
config = validatePropertyTypes(map);
assertThat(config.get(Constants.OBJECTCLASS), Is.<Object>is(new String[]{"test"}));
- map = new HashMap<String, Object>();
+ map = new HashMap<>();
map.put(Constants.OBJECTCLASS, singletonList("test"));
config = validatePropertyTypes(map);
assertThat(config.get(Constants.OBJECTCLASS), Is.<Object>is(new String[]{"test"}));
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
index 0a0c02f..9fcb8b4 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/EndpointDescriptionParser.java
@@ -64,7 +64,7 @@
public List<EndpointDescription> readEndpoints(InputStream is) {
List<EndpointDescriptionType> epdts = readEpdts(is);
- List<EndpointDescription> epds = new ArrayList<EndpointDescription>();
+ List<EndpointDescription> epds = new ArrayList<>();
for (EndpointDescriptionType epdt : epdts) {
epds.add(convert(epdt));
}
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
index a17020b..4ae8787 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapper.java
@@ -50,7 +50,7 @@
private static final Logger LOG = LoggerFactory.getLogger(PropertiesMapper.class);
public Map<String, Object> toProps(List<PropertyType> properties) {
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<>();
for (PropertyType prop : properties) {
map.put(prop.getName(), getValue(prop));
}
@@ -69,9 +69,9 @@
if ("array".equals(elName)) {
value = getArray(inValue, type);
} else if ("set".equals(elName)) {
- value = handleCollection(inValue, new HashSet<Object>(), type);
+ value = handleCollection(inValue, new HashSet<>(), type);
} else if ("list".equals(elName)) {
- value = handleCollection(inValue, new ArrayList<Object>(), type);
+ value = handleCollection(inValue, new ArrayList<>(), type);
}
} else if (el.getDeclaredType() == XmlType.class) {
value = readXML((XmlType)el.getValue(), type);
@@ -218,7 +218,7 @@
try {
if ("Character".equals(boxedType)) {
- return new Character(value.charAt(0));
+ return value.charAt(0);
} else {
Class<?> cls = ClassLoader.getSystemClassLoader().loadClass(javaType);
Constructor<?> ctor = cls.getConstructor(String.class);
@@ -280,7 +280,7 @@
}
private static Object[] normalizeArray(Object val) {
- List<Object> l = new ArrayList<Object>();
+ List<Object> l = new ArrayList<>();
if (val instanceof int[]) {
int[] ia = (int[]) val;
for (int i : ia) {
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
index b4393a9..1484dcb 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParser.java
@@ -45,9 +45,9 @@
public List<EndpointDescription> getAllEndpointDescriptions(Bundle b) {
Enumeration<URL> urls = getEndpointDescriptionURLs(b);
- List<EndpointDescription> elements = new ArrayList<EndpointDescription>();
+ List<EndpointDescription> elements = new ArrayList<>();
while (urls.hasMoreElements()) {
- URL resourceURL = (URL) urls.nextElement();
+ URL resourceURL = urls.nextElement();
try {
elements.addAll(parser.readEndpoints(resourceURL.openStream()));
} catch (Exception ex) {
diff --git a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
index 9f076f8..adf98b4 100644
--- a/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
+++ b/discovery/local/src/main/java/org/apache/aries/rsa/discovery/local/LocalDiscovery.java
@@ -44,12 +44,9 @@
// this is effectively a set which allows for multiple service descriptions with the
// same interface name but different properties and takes care of itself with respect to concurrency
- Map<EndpointDescription, Bundle> endpointDescriptions =
- new ConcurrentHashMap<EndpointDescription, Bundle>();
- Map<EndpointEventListener, Collection<String>> listenerToFilters =
- new HashMap<EndpointEventListener, Collection<String>>();
- Map<String, Collection<EndpointEventListener>> filterToListeners =
- new HashMap<String, Collection<EndpointEventListener>>();
+ final Map<EndpointDescription, Bundle> endpointDescriptions = new ConcurrentHashMap<>();
+ final Map<EndpointEventListener, Collection<String>> listenerToFilters = new HashMap<>();
+ final Map<String, Collection<EndpointEventListener>> filterToListeners = new HashMap<>();
EndpointDescriptionBundleParser bundleParser;
@@ -80,7 +77,7 @@
for (String filter : filters) {
Collection<EndpointEventListener> listeners = filterToListeners.get(filter);
if (listeners == null) {
- listeners = new ArrayList<EndpointEventListener>();
+ listeners = new ArrayList<>();
filterToListeners.put(filter, listeners);
}
listeners.add(endpointListener);
@@ -117,12 +114,12 @@
private Map<String, Collection<EndpointEventListener>> getMatchingListeners(EndpointDescription endpoint) {
// return a copy of matched filters/listeners so that caller doesn't need to hold locks while triggering events
- Map<String, Collection<EndpointEventListener>> matched = new HashMap<String, Collection<EndpointEventListener>>();
+ Map<String, Collection<EndpointEventListener>> matched = new HashMap<>();
synchronized (listenerToFilters) {
for (Entry<String, Collection<EndpointEventListener>> entry : filterToListeners.entrySet()) {
String filter = entry.getKey();
if (LocalDiscovery.matchFilter(filter, endpoint)) {
- matched.put(filter, new ArrayList<EndpointEventListener>(entry.getValue()));
+ matched.put(filter, new ArrayList<>(entry.getValue()));
}
}
}
@@ -196,7 +193,7 @@
try {
Filter f = FrameworkUtil.createFilter(filter);
- Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
+ Dictionary<String, Object> dict = new Hashtable<>(endpoint.getProperties());
return f.match(dict);
} catch (Exception e) {
return false;
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
index 17ef458..ffd1dbc 100644
--- a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/endpoint/PropertiesMapperTest.java
@@ -38,7 +38,7 @@
@Test
@Ignore
public void testCreateXML() throws Exception {
- Map<String, Object> m = new LinkedHashMap<String, Object>();
+ Map<String, Object> m = new LinkedHashMap<>();
m.put("service.imported.configs", "org.apache.cxf.ws");
m.put("endpoint.id", "foo:bar");
m.put("objectClass", new String[] {"com.acme.HelloService", "some.other.Service"});
@@ -60,10 +60,10 @@
m.put("char", '@');
m.put("Character2", 'X');
- m.put("bool-list", Arrays.asList(new Boolean[]{true, false}));
- m.put("empty-set", new HashSet<Object>());
+ m.put("bool-list", Arrays.asList(true, false));
+ m.put("empty-set", new HashSet<>());
- Set<String> stringSet = new LinkedHashSet<String>();
+ Set<String> stringSet = new LinkedHashSet<>();
stringSet.add("Hello there");
stringSet.add("How are you?");
m.put("string-set", stringSet);
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
index 63753ac..c4b10a0 100644
--- a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/EndpointDescriptionBundleParserTest.java
@@ -140,8 +140,8 @@
assertTrue(Arrays.equals(new Integer[] {2, 1}, integerArray));
assertEquals(Arrays.asList(true, false), props.get("bool-list"));
- assertEquals(new HashSet<Object>(), props.get("long-set"));
- Set<String> stringSet = new HashSet<String>();
+ assertEquals(new HashSet<>(), props.get("long-set"));
+ Set<String> stringSet = new HashSet<>();
stringSet.add("Hello there");
stringSet.add("How are you?");
assertEquals(stringSet, props.get("string-set"));
diff --git a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java
index 42cd86b..59b3c3f 100644
--- a/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java
+++ b/discovery/local/src/test/java/org/apache/aries/rsa/discovery/local/LocalDiscoveryTest.java
@@ -51,7 +51,7 @@
EasyMock.replay(b1);
Bundle b2 = EasyMock.createMock(Bundle.class);
EasyMock.expect(b2.getState()).andReturn(Bundle.ACTIVE);
- Dictionary<String, String> headers = new Hashtable<String, String>();
+ Dictionary<String, String> headers = new Hashtable<>();
headers.put("Remote-Service", "OSGI-INF/remote-service/");
EasyMock.expect(b2.getHeaders()).andReturn(headers);
@@ -68,9 +68,9 @@
ld.processExistingBundles(bundles);
assertEquals(3, ld.endpointDescriptions.size());
- Set<String> expected = new HashSet<String>(
- Arrays.asList("http://somewhere:12345", "http://somewhere:1", "http://somewhere"));
- Set<String> actual = new HashSet<String>();
+ Set<String> expected = new HashSet<>(
+ Arrays.asList("http://somewhere:12345", "http://somewhere:1", "http://somewhere"));
+ Set<String> actual = new HashSet<>();
for (Map.Entry<EndpointDescription, Bundle> entry : ld.endpointDescriptions.entrySet()) {
assertSame(b2, entry.getValue());
actual.add(entry.getKey().getId());
@@ -85,7 +85,7 @@
Bundle bundle = EasyMock.createMock(Bundle.class);
EasyMock.expect(bundle.getSymbolicName()).andReturn("testing.bundle").anyTimes();
EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE);
- Dictionary<String, String> headers = new Hashtable<String, String>();
+ Dictionary<String, String> headers = new Hashtable<>();
headers.put("Remote-Service", "OSGI-INF/rsa/");
EasyMock.expect(bundle.getHeaders()).andReturn(headers);
EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "*.xml", false))
@@ -162,7 +162,7 @@
ServiceReference<EndpointEventListener> sr2 = epListenerWithScope("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))");
EasyMock.reset(el);
- final Set<String> actualEndpoints = new HashSet<String>();
+ final Set<String> actualEndpoints = new HashSet<>();
el.endpointChanged(EasyMock.anyObject(EndpointEvent.class),
EasyMock.eq("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"));
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@@ -185,7 +185,7 @@
ld.filterToListeners.get("(|(objectClass=org.example.ClassA)(objectClass=org.example.ClassB))"));
EasyMock.verify(el);
- Set<String> expectedEndpoints = new HashSet<String>(Arrays.asList("org.example.ClassA", "org.example.ClassB"));
+ Set<String> expectedEndpoints = new HashSet<>(Arrays.asList("org.example.ClassA", "org.example.ClassB"));
assertEquals(expectedEndpoints, actualEndpoints);
// Remove the EndpointListener Service
@@ -198,7 +198,7 @@
public void testRegisterTracker() throws Exception {
LocalDiscovery ld = new LocalDiscovery();
- final Map<String, Object> props = new Hashtable<String, Object>();
+ final Map<String, Object> props = new Hashtable<>();
props.put(EndpointEventListener.ENDPOINT_LISTENER_SCOPE, "(objectClass=Aaaa)");
@SuppressWarnings("unchecked")
ServiceReference<EndpointEventListener> sr = EasyMock.createMock(ServiceReference.class);
@@ -246,7 +246,7 @@
assertEquals(endpointListeners12, ld.filterToListeners.get("(objectClass=Aaaa)"));
// Add another listener with a multi-value scope
- final Map<String, Object> props2 = new Hashtable<String, Object>();
+ final Map<String, Object> props2 = new Hashtable<>();
props2.put(EndpointEventListener.ENDPOINT_LISTENER_SCOPE, Arrays.asList("(objectClass=X)", "(objectClass=Y)"));
@SuppressWarnings("unchecked")
ServiceReference<EndpointEventListener> sr3 = EasyMock.createMock(ServiceReference.class);
@@ -279,10 +279,10 @@
EndpointEventListener endpointListener = EasyMock.createMock(EndpointEventListener.class);
ld.listenerToFilters.put(endpointListener,
- new ArrayList<String>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
- ld.filterToListeners.put("(a=b)", new ArrayList<EndpointEventListener>(Arrays.asList(endpointListener)));
+ new ArrayList<>(Arrays.asList("(a=b)", "(objectClass=foo.bar.Bheuaark)")));
+ ld.filterToListeners.put("(a=b)", new ArrayList<>(Arrays.asList(endpointListener)));
ld.filterToListeners.put("(objectClass=foo.bar.Bheuaark)",
- new ArrayList<EndpointEventListener>(Arrays.asList(endpointListener)));
+ new ArrayList<>(Arrays.asList(endpointListener)));
assertEquals(1, ld.listenerToFilters.size());
assertEquals(2, ld.filterToListeners.size());
@@ -297,7 +297,7 @@
}
private ServiceReference<EndpointEventListener> epListenerWithScope(String scope) {
- final Map<String, Object> props = new Hashtable<String, Object>();
+ final Map<String, Object> props = new Hashtable<>();
props.put(EndpointEventListener.ENDPOINT_LISTENER_SCOPE, new String[] {scope});
return mockService(props);
}
@@ -319,7 +319,7 @@
private Bundle createBundle() {
Bundle bundle = EasyMock.createMock(Bundle.class);
EasyMock.expect(bundle.getState()).andReturn(Bundle.ACTIVE);
- Dictionary<String, String> headers = new Hashtable<String, String>();
+ Dictionary<String, String> headers = new Hashtable<>();
headers.put("Remote-Service", "OSGI-INF/rsa/ed4.xml");
EasyMock.expect(bundle.getHeaders()).andReturn(headers);
EasyMock.expect(bundle.findEntries("OSGI-INF/rsa", "ed4.xml", false))
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Activator.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Activator.java
index 57a0fdc..076159b 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Activator.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/Activator.java
@@ -55,7 +55,7 @@
}
private Dictionary<String, String> configProperties(String pid) {
- Dictionary<String, String> props = new Hashtable<String, String>();
+ Dictionary<String, String> props = new Hashtable<>();
props.put(Constants.SERVICE_PID, pid);
return props;
}
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ZooKeeperDiscovery.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ZooKeeperDiscovery.java
index 5e55d8c..2e9bea2 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ZooKeeperDiscovery.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/ZooKeeperDiscovery.java
@@ -130,8 +130,7 @@
}
protected ZooKeeper createZooKeeper(String host, String port, int timeout) throws IOException {
- LOG.info("ZooKeeper discovery connecting to {}:{} with timeout {}",
- new Object[]{host, port, timeout});
+ LOG.info("ZooKeeper discovery connecting to {}:{} with timeout {}", host, port, timeout);
return new ZooKeeper(host + ":" + port, timeout, this);
}
@@ -202,7 +201,7 @@
* @return the converted map, or an empty map if the given dictionary is null
*/
public static <K, V> Map<K, V> toMap(Dictionary<K, V> dict) {
- Map<K, V> map = new HashMap<K, V>();
+ Map<K, V> map = new HashMap<>();
if (dict != null) {
Enumeration<K> keys = dict.keys();
while (keys.hasMoreElements()) {
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
index 8f6f433..7f352a7 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListener.java
@@ -51,7 +51,7 @@
}
public void start(BundleContext bctx) {
- Dictionary<String, String> props = new Hashtable<String, String>();
+ Dictionary<String, String> props = new Hashtable<>();
String uuid = bctx.getProperty(Constants.FRAMEWORK_UUID);
props.put(EndpointEventListener.ENDPOINT_LISTENER_SCOPE,
String.format("(&(%s=*)(%s=%s))", Constants.OBJECTCLASS,
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/repository/ZookeeperEndpointRepository.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/repository/ZookeeperEndpointRepository.java
index a1d851f..c134f81 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/repository/ZookeeperEndpointRepository.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/repository/ZookeeperEndpointRepository.java
@@ -54,7 +54,7 @@
private EndpointEventListener listener;
public static final String PATH_PREFIX = "/osgi/service_registry";
- private Map<String, EndpointDescription> nodes = new ConcurrentHashMap<String, EndpointDescription>();
+ private Map<String, EndpointDescription> nodes = new ConcurrentHashMap<>();
public ZookeeperEndpointRepository(ZooKeeper zk) {
this(zk, null);
@@ -118,7 +118,7 @@
* elements of the original array in the same order
*/
public static List<String> removeEmpty(List<String> strings) {
- List<String> result = new ArrayList<String>();
+ List<String> result = new ArrayList<>();
if (strings == null) {
return result;
}
@@ -186,12 +186,8 @@
String childPath = (path.endsWith("/") ? path : path + "/") + child;
watchRecursive(childPath);
}
- } catch (NoNodeException e) {
- // Happens when a node was removed
- LOG.debug(e.getMessage(), e);
- } catch (ConnectionLossException e) {
- LOG.debug(e.getMessage(), e);
- } catch (SessionExpiredException e) {
+ } catch (NoNodeException | SessionExpiredException | ConnectionLossException e) {
+ // NoNodeException happens when a node was removed
LOG.debug(e.getMessage(), e);
} catch (Exception e) {
LOG.info(e.getMessage(), e);
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/Utils.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/Utils.java
index 67ea3a4..fd7d151 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/Utils.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/server/Utils.java
@@ -41,7 +41,7 @@
* @param dict a dictionary
*/
public static void removeEmptyValues(Dictionary<String, ?> dict) {
- List<String> keysToRemove = new ArrayList<String>();
+ List<String> keysToRemove = new ArrayList<>();
Enumeration<String> keys = dict.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
@@ -78,7 +78,7 @@
* @return the converted map, or an empty map if the given dictionary is null
*/
public static <K, V> Map<K, V> toMap(Dictionary<K, V> dict) {
- Map<K, V> map = new HashMap<K, V>();
+ Map<K, V> map = new HashMap<>();
if (dict != null) {
Enumeration<K> keys = dict.keys();
while (keys.hasMoreElements()) {
diff --git a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterestManager.java b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterestManager.java
index de177f7..6e92c78 100644
--- a/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterestManager.java
+++ b/discovery/zookeeper/src/main/java/org/apache/aries/rsa/discovery/zookeeper/subscribe/InterestManager.java
@@ -43,7 +43,7 @@
private static final Logger LOG = LoggerFactory.getLogger(InterestManager.class);
private final ZookeeperEndpointRepository repository;
- private final Map<ServiceReference, Interest> interests = new ConcurrentHashMap<ServiceReference, Interest>();
+ private final Map<ServiceReference, Interest> interests = new ConcurrentHashMap<>();
protected static class Interest {
List<String> scopes;
diff --git a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java
index bc138f7..e00e3c7 100644
--- a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java
+++ b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/ZookeeperDiscoveryTest.java
@@ -47,7 +47,7 @@
}
};
- Dictionary<String, Object> configuration = new Hashtable<String, Object>();
+ Dictionary<String, Object> configuration = new Hashtable<>();
zkd.updated(configuration);
}
@@ -65,7 +65,7 @@
}
};
- Dictionary<String, Object> configuration = new Hashtable<String, Object>();
+ Dictionary<String, Object> configuration = new Hashtable<>();
configuration.put("zookeeper.host", "myhost");
configuration.put("zookeeper.port", "1");
configuration.put("zookeeper.timeout", "1000");
diff --git a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
index 3fae691..3884c95 100644
--- a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
+++ b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/publish/PublishingEndpointListenerTest.java
@@ -77,7 +77,7 @@
}
private EndpointDescription createEndpoint() {
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
props.put(Constants.OBJECTCLASS, new String[] {"myClass"});
props.put(RemoteConstants.ENDPOINT_ID, "http://google.de:80/test/sub");
props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myConfig");
diff --git a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarterTest.java b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarterTest.java
index 02dce0c..8a03861 100644
--- a/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarterTest.java
+++ b/discovery/zookeeper/src/test/java/org/apache/aries/rsa/discovery/zookeeper/server/ZookeeperStarterTest.java
@@ -56,7 +56,7 @@
this.main = mockServer;
}
};
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put("clientPort", "1234");
starter.updated(props);
assertNotNull(starter.main);
diff --git a/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java b/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java
index d560a8f..19dc4e6 100644
--- a/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java
+++ b/eapub/src/main/java/org/apache/aries/rsa/eapub/EventAdminHelper.java
@@ -49,7 +49,7 @@
props.put("bundle.id", bctx.getBundle().getBundleId());
props.put("bundle.symbolicname", bctx.getBundle().getSymbolicName());
- String version = (String)bctx.getBundle().getHeaders().get("Bundle-Version");
+ String version = bctx.getBundle().getHeaders().get("Bundle-Version");
Version v = version != null ? new Version(version) : Version.emptyVersion;
setIfNotNull(props, "bundle.version", v);
@@ -60,7 +60,7 @@
public void remoteAdminEvent(RemoteServiceAdminEvent rsae) {
String topic = remoteServiceAdminEventTypeToString(rsae.getType());
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
setIfNotNull(props, "cause", rsae.getException());
EndpointDescription endpoint = null;
diff --git a/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java b/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
index e08a05f..d7d4458 100644
--- a/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
+++ b/eapub/src/test/java/org/apache/aries/rsa/eapub/EventAdminHelperTest.java
@@ -62,7 +62,7 @@
final Bundle bundle = EasyMock.createNiceMock(Bundle.class);
EasyMock.expect(bundle.getBundleId()).andReturn(42L).anyTimes();
EasyMock.expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes();
- Dictionary<String, String> headers = new Hashtable<String, String>();
+ Dictionary<String, String> headers = new Hashtable<>();
headers.put("Bundle-Version", "1.2.3.test");
EasyMock.expect(bundle.getHeaders()).andReturn(headers).anyTimes();
EasyMock.replay(bundle);
diff --git a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
index c70aa0a..346960d 100644
--- a/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
+++ b/itests/felix/src/test/java/org/apache/aries/rsa/itests/felix/RsaTestBase.java
@@ -71,13 +71,10 @@
}
protected int getFreePort() throws IOException {
- ServerSocket socket = new ServerSocket();
- try {
+ try (ServerSocket socket = new ServerSocket()) {
socket.setReuseAddress(true); // enables quickly reopening socket on same port
socket.bind(new InetSocketAddress(0)); // zero finds a free port
return socket.getLocalPort();
- } finally {
- socket.close();
}
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/BaseActivator.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/BaseActivator.java
index 890a471..98752c9 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/BaseActivator.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/BaseActivator.java
@@ -45,7 +45,7 @@
protected BundleContext bundleContext;
protected ExecutorService executor = new ThreadPoolExecutor(0, 1, 0L, TimeUnit.MILLISECONDS,
- new LinkedBlockingQueue<Runnable>());
+ new LinkedBlockingQueue<>());
private AtomicBoolean scheduled = new AtomicBoolean();
private long schedulerStopTimeout = TimeUnit.MILLISECONDS.convert(30, TimeUnit.SECONDS);
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java
index 4f7e38c..12fabb7 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/api/ProtobufSerializationStrategy.java
@@ -112,7 +112,7 @@
Throwable error;
try {
// try to build the exception...
- Constructor<?> ctr = loader.loadClass(className).getConstructor(new Class[]{String.class});
+ Constructor<?> ctr = loader.loadClass(className).getConstructor(String.class);
error = (Throwable) ctr.newInstance(message);
} catch (Throwable e) {
// fallback to something simple..
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AsyncFutureInvocationStrategy.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AsyncFutureInvocationStrategy.java
index 9af8ce0..ab7e6ce 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AsyncFutureInvocationStrategy.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/AsyncFutureInvocationStrategy.java
@@ -54,7 +54,7 @@
final Object[] args = new Object[types.length];
serializationStrategy.decodeRequest(loader, types, requestStream, args);
Future<Object> future = (Future<Object>)method.invoke(target, args);
- CompletableFuture<Object> completable = null;
+ CompletableFuture<Object> completable;
if(future instanceof CompletableFuture) {
completable = (CompletableFuture<Object>)future;
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java
index 521445c..3da1bdb 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ClientInvokerImpl.java
@@ -54,7 +54,7 @@
protected static final Logger LOGGER = LoggerFactory.getLogger(ClientInvokerImpl.class);
@SuppressWarnings("rawtypes")
- private final static Map<Class,String> CLASS_TO_PRIMITIVE = new HashMap<Class, String>(8, 1.0F);
+ private final static Map<Class,String> CLASS_TO_PRIMITIVE = new HashMap<>(8, 1.0F);
static {
CLASS_TO_PRIMITIVE.put(boolean.class,"Z");
@@ -69,9 +69,9 @@
protected final AtomicLong correlationGenerator = new AtomicLong();
protected final DispatchQueue queue;
- protected final Map<String, TransportPool> transports = new HashMap<String, TransportPool>();
+ protected final Map<String, TransportPool> transports = new HashMap<>();
protected final AtomicBoolean running = new AtomicBoolean(false);
- protected final Map<Long, ResponseFuture> requests = new HashMap<Long, ResponseFuture>();
+ protected final Map<Long, ResponseFuture> requests = new HashMap<>();
protected final long timeout;
protected final Map<String, SerializationStrategy> serializationStrategies;
@@ -156,7 +156,7 @@
}
}
- static final WeakHashMap<Method, MethodData> method_cache = new WeakHashMap<Method, MethodData>();
+ static final WeakHashMap<Method, MethodData> method_cache = new WeakHashMap<>();
static class MethodData {
private final SerializationStrategy serializationStrategy;
@@ -171,7 +171,7 @@
}
private MethodData getMethodData(Method method) throws IOException {
- MethodData rc = null;
+ MethodData rc;
synchronized (method_cache) {
rc = method_cache.get(method);
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java
index 7724f9e..f1589a1 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodec.java
@@ -40,7 +40,7 @@
final int write_buffer_size = 1024 * 64;
long write_counter = 0L;
WritableByteChannel write_channel;
- final Queue<ByteBuffer> next_write_buffers = new LinkedList<ByteBuffer>();
+ final Queue<ByteBuffer> next_write_buffers = new LinkedList<>();
int next_write_size = 0;
public boolean full() {
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java
index 2534268..cce0616 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/ServerInvokerImpl.java
@@ -54,7 +54,7 @@
public class ServerInvokerImpl implements ServerInvoker, Dispatched {
protected static final Logger LOGGER = LoggerFactory.getLogger(ServerInvokerImpl.class);
- static private final HashMap<String, Class> PRIMITIVE_TO_CLASS = new HashMap<String, Class>(8, 1.0F);
+ static private final HashMap<String, Class> PRIMITIVE_TO_CLASS = new HashMap<>(8, 1.0F);
static {
PRIMITIVE_TO_CLASS.put("Z", boolean.class);
PRIMITIVE_TO_CLASS.put("B", byte.class);
@@ -70,7 +70,7 @@
protected final DispatchQueue queue;
private final Map<String, SerializationStrategy> serializationStrategies;
protected final TransportServer server;
- protected final Map<UTF8Buffer, ServiceFactoryHolder> holders = new HashMap<UTF8Buffer, ServiceFactoryHolder>();
+ protected final Map<UTF8Buffer, ServiceFactoryHolder> holders = new HashMap<>();
private StreamProvider streamProvider;
static class MethodData {
@@ -91,7 +91,7 @@
private final ServiceFactory factory;
private final ClassLoader loader;
private final Class clazz;
- private HashMap<Buffer, MethodData> method_cache = new HashMap<Buffer, MethodData>();
+ private HashMap<Buffer, MethodData> method_cache = new HashMap<>();
public ServiceFactoryHolder(ServiceFactory factory, ClassLoader loader) {
this.factory = factory;
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
index 7f6c4a2..0816702 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransport.java
@@ -587,7 +587,7 @@
reduction = remaining - read_allowance;
dst.limit(dst.limit() - reduction);
}
- int rc=0;
+ int rc;
try {
rc = channel.read(dst);
read_allowance -= rc;
@@ -620,7 +620,7 @@
reduction = remaining - write_allowance;
src.limit(src.limit() - reduction);
}
- int rc = 0;
+ int rc;
try {
rc = channel.write(src);
write_allowance -= rc;
@@ -662,7 +662,7 @@
//
public static abstract class State {
- LinkedList<Runnable> callbacks = new LinkedList<Runnable>();
+ LinkedList<Runnable> callbacks = new LinkedList<>();
void add(Runnable r) {
if (r != null) {
@@ -784,7 +784,7 @@
}
class CANCELING extends SocketState {
- private LinkedList<Runnable> runnables = new LinkedList<Runnable>();
+ private LinkedList<Runnable> runnables = new LinkedList<>();
private int remaining;
private boolean dispose;
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportFactory.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportFactory.java
index 97c4cd1..3fc7199 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportFactory.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportFactory.java
@@ -43,7 +43,7 @@
TcpTransportServer server = createTcpTransportServer(uri);
if (server == null) return null;
- Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(uri));
+ Map<String, String> options = new HashMap<>(URISupport.parseParameters(uri));
IntrospectionSupport.setProperties(server, options);
Map<String, Object> transportOptions = IntrospectionSupport.extractProperties(options, "transport.");
server.setTransportOption(transportOptions);
@@ -56,7 +56,7 @@
TcpTransport transport = createTransport(uri);
if (transport == null) return null;
- Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(uri));
+ Map<String, String> options = new HashMap<>(URISupport.parseParameters(uri));
URI localLocation = getLocalLocation(uri);
transport.connecting(uri, localLocation);
@@ -106,7 +106,7 @@
if (path != null && path.length() > 0) {
int localPortIndex = path.indexOf(':');
try {
- Integer.parseInt(path.substring(localPortIndex + 1, path.length()));
+ Integer.parseInt(path.substring(localPortIndex + 1));
String localString = location.getScheme() + ":/" + path;
localLocation = new URI(localString);
} catch (Exception e) {
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java
index d4a2805..d7771e7 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TcpTransportServer.java
@@ -190,7 +190,7 @@
}
protected final void handleSocket(SocketChannel socket) throws Exception {
- HashMap<String, Object> options = new HashMap<String, Object>();
+ HashMap<String, Object> options = new HashMap<>();
// options.put("maxInactivityDuration", Long.valueOf(maxInactivityDuration));
// options.put("maxInactivityDurationInitalDelay", Long.valueOf(maxInactivityDurationInitalDelay));
// options.put("trace", Boolean.valueOf(trace));
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TransportPool.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TransportPool.java
index f5dd597..fa61d4c 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TransportPool.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/tcp/TransportPool.java
@@ -46,8 +46,8 @@
protected final String uri;
protected final DispatchQueue queue;
- protected final LinkedList<Pair> pending = new LinkedList<Pair>();
- protected final Map<Transport, TransportState> transports = new HashMap<Transport, TransportState>();
+ protected final LinkedList<Pair> pending = new LinkedList<>();
+ protected final Map<Transport, TransportState> transports = new HashMap<>();
protected AtomicBoolean running = new AtomicBoolean(false);
protected int poolSize;
@@ -191,7 +191,7 @@
public TransportState() {
time = 0;
- inflight = new HashSet<Object>();
+ inflight = new HashSet<>();
}
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/ClassLoaderObjectInputStream.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/ClassLoaderObjectInputStream.java
index 3227d9f..8b83043 100644
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/ClassLoaderObjectInputStream.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/ClassLoaderObjectInputStream.java
@@ -29,7 +29,7 @@
public class ClassLoaderObjectInputStream extends ObjectInputStream {
/** <p>Maps primitive type names to corresponding class objects.</p> */
- private static final HashMap<String, Class> primClasses = new HashMap<String, Class>(8, 1.0F);
+ private static final HashMap<String, Class> primClasses = new HashMap<>(8, 1.0F);
private ClassLoader classLoader;
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
index b95ca8e..72b94bb 100755
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/IntrospectionSupport.java
@@ -54,16 +54,15 @@
Class<?> clazz = target.getClass();
Method[] methods = clazz.getMethods();
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
+ for (Method method : methods) {
String name = method.getName();
Class<?> type = method.getReturnType();
- Class<?> params[] = method.getParameterTypes();
+ Class<?>[] params = method.getParameterTypes();
if ((name.startsWith("is") || name.startsWith("get")) && params.length == 0 && type != null && isSettableType(type)) {
try {
- Object value = method.invoke(target, new Object[] {});
+ Object value = method.invoke(target);
if (value == null) {
continue;
}
@@ -74,10 +73,10 @@
}
if (name.startsWith("get")) {
name = name.substring(3, 4).toLowerCase()
- + name.substring(4);
+ + name.substring(4);
} else {
name = name.substring(2, 3).toLowerCase()
- + name.substring(3);
+ + name.substring(3);
}
props.put(optionPrefix + name, strValue);
rc = true;
@@ -119,7 +118,7 @@
throw new IllegalArgumentException("props was null.");
}
- HashMap<String, Object> rc = new HashMap<String, Object>(props.size());
+ HashMap<String, Object> rc = new HashMap<>(props.size());
for (Iterator<Entry> iter = props.entrySet().iterator(); iter.hasNext();) {
Entry entry = iter.next();
@@ -175,10 +174,10 @@
// If the type is null or it matches the needed type, just use the
// value directly
if (value == null || value.getClass() == setter.getParameterTypes()[0]) {
- setter.invoke(target, new Object[] {value});
+ setter.invoke(target, value);
} else {
// We need to convert it
- setter.invoke(target, new Object[] {convert(value, setter.getParameterTypes()[0])});
+ setter.invoke(target, convert(value, setter.getParameterTypes()[0]));
}
return true;
} catch (Throwable ignore) {
@@ -220,10 +219,9 @@
// Build the method name.
name = "set" + name.substring(0, 1).toUpperCase() + name.substring(1);
Method[] methods = clazz.getMethods();
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
- Class<?> params[] = method.getParameterTypes();
- if (method.getName().equals(name) && params.length == 1 ) {
+ for (Method method : methods) {
+ Class<?>[] params = method.getParameterTypes();
+ if (method.getName().equals(name) && params.length == 1) {
return method;
}
}
@@ -256,7 +254,7 @@
public static String toString(Object target, Class<?> stopClass, Map<String, Object> overrideFields, String ... fields) {
try {
- LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
+ LinkedHashMap<String, Object> map = new LinkedHashMap<>();
addFields(target, target.getClass(), stopClass, map);
if (overrideFields != null) {
for(String key : overrideFields.keySet()) {
@@ -270,7 +268,7 @@
}
boolean useMultiLine=false;
- LinkedHashMap<String, String> props = new LinkedHashMap<String, String>();
+ LinkedHashMap<String, String> props = new LinkedHashMap<>();
for (Entry<String, Object> entry : map.entrySet()) {
String key = entry.getKey();
String value = null;
@@ -283,7 +281,7 @@
props.put(key, value);
}
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
if( useMultiLine) {
buffer.append("{\n");
boolean first = true;
@@ -339,8 +337,7 @@
}
Field[] fields = startClass.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
+ for (Field field : fields) {
if (Modifier.isStatic(field.getModifiers())) {
continue;
}
diff --git a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/URISupport.java b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/URISupport.java
index 7874ad8..4e22b0e 100755
--- a/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/URISupport.java
+++ b/provider/fastbin/src/main/java/org/apache/aries/rsa/provider/fastbin/util/URISupport.java
@@ -67,7 +67,7 @@
}
public URI toURI() throws URISyntaxException {
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
if (scheme != null) {
sb.append(scheme);
sb.append(':');
@@ -104,17 +104,17 @@
public static Map<String, String> parseQuery(String uri) throws URISyntaxException {
try {
- Map<String, String> rc = new HashMap<String, String>();
+ Map<String, String> rc = new HashMap<>();
if (uri != null) {
String[] parameters = uri.split("&");
- for (int i = 0; i < parameters.length; i++) {
- int p = parameters[i].indexOf("=");
+ for (String parameter : parameters) {
+ int p = parameter.indexOf("=");
if (p >= 0) {
- String name = URLDecoder.decode(parameters[i].substring(0, p), "UTF-8");
- String value = URLDecoder.decode(parameters[i].substring(p + 1), "UTF-8");
+ String name = URLDecoder.decode(parameter.substring(0, p), "UTF-8");
+ String value = URLDecoder.decode(parameter.substring(p + 1), "UTF-8");
rc.put(name, value);
} else {
- rc.put(parameters[i], null);
+ rc.put(parameter, null);
}
}
}
@@ -216,7 +216,7 @@
* @return
*/
private static String[] splitComponents(String str) {
- List<String> l = new ArrayList<String>();
+ List<String> l = new ArrayList<>();
int last = 0;
int depth = 0;
@@ -264,7 +264,7 @@
public static String createQueryString(Map<String,String> options) throws URISyntaxException {
try {
if (options.size() > 0) {
- StringBuffer rc = new StringBuffer();
+ StringBuilder rc = new StringBuilder();
boolean first = true;
for (Map.Entry<String,String> entry : options.entrySet()) {
if (first) {
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/FutureInvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/FutureInvocationTest.java
index 9c49a1e..c8c348e 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/FutureInvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/FutureInvocationTest.java
@@ -60,7 +60,7 @@
public void setup() throws Exception
{
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
index bd918a8..832750f 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/InvocationTest.java
@@ -62,7 +62,7 @@
public void testInvoke() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -91,12 +91,12 @@
// of primitives / objects and array dimensions.
assertEquals('a', hello.mix(0));
assertEquals('b', hello.mix(new int[]{0}));
- assertEquals('c', hello.mix(new Integer(0)));
- assertEquals('d', hello.mix(new Integer[]{new Integer(0)}));
+ assertEquals('c', hello.mix(Integer.valueOf(0)));
+ assertEquals('d', hello.mix(new Integer[]{0}));
assertEquals('e', hello.mix(new int[0][0]));
assertEquals('f', hello.mix(new Integer[0][0]));
- AsyncCallbackFuture<String> future1 = new AsyncCallbackFuture<String>();
+ AsyncCallbackFuture<String> future1 = new AsyncCallbackFuture<>();
hello.hello("Hiram", future1);
assertEquals("Hello Hiram!", future1.get(2, TimeUnit.SECONDS));
@@ -121,7 +121,7 @@
public void testInvokeInvalidServiceID() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -169,7 +169,7 @@
public void testObjectMethods() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -205,7 +205,7 @@
public void testOverflowAsync() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -230,9 +230,9 @@
char[] chars = new char[65*1024];
String payload = new String(chars);
- final List<AsyncCallbackFuture<String>> futures = new ArrayList<AsyncCallbackFuture<String>>();
+ final List<AsyncCallbackFuture<String>> futures = new ArrayList<>();
for(int i = 0; i < 100; i++) {
- AsyncCallbackFuture<String> future = new AsyncCallbackFuture<String>();
+ AsyncCallbackFuture<String> future = new AsyncCallbackFuture<>();
hello.hello(payload, future);
futures.add(future);
}
@@ -255,7 +255,7 @@
public void testOverflow() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -324,7 +324,7 @@
public void testNoOverflow() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -361,7 +361,7 @@
@Test(timeout=30*1000)
public void testUnderLoadSyncObject() throws Exception {
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
DispatchQueue queue = Dispatch.createQueue();
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -427,9 +427,9 @@
final long end = System.nanoTime();
long latency_sum = 0;
- for (int t = 0; t < latencies.length; t++) {
- if( latencies[t] != -1 ) {
- latency_sum += latencies[t];
+ for (long latency : latencies) {
+ if (latency != -1) {
+ latency_sum += latency;
}
}
double latency_avg = ((latency_sum * 1.0d)/requests.get()) / MILLIS_IN_A_NANO;
@@ -514,7 +514,7 @@
@Test(timeout=30*1000)
public void testUnderLoadAsyncProto() throws Exception {
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
DispatchQueue queue = Dispatch.createQueue();
@@ -556,9 +556,9 @@
final long end = System.nanoTime();
long latency_sum = 0;
- for (int t = 0; t < latencies.length; t++) {
- if( latencies[t] != -1 ) {
- latency_sum += latencies[t];
+ for (long latency : latencies) {
+ if (latency != -1) {
+ latency_sum += latency;
}
}
double latency_avg = ((latency_sum * 1.0d)/requests.get()) / MILLIS_IN_A_NANO;
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/PromiseInvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/PromiseInvocationTest.java
index 7835f1f..6f44f01 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/PromiseInvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/PromiseInvocationTest.java
@@ -60,7 +60,7 @@
public void setup() throws Exception
{
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
@@ -142,14 +142,14 @@
@Override
public Promise<String> helloPromise() {
- final Deferred<String> deferred = new Deferred<String>();
+ final Deferred<String> deferred = new Deferred<>();
new Thread(() -> deferred.resolve("Hello")).start();
return deferred.getPromise();
}
@Override
public Promise<String> exceptionPromise() throws IOException {
- final Deferred<String> deferred = new Deferred<String>();
+ final Deferred<String> deferred = new Deferred<>();
new Thread(() -> {
sleep(500);
deferred.fail(new IOException("test"));
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java
index c8f217d..59b518d 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/StreamInvocationTest.java
@@ -60,7 +60,7 @@
public void setup() throws Exception
{
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
server.start();
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/TransportFailureTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/TransportFailureTest.java
index 151de05..cb9aec4 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/TransportFailureTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/TransportFailureTest.java
@@ -50,7 +50,7 @@
public void testInvoke() throws Exception {
DispatchQueue queue = Dispatch.createQueue();
- HashMap<String, SerializationStrategy> map = new HashMap<String, SerializationStrategy>();
+ HashMap<String, SerializationStrategy> map = new HashMap<>();
map.put("protobuf", new ProtobufSerializationStrategy());
ServerInvokerImpl server = new ServerInvokerImpl("tcp://localhost:0", queue, map);
@@ -72,7 +72,7 @@
InvocationHandler handler = client.getProxy(server.getConnectAddress(), "service-id", HelloImpl.class.getClassLoader());
Hello hello = (Hello) Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), new Class[]{Hello.class}, handler);
- AsyncCallbackFuture<String> future1 = new AsyncCallbackFuture<String>();
+ AsyncCallbackFuture<String> future1 = new AsyncCallbackFuture<>();
hello.hello("Guillaume", future1);
long t0 = System.currentTimeMillis();
diff --git a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
index f440a72..e5aa03c 100644
--- a/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
+++ b/provider/fastbin/src/test/java/org/apache/aries/rsa/provider/fastbin/tcp/LengthPrefixedCodecTest.java
@@ -72,12 +72,12 @@
@Test
public void testGetWriteCounter() throws Exception {
- assertEquals(0l, codec.getWriteCounter());
+ assertEquals(0L, codec.getWriteCounter());
}
@Test
public void testGetReadCounter() throws Exception {
- assertEquals(0l, codec.getReadCounter());
+ assertEquals(0L, codec.getReadCounter());
}
@Test
@@ -89,7 +89,7 @@
assertEquals(BufferState.WAS_EMPTY, state);
assertEquals(false, codec.full());
assertEquals(false, codec.empty());
- assertEquals(0l, codec.getWriteCounter());
+ assertEquals(0L, codec.getWriteCounter());
}
@Test
@@ -103,7 +103,7 @@
assertEquals(BufferState.NOT_EMPTY, state);
assertEquals(false, codec.full());
assertEquals(false, codec.empty());
- assertEquals(0l, codec.getWriteCounter());
+ assertEquals(0L, codec.getWriteCounter());
}
@Test
diff --git a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
index 3f40bd8..95d6e90 100644
--- a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
+++ b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/LocalHostUtil.java
@@ -66,7 +66,7 @@
*/
private static InetAddress[] getAllLocalUsingNetworkInterface() throws UnknownHostException {
try {
- List<InetAddress> addresses = new ArrayList<InetAddress>();
+ List<InetAddress> addresses = new ArrayList<>();
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
while (e.hasMoreElements()) {
NetworkInterface ni = e.nextElement();
diff --git a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
index 4a4053a..5656a59 100644
--- a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
+++ b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/MethodInvoker.java
@@ -44,9 +44,8 @@
public Object invoke(String methodName, Object[] args) {
Class<?>[] parameterTypesAr = getTypes(args);
- Method method = null;
try {
- method = getMethod(methodName, parameterTypesAr);
+ Method method = getMethod(methodName, parameterTypesAr);
return method.invoke(service, args);
} catch (Throwable e) {
return e;
diff --git a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
index 8e78f4d..d230292 100644
--- a/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
+++ b/provider/tcp/src/main/java/org/apache/aries/rsa/provider/tcp/TcpInvocationHandler.java
@@ -82,7 +82,7 @@
}
private Object createPromiseResult(final Method method, final Object[] args) {
- final Deferred<Object> deferred = new Deferred<Object>();
+ final Deferred<Object> deferred = new Deferred<>();
new Thread(new Runnable() {
@Override
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/EndpointParserTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/EndpointParserTest.java
index 27a2399..554d995 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/EndpointParserTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/EndpointParserTest.java
@@ -35,7 +35,7 @@
@Before
public void defaultProps() {
- props = new Hashtable<String, Object>();
+ props = new Hashtable<>();
props.put("objectClass", new String[]{Runnable.class.getName()});
props.put(RemoteConstants.ENDPOINT_ID, "myid");
props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "any");
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java
index 1d7928c..e8b8d71 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderIntentTest.java
@@ -52,7 +52,7 @@
@Test
public void basicAndAsnycIntents() {
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
EndpointHelper.addObjectClass(props, exportedInterfaces);
String[] standardIntents = new String[] {"osgi.basic", "osgi.async"};
props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, standardIntents);
@@ -62,7 +62,7 @@
@Test
public void unknownIntent() {
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
EndpointHelper.addObjectClass(props, exportedInterfaces);
props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS, "unknown");
Endpoint ep = provider.exportService(myService, bc, props, exportedInterfaces);
@@ -71,7 +71,7 @@
@Test
public void unknownIntentExtra() {
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
EndpointHelper.addObjectClass(props, exportedInterfaces);
props.put(RemoteConstants.SERVICE_EXPORTED_INTENTS_EXTRA, "unknown");
Endpoint ep = provider.exportService(myService, bc, props, exportedInterfaces);
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
index 25ff6ea..9443baa 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderPrimitiveTest.java
@@ -57,7 +57,7 @@
public static void createServerAndProxy() {
Class<?>[] exportedInterfaces = new Class[] {PrimitiveService.class};
TCPProvider provider = new TCPProvider();
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
EndpointHelper.addObjectClass(props, exportedInterfaces);
props.put("aries.rsa.hostname", "localhost");
props.put("aries.rsa.numThreads", "10");
@@ -89,7 +89,7 @@
@Test
public void testLong() {
- Assert.assertEquals(1l, myServiceProxy.callLong(1l));
+ Assert.assertEquals(1L, myServiceProxy.callLong(1L));
}
@Test
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
index dc4737e..9f9143f 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/TcpProviderTest.java
@@ -68,7 +68,7 @@
public static void createServerAndProxy() {
Class<?>[] exportedInterfaces = new Class[] {MyService.class};
TCPProvider provider = new TCPProvider();
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
EndpointHelper.addObjectClass(props, exportedInterfaces);
props.put("aries.rsa.hostname", "localhost");
props.put("aries.rsa.numThreads", "10");
@@ -123,7 +123,7 @@
*/
@Test
public void testCallWithInterfaceBasedParam() throws IOException, InterruptedException {
- List<String> msgList = new ArrayList<String>();
+ List<String> msgList = new ArrayList<>();
myServiceProxy.callWithList(msgList);
}
diff --git a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
index a030c9e..3316a00 100644
--- a/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
+++ b/provider/tcp/src/test/java/org/apache/aries/rsa/provider/tcp/myservice/MyServiceImpl.java
@@ -84,7 +84,7 @@
@Override
public Promise<String> callAsyncPromise(final int delay) {
- final Deferred<String> deferred = new Deferred<String>();
+ final Deferred<String> deferred = new Deferred<>();
new Thread(new Runnable() {
@Override
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java b/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java
index b9aec0c..9b9c244 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/ClientServiceFactory.java
@@ -59,7 +59,7 @@
final ClassLoader consumerLoader = requestingBundle.adapt(BundleWiring.class).getClassLoader();
try {
LOG.debug("getService() from serviceFactory for {}", interfaceNames);
- final List<Class<?>> interfaces = new ArrayList<Class<?>>();
+ final List<Class<?>> interfaces = new ArrayList<>();
for (String ifaceName : interfaceNames) {
interfaces.add(consumerLoader.loadClass(ifaceName));
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
index a2d1192..942a965 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/DistributionProviderTracker.java
@@ -62,7 +62,7 @@
provider,
packageUtil);
RemoteServiceadminFactory rsaf = new RemoteServiceadminFactory(rsaCore);
- Dictionary<String, Object> props = new Hashtable<String, Object>();
+ Dictionary<String, Object> props = new Hashtable<>();
props.put(REMOTE_INTENTS_SUPPORTED, getPropertyNullSafe(reference, REMOTE_INTENTS_SUPPORTED));
props.put(REMOTE_CONFIGS_SUPPORTED, getPropertyNullSafe(reference, REMOTE_CONFIGS_SUPPORTED));
LOG.info("Registering RemoteServiceAdmin for provider " + provider.getClass().getName());
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java b/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java
index 86ebf5e..4ddf115 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/ImportRegistrationImpl.java
@@ -79,7 +79,7 @@
private void initParent() {
parent = this;
- children = new ArrayList<ImportRegistrationImpl>(1);
+ children = new ArrayList<>(1);
}
private void ensureParent() {
@@ -161,7 +161,7 @@
private List<ImportRegistrationImpl> copyChildren() {
synchronized (this) {
- return new ArrayList<ImportRegistrationImpl>(children);
+ return new ArrayList<>(children);
}
}
diff --git a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
index f5b6ef1..40c3f93 100644
--- a/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
+++ b/rsa/src/main/java/org/apache/aries/rsa/core/RemoteServiceAdminCore.java
@@ -60,10 +60,8 @@
private static final Logger LOG = LoggerFactory.getLogger(RemoteServiceAdminCore.class);
- private final Map<Map<String, Object>, Collection<ExportRegistration>> exportedServices
- = new LinkedHashMap<Map<String, Object>, Collection<ExportRegistration>>();
- private final Map<EndpointDescription, Collection<ImportRegistration>> importedServices
- = new LinkedHashMap<EndpointDescription, Collection<ImportRegistration>>();
+ private final Map<Map<String, Object>, Collection<ExportRegistration>> exportedServices = new LinkedHashMap<>();
+ private final Map<EndpointDescription, Collection<ImportRegistration>> importedServices = new LinkedHashMap<>();
// Is stored in exportedServices while the export is in progress as a marker
private final List<ExportRegistration> exportInProgress = Collections.emptyList();
@@ -170,7 +168,7 @@
if (!exportRegs.isEmpty()) {
// enlist initial export registrations in global list of exportRegistrations
synchronized (exportedServices) {
- exportedServices.put(key, new ArrayList<ExportRegistration>(exportRegs));
+ exportedServices.put(key, new ArrayList<>(exportRegs));
}
eventProducer.publishNotification(exportRegs);
}
@@ -300,7 +298,7 @@
throw new IllegalArgumentException("service is missing the service.exported.interfaces property");
}
- List<String> interfaces = new ArrayList<String>(1);
+ List<String> interfaces = new ArrayList<>(1);
if (exportedInterfaces.size() == 1 && "*".equals(exportedInterfaces.get(0))) {
// FIXME: according to the spec, this should only return the interfaces, and not
// non-interface classes (which are valid OBJECTCLASS values, even if discouraged)
@@ -330,7 +328,7 @@
private Map<String, Object> makeKey(Map<String, Object> properties) {
// FIXME: we should also make logically equal values actually compare as equal
// (e.g. String+ values should be normalized)
- Map<String, Object> converted = new HashMap<String, Object>(properties.size());
+ Map<String, Object> converted = new HashMap<>(properties.size());
for (Map.Entry<String, Object> entry : properties.entrySet()) {
Object val = entry.getValue();
// convert arrays into lists so that they can be compared via equals()
@@ -343,10 +341,10 @@
}
private List<ExportRegistration> copyExportRegistration(Collection<ExportRegistration> regs) {
- Set<EndpointDescription> copiedEndpoints = new HashSet<EndpointDescription>();
+ Set<EndpointDescription> copiedEndpoints = new HashSet<>();
// create a new list with copies of the exportRegistrations
- List<ExportRegistration> copy = new ArrayList<ExportRegistration>(regs.size());
+ List<ExportRegistration> copy = new ArrayList<>(regs.size());
for (ExportRegistration exportRegistration : regs) {
if (exportRegistration instanceof ExportRegistrationImpl) {
ExportRegistrationImpl exportRegistrationImpl = (ExportRegistrationImpl) exportRegistration;
@@ -375,7 +373,7 @@
@Override
public Collection<ExportReference> getExportedServices() {
synchronized (exportedServices) {
- List<ExportReference> ers = new ArrayList<ExportReference>();
+ List<ExportReference> ers = new ArrayList<>();
for (Collection<ExportRegistration> exportRegistrations : exportedServices.values()) {
for (ExportRegistration er : exportRegistrations) {
if (er.getExportReference() != null) {
@@ -390,7 +388,7 @@
@Override
public Collection<ImportReference> getImportedEndpoints() {
synchronized (importedServices) {
- List<ImportReference> irs = new ArrayList<ImportReference>();
+ List<ImportReference> irs = new ArrayList<>();
for (Collection<ImportRegistration> irl : importedServices.values()) {
for (ImportRegistration impl : irl) {
irs.add(impl.getImportReference());
@@ -436,7 +434,7 @@
ImportRegistrationImpl imReg = exposeServiceFactory(matchingInterfaces.toArray(new String[matchingInterfaces.size()]), endpoint, provider);
if (imRegs == null) {
- imRegs = new ArrayList<ImportRegistration>();
+ imRegs = new ArrayList<>();
importedServices.put(endpoint, imRegs);
}
imRegs.add(imReg);
@@ -448,7 +446,7 @@
private List<String> determineConfigTypesForImport(EndpointDescription endpoint) {
List<String> remoteConfigurationTypes = endpoint.getConfigurationTypes();
- List<String> usableConfigurationTypes = new ArrayList<String>();
+ List<String> usableConfigurationTypes = new ArrayList<>();
for (String ct : provider.getSupportedTypes()) {
if (remoteConfigurationTypes.contains(ct)) {
usableConfigurationTypes.add(ct);
@@ -468,7 +466,7 @@
ImportRegistrationImpl imReg = new ImportRegistrationImpl(epd, closeHandler, eventProducer);
try {
EndpointDescription endpoint = imReg.getImportedEndpointDescription();
- Dictionary<String, Object> serviceProps = new Hashtable<String, Object>(endpoint.getProperties());
+ Dictionary<String, Object> serviceProps = new Hashtable<>(endpoint.getProperties());
serviceProps.put(RemoteConstants.SERVICE_IMPORTED, true);
serviceProps.remove(RemoteConstants.SERVICE_EXPORTED_INTERFACES);
@@ -497,12 +495,10 @@
* @param sref the service whose exports should be removed and closed
*/
protected void removeServiceExports(ServiceReference<?> sref) {
- List<ExportRegistration> regs = new ArrayList<ExportRegistration>(1);
+ List<ExportRegistration> regs = new ArrayList<>(1);
synchronized (exportedServices) {
- for (Iterator<Collection<ExportRegistration>> it = exportedServices.values().iterator(); it.hasNext();) {
- Collection<ExportRegistration> value = it.next();
- for (Iterator<ExportRegistration> it2 = value.iterator(); it2.hasNext();) {
- ExportRegistration er = it2.next();
+ for (Collection<ExportRegistration> value : exportedServices.values()) {
+ for (ExportRegistration er : value) {
if (er.getExportReference().getExportedService().equals(sref)) {
regs.add(er);
}
@@ -553,7 +549,7 @@
// remove all import registrations
protected void closeImportRegistrations() {
- Collection<ImportRegistration> copy = new ArrayList<ImportRegistration>();
+ Collection<ImportRegistration> copy = new ArrayList<>();
synchronized (importedServices) {
for (Collection<ImportRegistration> irs : importedServices.values()) {
copy.addAll(irs);
@@ -566,7 +562,7 @@
private List<ExportRegistration> getExportsForBundle(Bundle exportingBundle) {
synchronized (exportedServices) {
- List<ExportRegistration> bundleRegs = new ArrayList<ExportRegistration>();
+ List<ExportRegistration> bundleRegs = new ArrayList<>();
for (Collection<ExportRegistration> regs : exportedServices.values()) {
if (!regs.isEmpty()) {
ExportRegistration exportRegistration = regs.iterator().next();
@@ -613,7 +609,7 @@
static void overlayProperties(Map<String, Object> serviceProperties,
Map<String, Object> additionalProperties) {
- Map<String, String> keysLowerCase = new HashMap<String, String>();
+ Map<String, String> keysLowerCase = new HashMap<>();
for (String key : serviceProperties.keySet()) {
keysLowerCase.put(key.toLowerCase(), key);
}
@@ -647,7 +643,7 @@
*/
private Map<String, Object> getProperties(ServiceReference<?> serviceReference) {
String[] keys = serviceReference.getPropertyKeys();
- Map<String, Object> props = new HashMap<String, Object>(keys.length);
+ Map<String, Object> props = new HashMap<>(keys.length);
for (String key : keys) {
Object val = serviceReference.getProperty(key);
props.put(key, val);
@@ -657,7 +653,7 @@
protected Map<String, Object> createEndpointProps(Map<String, Object> effectiveProps,
Class<?>[] ifaces) {
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
copyEndpointProperties(effectiveProps, props);
props.remove(org.osgi.framework.Constants.SERVICE_ID);
EndpointHelper.addObjectClass(props, ifaces);
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
index 5c83b7f..fcee597 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/ClientServiceFactoryTest.java
@@ -82,7 +82,7 @@
}
private EndpointDescription createTestEndpointDesc() {
- Map<String, Object> map = new HashMap<String, Object>();
+ Map<String, Object> map = new HashMap<>();
map.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
map.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "myGreatConfiguration");
map.put(Constants.OBJECTCLASS, new String[]{String.class.getName()});
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
index 9b784cc..cb4ea81 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/OverlayPropertiesTest.java
@@ -33,8 +33,8 @@
@Test
public void testOverlayProperties() {
- Map<String, Object> sProps = new HashMap<String, Object>();
- Map<String, Object> aProps = new HashMap<String, Object>();
+ Map<String, Object> sProps = new HashMap<>();
+ Map<String, Object> aProps = new HashMap<>();
RemoteServiceAdminCore.overlayProperties(sProps, aProps);
assertEquals(0, sProps.size());
@@ -49,7 +49,7 @@
aProps.put(Constants.OBJECTCLASS, new String[] {"Y"});
aProps.put(Constants.SERVICE_ID.toUpperCase(), 51L);
- Map<String, Object> aPropsOrg = new HashMap<String, Object>(aProps);
+ Map<String, Object> aPropsOrg = new HashMap<>(aProps);
RemoteServiceAdminCore.overlayProperties(sProps, aProps);
assertEquals("The additional properties should not be modified", aPropsOrg, aProps);
@@ -65,16 +65,16 @@
@Test
public void testOverlayProperties2() {
- Map<String, Object> original = new HashMap<String, Object>();
+ Map<String, Object> original = new HashMap<>();
original.put("MyProp", "my value");
original.put(Constants.OBJECTCLASS, "myClass");
- Map<String, Object> copy = new HashMap<String, Object>();
+ Map<String, Object> copy = new HashMap<>();
copy.putAll(original);
// nothing should change here
- Map<String, Object> overload = new HashMap<String, Object>();
+ Map<String, Object> overload = new HashMap<>();
RemoteServiceAdminCore.overlayProperties(copy, overload);
assertEquals(original.size(), copy.size());
@@ -86,7 +86,7 @@
copy.putAll(original);
// a property should be added
- overload = new HashMap<String, Object>();
+ overload = new HashMap<>();
overload.put("new", "prop");
RemoteServiceAdminCore.overlayProperties(copy, overload);
@@ -102,7 +102,7 @@
copy.putAll(original);
// only one property should be added
- overload = new HashMap<String, Object>();
+ overload = new HashMap<>();
overload.put("new", "prop");
overload.put("NEW", "prop");
@@ -119,7 +119,7 @@
copy.putAll(original);
// nothing should change here
- overload = new HashMap<String, Object>();
+ overload = new HashMap<>();
overload.put(Constants.OBJECTCLASS, "assd");
overload.put(Constants.SERVICE_ID, "asasdasd");
RemoteServiceAdminCore.overlayProperties(copy, overload);
@@ -133,7 +133,7 @@
copy.putAll(original);
// overwrite own prop
- overload = new HashMap<String, Object>();
+ overload = new HashMap<>();
overload.put("MyProp", "newValue");
RemoteServiceAdminCore.overlayProperties(copy, overload);
@@ -149,7 +149,7 @@
copy.putAll(original);
// overwrite own prop in different case
- overload = new HashMap<String, Object>();
+ overload = new HashMap<>();
overload.put("MYPROP", "newValue");
RemoteServiceAdminCore.overlayProperties(copy, overload);
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
index c6f3378..ae56296 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/RemoteServiceAdminCoreTest.java
@@ -172,7 +172,7 @@
c.replay();
- Map<String, Object> p = new HashMap<String, Object>();
+ Map<String, Object> p = new HashMap<>();
p.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
p.put(Constants.OBJECTCLASS, new String[] {
"es.schaaf.my.class",
@@ -204,7 +204,7 @@
@Test
public void testExport() throws Exception {
- final Map<String, Object> sProps = new HashMap<String, Object>();
+ final Map<String, Object> sProps = new HashMap<>();
sProps.put("objectClass", new String[] {"java.lang.Runnable"});
sProps.put("service.id", 51L);
sProps.put("myProp", "myVal");
@@ -253,7 +253,7 @@
@Test
public void testExportWrongConfig() throws Exception {
- final Map<String, Object> sProps = new HashMap<String, Object>();
+ final Map<String, Object> sProps = new HashMap<>();
sProps.put("objectClass", new String[] {"java.lang.Runnable"});
sProps.put("service.id", 51L);
sProps.put("myProp", "myVal");
@@ -271,7 +271,7 @@
@Test
public void testExportOneConfigSupported() throws Exception {
- final Map<String, Object> sProps = new HashMap<String, Object>();
+ final Map<String, Object> sProps = new HashMap<>();
sProps.put("objectClass", new String[] {"java.lang.Runnable"});
sProps.put("service.id", 51L);
sProps.put("myProp", "myVal");
@@ -290,7 +290,7 @@
@Test
public void testExportException() throws Exception {
- final Map<String, Object> sProps = new HashMap<String, Object>();
+ final Map<String, Object> sProps = new HashMap<>();
sProps.put("objectClass", new String[] {"java.lang.Runnable"});
sProps.put("service.id", 51L);
sProps.put("service.exported.interfaces", "*");
@@ -311,7 +311,7 @@
@Test
public void testCreateEndpointProps() {
c.replay();
- Map<String, Object> sd = new HashMap<String, Object>();
+ Map<String, Object> sd = new HashMap<>();
sd.put(org.osgi.framework.Constants.SERVICE_ID, 42);
Map<String, Object> props = rsaCore.createEndpointProps(sd, new Class[]{String.class});
@@ -325,7 +325,7 @@
}
private Endpoint createEndpoint(final Map<String, Object> sProps) throws IOException {
- Map<String, Object> eProps = new HashMap<String, Object>(sProps);
+ Map<String, Object> eProps = new HashMap<>(sProps);
eProps.put("endpoint.id", "http://something");
eProps.put("service.imported.configs", new String[] {MYCONFIG});
final EndpointDescription epd = new EndpointDescription(eProps);
@@ -340,7 +340,7 @@
Bundle b = c.createMock(Bundle.class);
expect(b.getBundleContext()).andReturn(bc).anyTimes();
expect(b.getSymbolicName()).andReturn("rsabundle").anyTimes();
- expect(b.getBundleId()).andReturn(10l).anyTimes();
+ expect(b.getBundleId()).andReturn(10L).anyTimes();
expect(b.getVersion()).andReturn(new Version("1.0.0")).anyTimes();
expect(b.getHeaders()).andReturn(new Hashtable<String, String>()).anyTimes();
return b;
@@ -368,7 +368,7 @@
}
private EndpointDescription creatEndpointDesc(String configType) {
- Map<String, Object> p = new HashMap<String, Object>();
+ Map<String, Object> p = new HashMap<>();
p.put(RemoteConstants.ENDPOINT_ID, "http://google.de");
p.put(Constants.OBJECTCLASS, new String[] {
"es.schaaf.my.class"
diff --git a/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java b/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java
index 1f8cc66..211a1bb 100644
--- a/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java
+++ b/rsa/src/test/java/org/apache/aries/rsa/core/event/EventProducerTest.java
@@ -115,7 +115,7 @@
final Bundle bundle = c.createMock(Bundle.class);
expect(bundle.getBundleId()).andReturn(42L).anyTimes();
expect(bundle.getSymbolicName()).andReturn("test.bundle").anyTimes();
- Dictionary<String, String> headers = new Hashtable<String, String>();
+ Dictionary<String, String> headers = new Hashtable<>();
headers.put("Bundle-Version", "1.2.3.test");
expect(bundle.getHeaders()).andReturn(headers).anyTimes();
return bundle;
diff --git a/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java b/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java
index c57e656..07a8697 100644
--- a/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java
+++ b/spi/src/main/java/org/apache/aries/rsa/util/EndpointHelper.java
@@ -32,7 +32,7 @@
}
public static String[] getClassNames(Class<?>[] ifaces) {
- List<String> ifaceNames = new ArrayList<String>();
+ List<String> ifaceNames = new ArrayList<>();
for (Class<?> iface : ifaces) {
ifaceNames.add(iface.getName());
}
diff --git a/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java b/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java
index bff9503..ea33955 100644
--- a/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java
+++ b/spi/src/main/java/org/apache/aries/rsa/util/StringPlus.java
@@ -39,7 +39,7 @@
if (object instanceof String) {
String s = (String)object;
String[] values = s.split(",");
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
for (String val : values) {
String actualValue = val.trim();
if (!actualValue.isEmpty()) {
@@ -55,7 +55,7 @@
if (object instanceof Collection) {
Collection col = (Collection)object;
- List<String> ar = new ArrayList<String>(col.size());
+ List<String> ar = new ArrayList<>(col.size());
for (Object o : col) {
if (o instanceof String) {
String s = (String)o;
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/Activator.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/Activator.java
index 5658e5e..8568a5f 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/Activator.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/Activator.java
@@ -60,7 +60,7 @@
private EndpointEventListenerTracker epeListenerTracker;
public void start(final BundleContext bc) throws Exception {
- Dictionary<String, String> props = new Hashtable<String, String>();
+ Dictionary<String, String> props = new Hashtable<>();
props.put("name", "default");
bc.registerService(ExportPolicy.class, new DefaultExportPolicy(), props);
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java
index b816306..540f5eb 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifier.java
@@ -48,7 +48,7 @@
private Map<EndpointEventListener, Set<Filter>> listeners;
public EndpointListenerNotifier() {
- this.listeners = new ConcurrentHashMap<EndpointEventListener, Set<Filter>>();
+ this.listeners = new ConcurrentHashMap<>();
}
public static Set<Filter> filtersFromEL(ServiceReference<EndpointListener> sref) {
@@ -62,7 +62,7 @@
}
private static Set<Filter> getFilterSet(List<String> scopes) {
- Set<Filter> filters = new HashSet<Filter>();
+ Set<Filter> filters = new HashSet<>();
for (String scope : scopes) {
try {
filters.add(FrameworkUtil.createFilter(scope));
@@ -109,11 +109,11 @@
}
private static Set<Filter> getMatchingFilters(Set<Filter> filters, EndpointDescription endpoint) {
- Set<Filter> matchingFilters = new HashSet<Filter>();
+ Set<Filter> matchingFilters = new HashSet<>();
if (endpoint == null) {
return matchingFilters;
}
- Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
+ Dictionary<String, Object> dict = new Hashtable<>(endpoint.getProperties());
for (Filter filter : filters) {
if (filter.match(dict)) {
LOG.debug("Filter {} matches endpoint {}", filter, dict);
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java
index 3676844..c41c824 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/exporter/ServiceExportsRepository.java
@@ -105,7 +105,7 @@
}
public synchronized void addService(ServiceReference<?> sref, Collection<ExportRegistration> exports) {
- List<ExportRegistrationHolder> holderList = new ArrayList<ExportRegistrationHolder>(exports.size());
+ List<ExportRegistrationHolder> holderList = new ArrayList<>(exports.size());
exportsMap.put(sref, holderList);
for (ExportRegistration reg : exports) {
ExportReference exportReference = reg.getExportReference();
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
index 23e0544..1761d61 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/TopologyManagerImport.java
@@ -56,17 +56,15 @@
/**
* List of Endpoints by matched filter that were reported by the EndpointListener and can be imported
*/
- private final MultiMap<EndpointDescription> importPossibilities
- = new MultiMap<EndpointDescription>();
+ private final MultiMap<EndpointDescription> importPossibilities = new MultiMap<>();
/**
* List of already imported Endpoints by their matched filter
*/
- private final MultiMap<ImportRegistration> importedServices
- = new MultiMap<ImportRegistration>();
+ private final MultiMap<ImportRegistration> importedServices = new MultiMap<>();
public TopologyManagerImport(BundleContext bc) {
- this.rsaSet = new HashSet<RemoteServiceAdmin>();
+ this.rsaSet = new HashSet<>();
bctx = bc;
execService = new ThreadPoolExecutor(5, 10, 50, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
}
@@ -189,7 +187,7 @@
}
private void unImport(ImportReference ref) {
- List<ImportRegistration> removed = new ArrayList<ImportRegistration>();
+ List<ImportRegistration> removed = new ArrayList<>();
HashSet<String> imported = new HashSet<>(importedServices.keySet());
for (String key : imported) {
for (ImportRegistration ir : importedServices.get(key)) {
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java
index 084e927..9376cb4 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/EndpointListenerManager.java
@@ -69,7 +69,7 @@
private final BundleContext bctx;
private volatile ServiceRegistration<?> serviceRegistration;
- private final List<String> filters = new ArrayList<String>();
+ private final List<String> filters = new ArrayList<>();
private final EndpointEventListener endpointListener;
private final ListenerHookImpl listenerHook;
private RSFindHook findHook;
@@ -77,7 +77,7 @@
/**
* Count service interest by filter. This allows to modify the scope of the EndpointListener as seldom as possible
*/
- private final ReferenceCounter<String> importInterestsCounter = new ReferenceCounter<String>();
+ private final ReferenceCounter<String> importInterestsCounter = new ReferenceCounter<>();
public EndpointListenerManager(BundleContext bc, EndpointEventListener endpointListener) {
this.bctx = bc;
@@ -125,7 +125,7 @@
}
private Dictionary<String, Object> getEELProperties() {
- Dictionary<String, Object> p = new Hashtable<String, Object>();
+ Dictionary<String, Object> p = new Hashtable<>();
p.put(EndpointEventListener.ENDPOINT_LISTENER_SCOPE, copyFilters());
return p;
}
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelper.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelper.java
index bf22558..e820107 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelper.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/FilterHelper.java
@@ -44,7 +44,7 @@
private static final Set<String> SYSTEM_PACKAGES;
static {
- SYSTEM_PACKAGES = new HashSet<String>();
+ SYSTEM_PACKAGES = new HashSet<>();
SYSTEM_PACKAGES.add("org.osgi.service");
SYSTEM_PACKAGES.add("org.apache.felix");
SYSTEM_PACKAGES.add("org.ops4j.pax.logging");
diff --git a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounter.java b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounter.java
index a224b8b..0860c77 100644
--- a/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounter.java
+++ b/topology-manager/src/main/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounter.java
@@ -28,7 +28,7 @@
*/
public class ReferenceCounter<K> {
- private final ConcurrentMap<K, Integer> counts = new ConcurrentHashMap<K, Integer>();
+ private final ConcurrentMap<K, Integer> counts = new ConcurrentHashMap<>();
/**
* Increases the reference count for the given key,
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
index bc3c084..116c7b7 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/EndpointListenerNotifierTest.java
@@ -98,7 +98,7 @@
}
private EndpointDescription createEndpoint(String iface) {
- Map<String, Object> props = new Hashtable<String, Object>();
+ Map<String, Object> props = new Hashtable<>();
props.put("objectClass", new String[]{iface});
props.put(RemoteConstants.ENDPOINT_ID, iface);
props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "any");
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java
index 56c09d1..8100677 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/exporter/TopologyManagerExportTest.java
@@ -161,7 +161,7 @@
}
private EndpointDescription createEndpoint() {
- Map<String, Object> props = new HashMap<String, Object>();
+ Map<String, Object> props = new HashMap<>();
props.put(RemoteConstants.ENDPOINT_ID, "1");
props.put(Constants.OBJECTCLASS, new String[] {"abc"});
props.put(RemoteConstants.SERVICE_IMPORTED_CONFIGS, "cxf");
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ListenerHookImplTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ListenerHookImplTest.java
index 07df9d6..ee85fb9 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ListenerHookImplTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ListenerHookImplTest.java
@@ -48,7 +48,7 @@
Filter f = FrameworkUtil.createFilter(filter);
- Dictionary<String, String> m = new Hashtable<String, String>();
+ Dictionary<String, String> m = new Hashtable<>();
m.put("a", "b");
assertTrue(filter + " filter must match as uuid is missing", f.match(m));
m.put(RemoteConstants.ENDPOINT_FRAMEWORK_UUID, "MyUUID");
diff --git a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounterTest.java b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounterTest.java
index e1cba7d..711396e 100644
--- a/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounterTest.java
+++ b/topology-manager/src/test/java/org/apache/aries/rsa/topologymanager/importer/local/ReferenceCounterTest.java
@@ -28,7 +28,7 @@
@Test
public void testCounter() {
- ReferenceCounter<String> counter = new ReferenceCounter<String>();
+ ReferenceCounter<String> counter = new ReferenceCounter<>();
assertEquals(-1, counter.remove("a"));
assertEquals(-1, counter.remove("a"));
assertEquals(1, counter.add("a"));