@@ -61,7 +61,9 @@ public List<String> list(URL url, String path) throws IOException {
61
61
URL jarUrl = findJarForResource (url );
62
62
if (jarUrl != null ) {
63
63
is = jarUrl .openStream ();
64
- log .debug ("Listing " + url );
64
+ if (log .isDebugEnabled ()) {
65
+ log .debug ("Listing " + url );
66
+ }
65
67
resources = listResources (new JarInputStream (is ), path );
66
68
}
67
69
else {
@@ -72,9 +74,13 @@ public List<String> list(URL url, String path) throws IOException {
72
74
// referenced by the URL isn't actually a JAR
73
75
is = url .openStream ();
74
76
JarInputStream jarInput = new JarInputStream (is );
75
- log .debug ("Listing " + url );
77
+ if (log .isDebugEnabled ()) {
78
+ log .debug ("Listing " + url );
79
+ }
76
80
for (JarEntry entry ; (entry = jarInput .getNextJarEntry ()) != null ;) {
77
- log .debug ("Jar entry: " + entry .getName ());
81
+ if (log .isDebugEnabled ()) {
82
+ log .debug ("Jar entry: " + entry .getName ());
83
+ }
78
84
children .add (entry .getName ());
79
85
}
80
86
}
@@ -91,7 +97,9 @@ public List<String> list(URL url, String path) throws IOException {
91
97
BufferedReader reader = new BufferedReader (new InputStreamReader (is ));
92
98
List <String > lines = new ArrayList <String >();
93
99
for (String line ; (line = reader .readLine ()) != null ;) {
94
- log .debug ("Reader entry: " + line );
100
+ if (log .isDebugEnabled ()) {
101
+ log .debug ("Reader entry: " + line );
102
+ }
95
103
lines .add (line );
96
104
if (getResources (path + "/" + line ).isEmpty ()) {
97
105
lines .clear ();
@@ -100,7 +108,9 @@ public List<String> list(URL url, String path) throws IOException {
100
108
}
101
109
102
110
if (!lines .isEmpty ()) {
103
- log .debug ("Listing " + url );
111
+ if (log .isDebugEnabled ()) {
112
+ log .debug ("Listing " + url );
113
+ }
104
114
children .addAll (lines );
105
115
}
106
116
}
@@ -112,9 +122,13 @@ public List<String> list(URL url, String path) throws IOException {
112
122
*/
113
123
if ("file" .equals (url .getProtocol ())) {
114
124
File file = new File (url .getFile ());
115
- log .debug ("Listing directory " + file .getAbsolutePath ());
125
+ if (log .isDebugEnabled ()) {
126
+ log .debug ("Listing directory " + file .getAbsolutePath ());
127
+ }
116
128
if (file .isDirectory ()) {
117
- log .debug ("Listing " + url );
129
+ if (log .isDebugEnabled ()) {
130
+ log .debug ("Listing " + url );
131
+ }
118
132
children = Arrays .asList (file .list ());
119
133
}
120
134
}
@@ -175,7 +189,9 @@ protected List<String> listResources(JarInputStream jar, String path) throws IOE
175
189
176
190
// Check file name
177
191
if (name .startsWith (path )) {
178
- log .debug ("Found resource: " + name );
192
+ if (log .isDebugEnabled ()) {
193
+ log .debug ("Found resource: " + name );
194
+ }
179
195
resources .add (name .substring (1 )); // Trim leading slash
180
196
}
181
197
}
@@ -194,13 +210,17 @@ protected List<String> listResources(JarInputStream jar, String path) throws IOE
194
210
* @throws MalformedURLException
195
211
*/
196
212
protected URL findJarForResource (URL url ) throws MalformedURLException {
197
- log .debug ("Find JAR URL: " + url );
213
+ if (log .isDebugEnabled ()) {
214
+ log .debug ("Find JAR URL: " + url );
215
+ }
198
216
199
217
// If the file part of the URL is itself a URL, then that URL probably points to the JAR
200
218
try {
201
219
for (;;) {
202
220
url = new URL (url .getFile ());
203
- log .debug ("Inner URL: " + url );
221
+ if (log .isDebugEnabled ()) {
222
+ log .debug ("Inner URL: " + url );
223
+ }
204
224
}
205
225
} catch (MalformedURLException e ) {
206
226
// This will happen at some point and serves as a break in the loop
@@ -211,10 +231,14 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
211
231
int index = jarUrl .lastIndexOf (".jar" );
212
232
if (index >= 0 ) {
213
233
jarUrl .setLength (index + 4 );
214
- log .debug ("Extracted JAR URL: " + jarUrl );
234
+ if (log .isDebugEnabled ()) {
235
+ log .debug ("Extracted JAR URL: " + jarUrl );
236
+ }
215
237
}
216
238
else {
217
- log .debug ("Not a JAR: " + jarUrl );
239
+ if (log .isDebugEnabled ()) {
240
+ log .debug ("Not a JAR: " + jarUrl );
241
+ }
218
242
return null ;
219
243
}
220
244
@@ -226,7 +250,9 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
226
250
}
227
251
else {
228
252
// WebLogic fix: check if the URL's file exists in the filesystem.
229
- log .debug ("Not a JAR: " + jarUrl );
253
+ if (log .isDebugEnabled ()) {
254
+ log .debug ("Not a JAR: " + jarUrl );
255
+ }
230
256
jarUrl .replace (0 , jarUrl .length (), testUrl .getFile ());
231
257
File file = new File (jarUrl .toString ());
232
258
@@ -240,7 +266,9 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
240
266
}
241
267
242
268
if (file .exists ()) {
243
- log .debug ("Trying real file: " + file .getAbsolutePath ());
269
+ if (log .isDebugEnabled ()) {
270
+ log .debug ("Trying real file: " + file .getAbsolutePath ());
271
+ }
244
272
testUrl = file .toURI ().toURL ();
245
273
if (isJar (testUrl )) {
246
274
return testUrl ;
@@ -251,7 +279,9 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
251
279
log .warn ("Invalid JAR URL: " + jarUrl );
252
280
}
253
281
254
- log .debug ("Not a JAR: " + jarUrl );
282
+ if (log .isDebugEnabled ()) {
283
+ log .debug ("Not a JAR: " + jarUrl );
284
+ }
255
285
return null ;
256
286
}
257
287
@@ -288,7 +318,9 @@ protected boolean isJar(URL url, byte[] buffer) {
288
318
is = url .openStream ();
289
319
is .read (buffer , 0 , JAR_MAGIC .length );
290
320
if (Arrays .equals (buffer , JAR_MAGIC )) {
291
- log .debug ("Found JAR: " + url );
321
+ if (log .isDebugEnabled ()) {
322
+ log .debug ("Found JAR: " + url );
323
+ }
292
324
return true ;
293
325
}
294
326
} catch (Exception e ) {
0 commit comments