Repository: karaf-cellar Updated Branches: refs/heads/master 790c22bd0 -> 838b9f394
[KARAF-4538] Use matches() instead of find() to make bundle matching strategy more predictable Project: http://git-wip-us.apache.org/repos/asf/karaf-cellar/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf-cellar/commit/07efcdf5 Tree: http://git-wip-us.apache.org/repos/asf/karaf-cellar/tree/07efcdf5 Diff: http://git-wip-us.apache.org/repos/asf/karaf-cellar/diff/07efcdf5 Branch: refs/heads/master Commit: 07efcdf57f4453f67573958610d2b6cb4b51cf51 Parents: 790c22b Author: Sergiy Shyrkov <[email protected]> Authored: Tue Sep 6 21:02:38 2016 +0200 Committer: Jean-Baptiste Onofré <[email protected]> Committed: Wed Sep 7 06:14:02 2016 +0200 ---------------------------------------------------------------------- .../management/internal/CellarBundleMBeanImpl.java | 16 ++++++++-------- .../cellar/bundle/shell/BundleCommandSupport.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/07efcdf5/bundle/src/main/java/org/apache/karaf/cellar/bundle/management/internal/CellarBundleMBeanImpl.java ---------------------------------------------------------------------- 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 5342f5c..5bae2b0 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 @@ -472,7 +472,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle // id is a number Pattern pattern = Pattern.compile("^\\d+$"); Matcher matcher = pattern.matcher(nameId); - if (matcher.find()) { + if (matcher.matches()) { int idInt = Integer.parseInt(nameId); for (String bundle : clusterBundles.keySet()) { if (clusterBundles.get(bundle).getId() == idInt) { @@ -486,7 +486,7 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle // id as a number range pattern = Pattern.compile("^(\\d+)-(\\d+)$"); matcher = pattern.matcher(nameId); - if (matcher.find()) { + if (matcher.matches()) { int index = nameId.indexOf('-'); long startId = Long.parseLong(nameId.substring(0, index)); long endId = Long.parseLong(nameId.substring(index + 1)); @@ -517,19 +517,19 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle if (state.getName() != null) { // bundle name is populated, check if it matches the regex matcher = namePattern.matcher(state.getName()); - if (matcher.find()) { + 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(bundleSplit[0]); - if (matcher.find()) { + 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(bundleSplit[0]); - if (matcher.find()) { + if (matcher.matches()) { bundles.add(bundle); } } @@ -547,19 +547,19 @@ public class CellarBundleMBeanImpl extends StandardMBean implements CellarBundle if (state.getName() != null) { // bundle name is populated, check if it matches the regex matcher = namePattern.matcher(state.getName()); - if (matcher.find()) { + 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); - if (matcher.find()) { + 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); - if (matcher.find()) { + if (matcher.matches()) { bundles.add(bundle); } } http://git-wip-us.apache.org/repos/asf/karaf-cellar/blob/07efcdf5/bundle/src/main/java/org/apache/karaf/cellar/bundle/shell/BundleCommandSupport.java ---------------------------------------------------------------------- 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 a04742c..be5d5df 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 @@ -73,7 +73,7 @@ public abstract class BundleCommandSupport extends CellarCommandSupport { // id is a number Pattern pattern = Pattern.compile("^\\d+$"); Matcher matcher = pattern.matcher(nameId); - if (matcher.find()) { + if (matcher.matches()) { int id = Integer.parseInt(nameId); for (String bundle : clusterBundles.keySet()) { if (clusterBundles.get(bundle).getId() == id) { @@ -87,7 +87,7 @@ public abstract class BundleCommandSupport extends CellarCommandSupport { // id as a number range pattern = Pattern.compile("^(\\d+)-(\\d+)$"); matcher = pattern.matcher(nameId); - if (matcher.find()) { + if (matcher.matches()) { int index = nameId.indexOf('-'); long startId = Long.parseLong(nameId.substring(0, index)); long endId = Long.parseLong(nameId.substring(index + 1)); @@ -118,19 +118,19 @@ public abstract class BundleCommandSupport extends CellarCommandSupport { if (state.getName() != null) { // bundle name is populated, check if it matches the regex matcher = namePattern.matcher(state.getName()); - if (matcher.find()) { + 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(bundleSplit[0]); - if (matcher.find()) { + 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(bundleSplit[0]); - if (matcher.find()) { + if (matcher.matches()) { bundles.add(bundle); } } @@ -148,19 +148,19 @@ public abstract class BundleCommandSupport extends CellarCommandSupport { if (state.getName() != null) { // bundle name is populated, check if it matches the regex matcher = namePattern.matcher(state.getName()); - if (matcher.find()) { + 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); - if (matcher.find()) { + 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); - if (matcher.find()) { + if (matcher.matches()) { bundles.add(bundle); } }
