You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2017/09/14 13:28:02 UTC

karaf git commit: Fix blacklist mechanism broken by commit eb95bce7d5a1bcf23a5bda919209394ffcf3c01a

Repository: karaf
Updated Branches:
  refs/heads/master 83727d913 -> 1103f3de2


Fix blacklist mechanism broken by commit eb95bce7d5a1bcf23a5bda919209394ffcf3c01a


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

Branch: refs/heads/master
Commit: 1103f3de2c37539f7e2ee695c5bfe873ef47abc2
Parents: 83727d9
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Sep 14 15:27:47 2017 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Sep 14 15:27:47 2017 +0200

----------------------------------------------------------------------
 .../features/internal/service/Blacklist.java    |  7 ++++---
 .../internal/service/BlacklistTest.java         |  8 ++++++++
 .../features/internal/service/blacklist.txt     | 21 ++++++++++++++++++++
 3 files changed, 33 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/1103f3de/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
index f7f4aab..ac971fc 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Blacklist.java
@@ -69,8 +69,9 @@ public class Blacklist {
             try (InputStream is = new URL(blacklistUrl).openStream();
                 BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
                 reader.lines() //
-                    .map(line -> line.trim()) //
-                    .filter(line -> line.isEmpty() || line.startsWith("#")).collect(toSet());
+                    .map(String::trim) //
+                    .filter(line -> !line.isEmpty() && !line.startsWith("#"))
+                    .forEach(blacklist::add);
             } catch (FileNotFoundException e) {
                 LOGGER.debug("Unable to load blacklist bundles list", e.toString());
             } catch (Exception e) {
@@ -81,7 +82,7 @@ public class Blacklist {
     }
 
     public void blacklist(Features features) {
-        features.getFeature().removeIf(feature -> blacklist(feature));
+        features.getFeature().removeIf(this::blacklist);
     }
 
     public boolean blacklist(Feature feature) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/1103f3de/features/core/src/test/java/org/apache/karaf/features/internal/service/BlacklistTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/BlacklistTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/service/BlacklistTest.java
index 956d04b..8e835ea 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/BlacklistTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/BlacklistTest.java
@@ -56,6 +56,14 @@ public class BlacklistTest {
         assertTrue(bundles.noneMatch(b -> b.getLocation().equals(blacklisted)));
     }
 
+    @Test
+    public void testBlacklistLoad() throws URISyntaxException {
+        Blacklist blacklist = new Blacklist(getClass().getResource("blacklist.txt").toExternalForm());
+        RepositoryImpl repo = new RepositoryImpl(getClass().getResource("f02.xml").toURI(), blacklist, true);
+        Stream<Feature> features = Arrays.asList(repo.getFeatures()).stream();
+        assertTrue(features.noneMatch(f -> f.getId().equals("spring/2.5.6.SEC02")));
+    }
+
     private Stream<org.apache.karaf.features.Feature> blacklistWith(String blacklistClause) {
         URI uri;
         try {

http://git-wip-us.apache.org/repos/asf/karaf/blob/1103f3de/features/core/src/test/resources/org/apache/karaf/features/internal/service/blacklist.txt
----------------------------------------------------------------------
diff --git a/features/core/src/test/resources/org/apache/karaf/features/internal/service/blacklist.txt b/features/core/src/test/resources/org/apache/karaf/features/internal/service/blacklist.txt
new file mode 100644
index 0000000..43a36f2
--- /dev/null
+++ b/features/core/src/test/resources/org/apache/karaf/features/internal/service/blacklist.txt
@@ -0,0 +1,21 @@
+
+################################################################################
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+################################################################################
+
+spring;range=2.5.6.SEC02