Details
Description
An attempt to create a java.util.regex.Pattern from a variable that is declared as a String fails with a java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to java.lang.String
The code below worked with Groovy 1.7.8 but fails with Groovy 1.8.0
String value="test"
String s = "^\\S+$value\$"
def p = ~s <==Fails here
A workaround is to change the last statement to:
def p = ~/$s/
but that adds clutter
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Closed [ 6 ] |
| Assignee | Jochen Theodorou [ blackdrag ] | |
| Fix Version/s | 1.7.11 [ 17244 ] | |
| Fix Version/s | 1.8.1 [ 17223 ] | |
| Resolution | Fixed [ 1 ] |
fixed