You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2019/02/19 17:10:59 UTC

[karaf-cellar] branch cellar-4.1.x updated (042276a -> df7b4d2)

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a change to branch cellar-4.1.x
in repository https://gitbox.apache.org/repos/asf/karaf-cellar.git.


    from 042276a  Avoid potential NPE in wildcard matcher
     new 04549fb  [KARAF-6165] Fix bundle selector
     new df7b4d2  [KARAF-6162] Fix cluster:bundle-update command

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../management/internal/CellarBundleMBeanImpl.java | 44 +++++++++++++++++-----
 .../cellar/bundle/shell/BundleCommandSupport.java  | 39 ++++++++++++++++---
 .../cellar/bundle/shell/UpdateBundleCommand.java   |  2 +-
 3 files changed, 69 insertions(+), 16 deletions(-)


[karaf-cellar] 01/02: [KARAF-6165] Fix bundle selector

Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch cellar-4.1.x
in repository https://gitbox.apache.org/repos/asf/karaf-cellar.git

commit 04549fb48c83fde52cba17d6efa37f9a59d1df85
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Tue Feb 19 18:07:09 2019 +0100

    [KARAF-6165] Fix bundle selector
---
 .../management/internal/CellarBundleMBeanImpl.java | 44 +++++++++++++++++-----
 .../cellar/bundle/shell/BundleCommandSupport.java  | 39 ++++++++++++++++---
 2 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
