This patch fixes the parsing of ObjectNames where
the wildcard is inbetween other pairs.

Mark, you may want to consider this for the branch
as it seems to stop the exception in JBoss.

Changelog:

2007-04-07  Andrew John Hughes  <[EMAIL PROTECTED]>

        * javax/management/ObjectName.java
        (parse(String)): Fix parsing where the wildcard
        is juxtaposed between other pairs.

-- 
Andrew :-)

Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
Index: javax/management/ObjectName.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/management/ObjectName.java,v
retrieving revision 1.11
diff -u -3 -p -u -r1.11 ObjectName.java
--- javax/management/ObjectName.java	6 Apr 2007 15:45:09 -0000	1.11
+++ javax/management/ObjectName.java	7 Apr 2007 09:13:42 -0000
@@ -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<String,String>();
-    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();
   }

Attachment: signature.asc
Description: Digital signature

Reply via email to