Repository: karaf
Updated Branches:
  refs/heads/master 1c63a097e -> 3610b1dd8


[KARAF-2942] A couple more features/core JDK7 enhancement

Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/aa729204
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/aa729204
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/aa729204

Branch: refs/heads/master
Commit: aa729204dee764c247387d1115e47b68f79a34a0
Parents: 1c63a09
Author: Guillaume Nodet <gno...@gmail.com>
Authored: Fri Apr 25 16:47:05 2014 +0200
Committer: Guillaume Nodet <gno...@gmail.com>
Committed: Fri Apr 25 17:06:19 2014 +0200

----------------------------------------------------------------------
 .../karaf/features/internal/osgi/Activator.java       |  8 ++++----
 .../internal/service/FeaturesServiceImpl.java         |  7 +++++--
 .../karaf/features/internal/service/StateStorage.java | 14 +++++++-------
 3 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/aa729204/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
----------------------------------------------------------------------
diff --git 
a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
 
b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
index 4066dfa..8dbbf7c 100644
--- 
a/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
+++ 
b/features/core/src/main/java/org/apache/karaf/features/internal/osgi/Activator.java
@@ -94,7 +94,7 @@ public class Activator extends BaseActivator {
                 logger.warn("Error reading configuration file " + 
configFile.toString(), e);
             }
         }
-        Dictionary<String, String> props = new Hashtable<String, String>();
+        Dictionary<String, String> props = new Hashtable<>();
         for (Map.Entry<String, String> entry : configuration.entrySet()) {
             props.put(entry.getKey(), entry.getValue());
         }
@@ -126,11 +126,11 @@ public class Activator extends BaseActivator {
 
 
         FeatureFinder featureFinder = new FeatureFinder();
-        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        Hashtable<String, Object> props = new Hashtable<>();
         props.put(Constants.SERVICE_PID, FEATURES_REPOS_PID);
         register(ManagedService.class, featureFinder, props);
 
-        List<Repository> repositories = new ArrayList<Repository>();
+        List<Repository> repositories = new ArrayList<>();
         String[] resourceRepositories = getString("resourceRepositories", 
"").split(",");
         for (String url : resourceRepositories) {
             url = url.trim();
@@ -192,7 +192,7 @@ public class Activator extends BaseActivator {
                                 globalRepository);
         register(FeaturesService.class, featuresService);
 
-        featuresListenerTracker = new ServiceTracker<FeaturesListener, 
FeaturesListener>(
+        featuresListenerTracker = new ServiceTracker<>(
                 bundleContext, FeaturesListener.class, new 
ServiceTrackerCustomizer<FeaturesListener, FeaturesListener>() {
             @Override
             public FeaturesListener 
addingService(ServiceReference<FeaturesListener> reference) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/aa729204/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index 054c615..33b066f 100644
--- 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -1210,8 +1210,11 @@ public class FeaturesServiceImpl implements 
FeaturesService {
                     Resource resource = entry.getValue();
                     String uri = getUri(resource);
                     print("  " + uri, verbose);
-                    InputStream is = getBundleInputStream(resource, providers);
-                    bundle.update(is);
+                    try (
+                        InputStream is = getBundleInputStream(resource, 
providers)
+                    ) {
+                        bundle.update(is);
+                    }
                     toStart.add(bundle);
                     BundleInfo bi = bundleInfos.get(rde.getKey()).get(uri);
                     if (bi != null && bi.getStartLevel() > 0) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/aa729204/features/core/src/main/java/org/apache/karaf/features/internal/service/StateStorage.java
----------------------------------------------------------------------
diff --git 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/StateStorage.java
 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/StateStorage.java
index a509a9d..8168994 100644
--- 
a/features/core/src/main/java/org/apache/karaf/features/internal/service/StateStorage.java
+++ 
b/features/core/src/main/java/org/apache/karaf/features/internal/service/StateStorage.java
@@ -55,7 +55,7 @@ public abstract class StateStorage {
             OutputStream os = getOutputStream()
         ) {
             if (os != null) {
-                Map<String, Object> json = new HashMap<String, Object>();
+                Map<String, Object> json = new HashMap<>();
                 json.put("bootDone", state.bootDone.get());
                 json.put("repositories", state.repositories);
                 json.put("features", state.requestedFeatures);
@@ -71,7 +71,7 @@ public abstract class StateStorage {
     protected abstract OutputStream getOutputStream() throws IOException;
 
     protected Map<String, Set<String>> toStringStringSetMap(Map<?,?> map) {
-        Map<String, Set<String>> nm = new HashMap<String, Set<String>>();
+        Map<String, Set<String>> nm = new HashMap<>();
         for (Map.Entry entry : map.entrySet()) {
             nm.put(entry.getKey().toString(), toStringSet((Collection) 
entry.getValue()));
         }
@@ -79,7 +79,7 @@ public abstract class StateStorage {
     }
 
     protected Map<String, Set<Long>> toStringLongSetMap(Map<?,?> map) {
-        Map<String, Set<Long>> nm = new HashMap<String, Set<Long>>();
+        Map<String, Set<Long>> nm = new HashMap<>();
         for (Map.Entry entry : map.entrySet()) {
             nm.put(entry.getKey().toString(), toLongSet((Collection) 
entry.getValue()));
         }
@@ -87,7 +87,7 @@ public abstract class StateStorage {
     }
 
     protected Set<String> toStringSet(Collection<?> col) {
-        Set<String> ns = new TreeSet<String>();
+        Set<String> ns = new TreeSet<>();
         for (Object o : col) {
             ns.add(o.toString());
         }
@@ -95,7 +95,7 @@ public abstract class StateStorage {
     }
 
     protected Set<Long> toLongSet(Collection<?> set) {
-        Set<Long> ns = new TreeSet<Long>();
+        Set<Long> ns = new TreeSet<>();
         for (Object o : set) {
             ns.add(toLong(o));
         }
@@ -103,7 +103,7 @@ public abstract class StateStorage {
     }
 
     protected Map<Long, Long> toLongLongMap(Map<?,?> map) {
-        Map<Long, Long> nm = new HashMap<Long, Long>();
+        Map<Long, Long> nm = new HashMap<>();
         for (Map.Entry entry : map.entrySet()) {
             nm.put(toLong(entry.getKey()), toLong(entry.getValue()));
         }
@@ -111,7 +111,7 @@ public abstract class StateStorage {
     }
 
     protected Map<String, Long> toStringLongMap(Map<?,?> map) {
-        Map<String, Long> nm = new HashMap<String, Long>();
+        Map<String, Long> nm = new HashMap<>();
         for (Map.Entry entry : map.entrySet()) {
             nm.put(entry.getKey().toString(), toLong(entry.getValue()));
         }

Reply via email to