index abd76f4..a8c03c7 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java
@@ -535,14 +535,13 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
     }
 
     protected void addMatchingBundles(String nameId, List<String> bundles, Map<String, ExtendedBundleState> clusterBundles) {
-
         // id is a number
         Pattern pattern = Pattern.compile("^\\d+$");
         Matcher matcher = pattern.matcher(nameId);
         if (matcher.matches()) {
-            int idInt = Integer.parseInt(nameId);
+            int id = Integer.parseInt(nameId);
             for (String bundle : clusterBundles.keySet()) {
-                if (clusterBundles.get(bundle).getId() == idInt) {
+                if (clusterBundles.get(bundle).getId() == id) {
                     bundles.add(bundle);
                     break;
                 }
@@ -587,14 +586,26 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
                         if (matcher.matches()) {
                             bundles.add(bundle);
                         } else {
-                            // no match on bundle name, fall back to symbolic name and check if it matches the regex
+                            // no match on bundle name, fall back to id and check if it matches the regex
+                            matcher = namePattern.matcher(bundleSplit[0]);
+                            if (matcher.matches()) {
+                                bundles.add(bundle);
+                            }
+                        }
+                    } else if (state.getSymbolicName() != null) {
+                        // bundle symbolic name is populated, check if it matches the regex
+                        matcher = namePattern.matcher(state.getSymbolicName());
+                        if (matcher.matches()) {
+                            bundles.add(bundle);
+                        } else {
+                            // no match on bundle symbolic name, fall back to id and check if it matches the regex
                             matcher = namePattern.matcher(bundleSplit[0]);
                             if (matcher.matches()) {
                                 bundles.add(bundle);
                             }
                         }
                     } else {
-                        // no bundle name, fall back to symbolic name and check if it matches the regex
+                        // no bundle name, fall back to id and check if it matches the regex
                         matcher = namePattern.matcher(bundleSplit[0]);
                         if (matcher.matches()) {
                             bundles.add(bundle);
@@ -617,15 +628,30 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle
                 if (matcher.matches()) {
                     bundles.add(bundle);
                 } else {
-                    // no match on bundle name, fall back to symbolic name and check if it matches the regex
-                    matcher = namePattern.matcher(bundle);
+                    // no match on bundle name, fall back to id and check if it matches the regex
+                    String[] idSplit = bundle.split("/");
+                    matcher = namePattern.matcher(idSplit[0]);
+                    if (matcher.matches()) {
+                        bundles.add(bundle);
+                    }
+                }
+            } else if (state.getSymbolicName() != null) {
+                // bundle symbolic name is populated, check if it matches the regex
+                matcher = namePattern.matcher(state.getSymbolicName());
+                if (matcher.matches()) {
+                    bundles.add(bundle);
+                } else {
+                    // no match on bundle symbolic name, fall back to id and check if it matches the regex
+                    String[] idSplit = bundle.split("/");
+                    matcher = namePattern.matcher(idSplit[0]);
                     if (matcher.matches()) {
                         bundles.add(bundle);
                     }
                 }
             } else {
-                // no bundle name, fall back to symbolic name and check if it matches the regex
-                matcher = namePattern.matcher(bundle);
+                // no bundle name, fall back to id and check if it matches the regex
+                String[] idSplit = bundle.split("/");
+                matcher = namePattern.matcher(idSplit[0]);
                 if (matcher.matches()) {
                     bundles.add(bundle);
                 }
diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
index be5d5df..d16806a 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java
@@ -121,14 +121,26 @@ public abstract class BundleCommandSupport extends CellarCommandSupport {
                         if (matcher.matches()) {
                             bundles.add(bundle);
                         } else {
-                            // no match on bundle name, fall back to symbolic name and check if it matches the regex
+                            // no match on bundle name, fall back to id and check if it matches the regex
+                            matcher = namePattern.matcher(bundleSplit[0]);
+                            if (matcher.matches()) {
+                                bundles.add(bundle);
+                            }
+                        }
+                    } else if (state.getSymbolicName() != null) {
+                        // bundle symbolic name is populated, check if it matches the regex
+                        matcher = namePattern.matcher(state.getSymbolicName());
+                        if (matcher.matches()) {
+                            bundles.add(bundle);
+                        } else {
+                            // no match on bundle symbolic name, fall back to id and check if it matches the regex
                             matcher = namePattern.matcher(bundleSplit[0]);
                             if (matcher.matches()) {
                                 bundles.add(bundle);
                             }
                         }
                     } else {
-                        // no bundle name, fall back to symbolic name and check if it matches the regex
+                        // no bundle name, fall back to id and check if it matches the regex
                         matcher = namePattern.matcher(bundleSplit[0]);
                         if (matcher.matches()) {
                             bundles.add(bundle);
@@ -151,15 +163,30 @@ public abstract class BundleCommandSupport extends CellarCommandSupport {
                 if (matcher.matches()) {
                     bundles.add(bundle);
                 } else {
-                    // no match on bundle name, fall back to symbolic name and check if it matches the regex
-                    matcher = namePattern.matcher(bundle);
+                    // no match on bundle name, fall back to id and check if it matches the regex
+                    String[] idSplit = bundle.split("/");
+                    matcher = namePattern.matcher(idSplit[0]);
+                    if (matcher.matches()) {
+                        bundles.add(bundle);
+                    }
+                }
+            } else if (state.getSymbolicName() != null) {
+                // bundle symbolic name is populated, check if it matches the regex
+                matcher = namePattern.matcher(state.getSymbolicName());
+                if (matcher.matches()) {
+                    bundles.add(bundle);
+                } else {
+                    // no match on bundle symbolic name, fall back to id and check if it matches the regex
+                    String[] idSplit = bundle.split("/");
+                    matcher = namePattern.matcher(idSplit[0]);
                     if (matcher.matches()) {
                         bundles.add(bundle);
                     }
                 }
             } else {
-                // no bundle name, fall back to symbolic name and check if it matches the regex
-                matcher = namePattern.matcher(bundle);
+                // no bundle name, fall back to id and check if it matches the regex
+                String[] idSplit = bundle.split("/");
+                matcher = namePattern.matcher(idSplit[0]);
                 if (matcher.matches()) {
                     bundles.add(bundle);
                 }


[karaf-cellar] 02/02: [KARAF-6162] Fix cluster:bundle-update command

Posted by jb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch cellar-4.1.x
in repository https://gitbox.apache.org/repos/asf/karaf-cellar.git

commit df7b4d2b9fd226add8f66ed6859f8f45bd79e68a
Author: Jean-Baptiste Onofré <jb...@apache.org>
AuthorDate: Tue Feb 19 18:09:50 2019 +0100

    [KARAF-6162] Fix cluster:bundle-update command
---
 .../java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java
index 535d1f3..f6c1063 100644
--- a/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java
+++ b/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/UpdateBundleCommand.java
@@ -91,7 +91,7 @@ public class UpdateBundleCommand extends BundleCommandSupport {
             }
 
             // update cluster state
-            state.setLocation(updateLocation);
+            state.setLocation(location);
             clusterBundles.put(bundle, state);
 
             // broadcast the cluster event