@@ -304,11 +304,6 @@ public void setUseLastModified(boolean useLastModified) {
304
304
public void afterPropertiesSet () throws Exception {
305
305
resolveResourceLocations ();
306
306
307
- if (logger .isWarnEnabled () && CollectionUtils .isEmpty (getLocations ())) {
308
- logger .warn ("Locations list is empty. No resources will be served unless a " +
309
- "custom ResourceResolver is configured as an alternative to PathResourceResolver." );
310
- }
311
-
312
307
if (this .resourceResolvers .isEmpty ()) {
313
308
this .resourceResolvers .add (new PathResourceResolver ());
314
309
}
@@ -341,6 +336,12 @@ private void resolveResourceLocations() {
341
336
342
337
this .locationsToUse .clear ();
343
338
this .locationsToUse .addAll (result );
339
+
340
+ if (logger .isInfoEnabled ()) {
341
+ logger .info (!this .locationsToUse .isEmpty () ?
342
+ "Locations in use: " + locationToString (this .locationsToUse ) :
343
+ "0 locations in use." );
344
+ }
344
345
}
345
346
346
347
/**
@@ -350,10 +351,6 @@ private void resolveResourceLocations() {
350
351
*/
351
352
protected void initAllowedLocations () {
352
353
if (CollectionUtils .isEmpty (getLocations ())) {
353
- if (logger .isInfoEnabled ()) {
354
- logger .info ("Locations list is empty. No resources will be served unless a " +
355
- "custom ResourceResolver is configured as an alternative to PathResourceResolver." );
356
- }
357
354
return ;
358
355
}
359
356
for (int i = getResourceResolvers ().size () - 1 ; i >= 0 ; i --) {
@@ -621,18 +618,13 @@ protected void setHeaders(ServerWebExchange exchange, Resource resource, @Nullab
621
618
622
619
@ Override
623
620
public String toString () {
624
- return "ResourceWebHandler " + formatLocations ( );
621
+ return "ResourceWebHandler " + locationToString ( getLocations () );
625
622
}
626
623
627
- private Object formatLocations () {
628
- if (!this .locationValues .isEmpty ()) {
629
- return this .locationValues .stream ().collect (Collectors .joining ("\" , \" " , "[\" " , "\" ]" ));
630
- }
631
- if (!getLocations ().isEmpty ()) {
632
- return "[" + getLocations ().toString ()
633
- .replaceAll ("class path resource" , "Classpath" )
634
- .replaceAll ("ServletContext resource" , "ServletContext" ) + "]" ;
635
- }
636
- return Collections .emptyList ();
624
+ private String locationToString (List <Resource > locations ) {
625
+ return locations .toString ()
626
+ .replaceAll ("class path resource" , "classpath" )
627
+ .replaceAll ("ServletContext resource" , "ServletContext" );
637
628
}
629
+
638
630
}
0 commit comments