@@ -42,11 +42,12 @@ private GlobUtils() {
42
42
public static final String SAME_LEVEL_IDENTIFIER = "#" ;
43
43
private static final Pattern threeConsecutiveStarsRegex = Pattern .compile (".*[*]{3,}.*" );
44
44
private static final Pattern emptyLevelsRegex = Pattern .compile (".*/{2,}.*" );
45
+ private static final String ALL_UNNAMED = "ALL_UNNAMED" ;
45
46
46
47
public static String transformToTriePath (String resource , String module ) {
47
48
String resolvedModuleName ;
48
49
if (module == null || module .isEmpty ()) {
49
- resolvedModuleName = " ALL_UNNAMED" ;
50
+ resolvedModuleName = ALL_UNNAMED ;
50
51
} else {
51
52
resolvedModuleName = StringUtil .toSlashSeparated (module );
52
53
}
@@ -104,15 +105,25 @@ public static String validatePattern(String pattern) {
104
105
escapeMode = current == '\\' ;
105
106
}
106
107
107
- // check if pattern contains ** without previous Literal parent. Example: */**/... or **/...
108
- outer : for (List <GlobToken > levelTokens : tokenize (pattern )) {
109
- for (GlobToken token : levelTokens ) {
110
- if (token .kind == GlobToken .Kind .LITERAL ) {
111
- break outer ;
112
- } else if (token .kind == GlobToken .Kind .STAR_STAR ) {
113
- sb .append ("Pattern contains ** without previous literal. " +
114
- "This pattern is too generic and therefore can match many resources. " +
115
- "Please make the pattern more specific by adding non-generic level before ** level." );
108
+ // check if pattern (that matches something from classpath) contains ** without previous
109
+ // Literal parent. Example: */**/... or **/...
110
+ if (pattern .startsWith (ALL_UNNAMED )) {
111
+ List <List <GlobToken >> patternParts = tokenize (pattern );
112
+
113
+ // remove ALL_UNNAMED prefix
114
+ patternParts .removeFirst ();
115
+
116
+ // check glob without module prefix
117
+ outer : for (List <GlobToken > levelTokens : patternParts ) {
118
+ for (GlobToken token : levelTokens ) {
119
+ if (token .kind == GlobToken .Kind .LITERAL ) {
120
+ break outer ;
121
+ } else if (token .kind == GlobToken .Kind .STAR_STAR ) {
122
+ String patternWithoutModule = pattern .substring (ALL_UNNAMED .length () + 1 );
123
+ LogUtils .warning ("Pattern: " + patternWithoutModule + " contains ** without previous literal. " +
124
+ "This pattern is too generic and therefore can match many resources. " +
125
+ "Please make the pattern more specific by adding non-generic level before ** level." );
126
+ }
116
127
}
117
128
}
118
129
}
0 commit comments