Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Trivial
-
Resolution: Fixed
-
Affects Version/s: 1.5.6
-
Fix Version/s: 1.8-rc-1, 1.7.9, 1.9-beta-1
-
Component/s: None
-
Labels:None
-
Environment:Windows XP, Groovy 1.5.6
-
Number of attachments :
Description
In my project I have a starter config like this:
# load project resources
load *.jar
which causes groovy to fail with the following exception
exception while configuring main class loader: java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1768) at org.codehaus.groovy.tools.LoaderConfiguration.loadFilteredPath(LoaderConfiguration.java:193) at org.codehaus.groovy.tools.LoaderConfiguration.configure(LoaderConfiguration.java:113) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:81) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130)
This can be fixed in LoaderConfiguration.java as follows:
/** * load a possible filtered path. Filters are defined * by using the * wildcard like in any shell */ private void loadFilteredPath(String filter) { if (filter==null) return; int starIndex = filter.indexOf(WILDCARD); if (starIndex == -1) { addFile(new File(filter)); return; } boolean recursive = filter.indexOf(ALL_WILDCARD) != -1; String startDir = starIndex == 0 ? "./" : filter.substring(0, starIndex - 1); File root = new File(startDir); filter = RegexUtils.quote(filter); filter = filter.replaceAll("\\"+WILDCARD+"\\"+WILDCARD, MATCH_ALL); filter = filter.replaceAll("\\" + WILDCARD, MATCH_FILE_NAME); Pattern pattern = Pattern.compile(filter); final File[] files = root.listFiles(); if (files != null) { findMatchingFiles(files, pattern, recursive); } }
In the above method implementation the line
String startDir = filter.substring(0, starIndex - 1);
which caused the mentioned exception, was changed to
String startDir = starIndex == 0 ? "./" : filter.substring(0, starIndex - 1);
as you see.
Activity
blackdrag blackdrag
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | 1.5.7 [ 14242 ] | |
| Fix Version/s | 1.6-beta-2 [ 14261 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.5.7 [ 14242 ] | |
| Fix Version/s | 1.5.8 [ 14630 ] | |
| Fix Version/s | 1.6-beta-2 [ 14261 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.5.8 [ 14630 ] | |
| Fix Version/s | 1.6.2 [ 15151 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.6.2 [ 15151 ] | |
| Fix Version/s | 1.6.3 [ 15251 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.6.3 [ 15251 ] | |
| Fix Version/s | 1.7-beta-1 [ 14014 ] |
Guillaume Laforge
made changes -
| Fix Version/s | 1.7-beta-x [ 15538 ] | |
| Fix Version/s | 1.7-beta-1 [ 14014 ] |
blackdrag blackdrag
made changes -
| Parent | GROOVY-4683 [ 122027 ] | |
| Issue Type | Bug [ 1 ] | Sub-task [ 7 ] |
blackdrag blackdrag
made changes -
| Parent | GROOVY-4683 [ 122027 ] | |
| Issue Type | Sub-task [ 7 ] | Bug [ 1 ] |
Guillaume Laforge
made changes -
| Status | Open [ 1 ] | Closed [ 6 ] |
| Assignee | Guillaume Laforge [ guillaume ] | |
| Fix Version/s | 1.8-rc-1 [ 17132 ] | |
| Fix Version/s | 1.7.9 [ 17164 ] | |
| Fix Version/s | 1.9-beta-1 [ 17153 ] | |
| Fix Version/s | 1.7.x [ 15538 ] | |
| Resolution | Fixed [ 1 ] |