[jboss-jira] [JBoss JIRA] Commented: (JBRULES-2849) DSLMappingEntryTest fails with Java 1.5 on hudson (but not in Java 1.6)
Wolfgang Laun (JIRA)
jira-events at lists.jboss.org
Sat Dec 25 04:21:17 EST 2010
[ https://issues.jboss.org/browse/JBRULES-2849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12572299#comment-12572299 ]
Wolfgang Laun commented on JBRULES-2849:
----------------------------------------
The regular expressions are correct and according to javadoc in java.util.regex.Pattern. This is a bug in JDK 5: it doesn't handle alternatives in zero-width lookbehind assertions. Original code in 5.1.1 was using a complicated technique (in hindsight I can now say: as a workaround). However, there is another, simple workaround:
import java.util.regex.*;
public class Sandbox {
public static void main(String[] args) {
System.out.println("java = " + System.getProperty("java.version"));
String s1 = "a man";
String s2 = ":a man";
String s3 = "a man:";
String s4 = ":a man:";
String lb = "(?:(?<=^)|(?<=\\W))";
String la = "(?=$|\\W)"; // (?:(?=$)|(?=\\W))
Pattern p1 = Pattern.compile( lb + "a man" );
Pattern p2 = Pattern.compile( "a man" + la );
Pattern p3 = Pattern.compile( lb + "a man" + la );
for( Pattern p: new Pattern[]{ p1, p2, p3 } ){
for( String s: new String[]{ s1, s2, s3, s4 } ){
Matcher m = p.matcher( s );
System.out.println( "\"" + s + "\" =~ /" + p + "/ => " + m.find(0) );
}
}
}
}
$ $java Sandbox
java = 1.5.0_22
"a man" =~ /(?:(?<=^)|(?<=\W))a man/ => true
":a man" =~ /(?:(?<=^)|(?<=\W))a man/ => true
"a man:" =~ /(?:(?<=^)|(?<=\W))a man/ => true
":a man:" =~ /(?:(?<=^)|(?<=\W))a man/ => true
"a man" =~ /a man(?=$|\W)/ => true
":a man" =~ /a man(?=$|\W)/ => true
"a man:" =~ /a man(?=$|\W)/ => true
":a man:" =~ /a man(?=$|\W)/ => true
"a man" =~ /(?:(?<=^)|(?<=\W))a man(?=$|\W)/ => true
":a man" =~ /(?:(?<=^)|(?<=\W))a man(?=$|\W)/ => true
"a man:" =~ /(?:(?<=^)|(?<=\W))a man(?=$|\W)/ => true
":a man:" =~ /(?:(?<=^)|(?<=\W))a man(?=$|\W)/ => true
> DSLMappingEntryTest fails with Java 1.5 on hudson (but not in Java 1.6)
> -----------------------------------------------------------------------
>
> Key: JBRULES-2849
> URL: https://issues.jboss.org/browse/JBRULES-2849
> Project: Drools
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: drools-compiler
> Reporter: Geoffrey De Smet
> Assignee: Geoffrey De Smet
> Fix For: 5.2.0.M2
>
>
> with java 1.5 fails it on hudson:
> https://hudson.qa.jboss.com/hudson/view/Drools/job/drools/6242/testReport/org.drools.lang.dsl/DSLMappingEntryTest/testExpandWithDots/
> the next build, with java 1.6 does not fail it on hudson:
> https://hudson.qa.jboss.com/hudson/view/Drools/job/drools/6243/testReport/org.drools.lang.dsl/DSLMappingEntryTest/testExpandWithDots/
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list