[ https://issues.apache.org/jira/browse/GROOVY-8855?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King updated GROOVY-8855: ------------------------------ Labels: breaking (was: ) > Calling Matcher.asBoolean() twice returns different results > ----------------------------------------------------------- > > Key: GROOVY-8855 > URL: https://issues.apache.org/jira/browse/GROOVY-8855 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 3.0.0-alpha-3, 2.5.3 > Reporter: Szymon Stępniak > Priority: Trivial > Labels: breaking > > There is one non-deterministic use case of using type coercion from > {{java.util.regex.Matcher}} to a {{boolean}}. It was initially reported on > Stack Overflow - https://stackoverflow.com/q/52930876/2194470 > And here is an example that shows the problem: > {code:groovy} > def pattern = /[a-z]+/ > def input = 'abc' > def matcher = input =~ pattern > println matcher as Boolean > println matcher as Boolean > {code} > Output: > {code:bash} > true > false > {code} > Solution: > This problem can be solved by replacing {{matcher.find()}} with > {{matcher.find(0)}}, so casting matcher to a boolean does not modify search > index and always starts from the beginning. > I will create a pull request in couple of minutes. -- This message was sent by Atlassian JIRA (v7.6.3#76005)