#217 PatternSyntaxException if TopicHierarchyWildcardAny set to *

general
open
Amir Shevat
General (90)
5
2006-07-26
2006-07-26
Anonymous
No

affected version:
MantaRay 2.0

bug description:
If the configuration parameter
<TopicHierarchyWildcardAny> is set to '*'
a PatternSyntaxException is thrown during Topic setup.

java.util.regex.PatternSyntaxException: Dangling meta
character '*' near index 8
.*/[^/]+*.*
^
at java.util.regex.Pattern.error(Pattern.java:1541)
at
java.util.regex.Pattern.sequence(Pattern.java:1658)
at java.util.regex.Pattern.expr(Pattern.java:1558)
at
java.util.regex.Pattern.compile(Pattern.java:1291)
at
java.util.regex.Pattern.<init>(Pattern.java:1047)
at
java.util.regex.Pattern.compile(Pattern.java:785)
at
java.util.regex.Pattern.matches(Pattern.java:875)
at java.lang.String.matches(String.java:1597)
at
org.mr.kernel.services.topics.VirtualTopicManager.isLegalWildcardUsage(VirtualTopicManager.java:197)
at
org.mr.kernel.services.topics.VirtualTopicManager.isLegalWildcardUsage(VirtualTopicManager.java:188)
at
org.mr.kernel.services.topics.VirtualTopicManager.validateTopicName(VirtualTopicManager.java:129)
at
org.mr.api.jms.MantaTopic.setName(MantaTopic.java:114)
at
org.mr.api.jms.MantaTopic.<init>(MantaTopic.java:102)
at
org.mr.api.jms.MantaSession.createTopic(MantaSession.java:1121)
... and some more

cause:
'*' is a reserved character in regular expression patterns

possible solution:
Insert additional escape characters in
org.mr.kernel.services.topics.VirtualTopicManager.isLegalWildcardUsage(String
topicName, String wildcard)

original code:
// Returns true if usage of the wildcard is legal.
// Illegal use can be: /a/b*/
private static boolean isLegalWildcardUsage(String
topicName, String wildcard) {
String patternLeft =
wildcardMisuseLeft1+wildcard+wildcardMisuseLeft2;
String patternRight =
wildcardMisuseRight1+wildcard+wildcardMisuseRight2;
return !topicName.matches(patternLeft) &&
!topicName.matches(patternRight);
}

changed code:
// Returns true if usage of the wildcard is legal.
// Illegal use can be: /a/b*/
private static boolean isLegalWildcardUsage(String
topicName, String wildcard) {
String patternLeft =
wildcardMisuseLeft1+"\\"+wildcard+wildcardMisuseLeft2;
String patternRight =
wildcardMisuseRight1+"\\"+wildcard+wildcardMisuseRight2;
return !topicName.matches(patternLeft) &&
!topicName.matches(patternRight);
}

submitters:
frank.thomas[at]systemagmbh.de
christian.wohanka[at]systemagmbh.de

thank you for looking into this

Discussion

  • Logged In: NO

    sorry for posting this twice (duplicate of 1528966)
    please close/remove this one