@@ -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
jarInput .close ();
@@ -92,7 +98,9 @@ public List<String> list(URL url, String path) throws IOException {
92
98
BufferedReader reader = new BufferedReader (new InputStreamReader (is ));
93
99
List <String > lines = new ArrayList <String >();
94
100
for (String line ; (line = reader .readLine ()) != null ;) {
95
- log .debug ("Reader entry: " + line );
101
+ if (log .isDebugEnabled ()) {
102
+ log .debug ("Reader entry: " + line );
103
+ }
96
104
lines .add (line );
97
105
if (getResources (path + "/" + line ).isEmpty ()) {
98
106
lines .clear ();
@@ -101,7 +109,9 @@ public List<String> list(URL url, String path) throws IOException {
101
109
}
102
110
103
111
if (!lines .isEmpty ()) {
104
- log .debug ("Listing " + url );
112
+ if (log .isDebugEnabled ()) {
113
+ log .debug ("Listing " + url );
114
+ }
105
115
children .addAll (lines );
106
116
}
107
117
}
@@ -113,9 +123,13 @@ public List<String> list(URL url, String path) throws IOException {
113
123
*/
114
124
if ("file" .equals (url .getProtocol ())) {
115
125
File file = new File (url .getFile ());
116
- log .debug ("Listing directory " + file .getAbsolutePath ());
126
+ if (log .isDebugEnabled ()) {
127
+ log .debug ("Listing directory " + file .getAbsolutePath ());
128
+ }
117
129
if (file .isDirectory ()) {
118
- log .debug ("Listing " + url );
130
+ if (log .isDebugEnabled ()) {
131
+ log .debug ("Listing " + url );
132
+ }
119
133
children = Arrays .asList (file .list ());
120
134
}
121
135
}
@@ -182,7 +196,9 @@ protected List<String> listResources(JarInputStream jar, String path) throws IOE
182
196
183
197
// Check file name
184
198
if (name .startsWith (path )) {
185
- log .debug ("Found resource: " + name );
199
+ if (log .isDebugEnabled ()) {
200
+ log .debug ("Found resource: " + name );
201
+ }
186
202
// Trim leading slash
187
203
resources .add (name .substring (1 ));
188
204
}
@@ -202,13 +218,17 @@ protected List<String> listResources(JarInputStream jar, String path) throws IOE
202
218
* @throws MalformedURLException
203
219
*/
204
220
protected URL findJarForResource (URL url ) throws MalformedURLException {
205
- log .debug ("Find JAR URL: " + url );
221
+ if (log .isDebugEnabled ()) {
222
+ log .debug ("Find JAR URL: " + url );
223
+ }
206
224
207
225
// If the file part of the URL is itself a URL, then that URL probably points to the JAR
208
226
try {
209
227
for (;;) {
210
228
url = new URL (url .getFile ());
211
- log .debug ("Inner URL: " + url );
229
+ if (log .isDebugEnabled ()) {
230
+ log .debug ("Inner URL: " + url );
231
+ }
212
232
}
213
233
} catch (MalformedURLException e ) {
214
234
// This will happen at some point and serves as a break in the loop
@@ -219,10 +239,14 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
219
239
int index = jarUrl .lastIndexOf (".jar" );
220
240
if (index >= 0 ) {
221
241
jarUrl .setLength (index + 4 );
222
- log .debug ("Extracted JAR URL: " + jarUrl );
242
+ if (log .isDebugEnabled ()) {
243
+ log .debug ("Extracted JAR URL: " + jarUrl );
244
+ }
223
245
}
224
246
else {
225
- log .debug ("Not a JAR: " + jarUrl );
247
+ if (log .isDebugEnabled ()) {
248
+ log .debug ("Not a JAR: " + jarUrl );
249
+ }
226
250
return null ;
227
251
}
228
252
@@ -234,7 +258,9 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
234
258
}
235
259
else {
236
260
// WebLogic fix: check if the URL's file exists in the filesystem.
237
- log .debug ("Not a JAR: " + jarUrl );
261
+ if (log .isDebugEnabled ()) {
262
+ log .debug ("Not a JAR: " + jarUrl );
263
+ }
238
264
jarUrl .replace (0 , jarUrl .length (), testUrl .getFile ());
239
265
File file = new File (jarUrl .toString ());
240
266
@@ -248,7 +274,9 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
248
274
}
249
275
250
276
if (file .exists ()) {
251
- log .debug ("Trying real file: " + file .getAbsolutePath ());
277
+ if (log .isDebugEnabled ()) {
278
+ log .debug ("Trying real file: " + file .getAbsolutePath ());
279
+ }
252
280
testUrl = file .toURI ().toURL ();
253
281
if (isJar (testUrl )) {
254
282
return testUrl ;
@@ -259,7 +287,9 @@ protected URL findJarForResource(URL url) throws MalformedURLException {
259
287
log .warn ("Invalid JAR URL: " + jarUrl );
260
288
}
261
289
262
- log .debug ("Not a JAR: " + jarUrl );
290
+ if (log .isDebugEnabled ()) {
291
+ log .debug ("Not a JAR: " + jarUrl );
292
+ }
263
293
return null ;
264
294
}
265
295
@@ -296,7 +326,9 @@ protected boolean isJar(URL url, byte[] buffer) {
296
326
is = url .openStream ();
297
327
is .read (buffer , 0 , JAR_MAGIC .length );
298
328
if (Arrays .equals (buffer , JAR_MAGIC )) {
299
- log .debug ("Found JAR: " + url );
329
+ if (log .isDebugEnabled ()) {
330
+ log .debug ("Found JAR: " + url );
331
+ }
300
332
return true ;
301
333
}
302
334
} catch (Exception e ) {
0 commit comments