From 477807873aa209edc5a3b7746882e01e677eeee9 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 7 Apr 2007 10:11:06 +0000 Subject: 2007-04-07 Andrew John Hughes * javax/management/ObjectName.java (parse(String)): Fix parsing where the wildcard is juxtaposed between other pairs. --- ChangeLog | 6 ++++++ javax/management/ObjectName.java | 43 +++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37fef3b22..065c1b60d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-04-07 Andrew John Hughes + + * javax/management/ObjectName.java + (parse(String)): Fix parsing where the wildcard + is juxtaposed between other pairs. + 2007-04-06 Mark Wielaard * configure.ac (VERSION): Set to 0.95-rc. diff --git a/javax/management/ObjectName.java b/javax/management/ObjectName.java index 00a2a2875..f41740469 100644 --- a/javax/management/ObjectName.java +++ b/javax/management/ObjectName.java @@ -190,36 +190,29 @@ public class ObjectName if (domainSep == -1) throw new MalformedObjectNameException("No domain separator was found."); domain = name.substring(0, domainSep); - String rest = name.substring(domainSep + 1); + propertyListString = name.substring(domainSep + 1); properties = new TreeMap(); - if (rest.equals("*")) - propertyPattern = true; - else + String[] pairs = propertyListString.split(","); + if (pairs.length == 0 && !isPattern()) + throw new MalformedObjectNameException("A name that is not a " + + "pattern must contain at " + + "least one key-value pair."); + for (int a = 0; a < pairs.length; ++a) { - if (rest.endsWith(",*")) + if (pairs[a].equals("*")) { propertyPattern = true; - propertyListString = rest.substring(0, rest.length() - 2); + continue; } - else - propertyListString = rest; - String[] pairs = propertyListString.split(","); - if (pairs.length == 0 && !isPattern()) - throw new MalformedObjectNameException("A name that is not a " + - "pattern must contain at " + - "least one key-value pair."); - for (int a = 0; a < pairs.length; ++a) - { - int sep = pairs[a].indexOf('='); - if (sep == -1) - throw new MalformedObjectNameException("A key must be " + - "followed by a value."); - String key = pairs[a].substring(0, sep); - if (properties.containsKey(key)) - throw new MalformedObjectNameException("The same key occurs " + - "more than once."); - properties.put(key, pairs[a].substring(sep + 1)); - } + int sep = pairs[a].indexOf('='); + if (sep == -1) + throw new MalformedObjectNameException("A key must be " + + "followed by a value."); + String key = pairs[a].substring(0, sep); + if (properties.containsKey(key)) + throw new MalformedObjectNameException("The same key occurs " + + "more than once."); + properties.put(key, pairs[a].substring(sep + 1)); } checkComponents(); } -- cgit v1.2.1