karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject karaf git commit: [KARAF-4314] karaf-maven-plugin issue when parsing feature xmls with <repository> entries that contain a newline and/or whitespaces
Date Fri, 10 Feb 2017 09:25:48 GMT
Repository: karaf
Updated Branches:
  refs/heads/master ee9612a0c -> 1950f8fa0


[KARAF-4314] karaf-maven-plugin issue when parsing feature xmls with <repository> entries
that contain a newline and/or whitespaces

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

Branch: refs/heads/master
Commit: 1950f8fa0f7effa22e67ed3250935dd74447fee6
Parents: ee9612a
Author: Guillaume Nodet <gnodet@apache.org>
Authored: Fri Feb 10 10:25:37 2017 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Fri Feb 10 10:25:37 2017 +0100

----------------------------------------------------------------------
 .../karaf/features/internal/model/Features.java     | 11 +++++++++++
 .../features/internal/service/RepositoryImpl.java   | 16 ++--------------
 2 files changed, 13 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/1950f8fa/features/core/src/main/java/org/apache/karaf/features/internal/model/Features.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/model/Features.java
b/features/core/src/main/java/org/apache/karaf/features/internal/model/Features.java
index af343e3..0bda125 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/model/Features.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/model/Features.java
@@ -18,6 +18,7 @@ package org.apache.karaf.features.internal.model;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -176,6 +177,16 @@ public class Features {
                 f.postUnmarshall();
             }
         }
+        if (repository != null) {
+            repository = trim(repository);
+        }
+        if (resourceRepository != null) {
+            resourceRepository = trim(resourceRepository);
+        }
+    }
+
+    private static List<String> trim(List<String> list) {
+        return list.stream().map(String::trim).collect(Collectors.toList());
     }
 
     public void setNamespace(String namespace) {

http://git-wip-us.apache.org/repos/asf/karaf/blob/1950f8fa/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
index 45c9fd0..ad294b4 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java
@@ -55,24 +55,12 @@ public class RepositoryImpl implements Repository {
 
     public URI[] getRepositories() throws IOException {
         load();
-        URI[] result = new URI[features.getRepository().size()];
-        for (int i = 0; i < features.getRepository().size(); i++) {
-            String uri = features.getRepository().get(i);
-            uri = uri.trim();
-            result[i] = URI.create(uri);
-        }
-        return result;
+        return features.getRepository().stream().map(URI::create).toArray(URI[]::new);
     }
 
     public URI[] getResourceRepositories() throws IOException {
         load();
-        URI[] result = new URI[features.getResourceRepository().size()];
-        for (int i = 0; i < features.getResourceRepository().size(); i++) {
-            String uri = features.getResourceRepository().get(i);
-            uri = uri.trim();
-            result[i] = URI.create(uri);
-        }
-        return result;
+        return features.getResourceRepository().stream().map(URI::create).toArray(URI[]::new);
     }
 
     public org.apache.karaf.features.Feature[] getFeatures() throws IOException {


Mime
View raw message