diff --git a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java index 455b5a655c..8837f47292 100644 --- a/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java +++ b/spring-core/src/main/java/org/springframework/core/io/AbstractResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import org.springframework.core.NestedIOException; +import org.springframework.core.log.LogAccessor; import org.springframework.lang.Nullable; import org.springframework.util.ResourceUtils; @@ -39,10 +40,13 @@ import org.springframework.util.ResourceUtils; * throw an exception; and "toString" will return the description. * * @author Juergen Hoeller + * @author Sam Brannen * @since 28.12.2003 */ public abstract class AbstractResource implements Resource { + private static final LogAccessor logAccessor = new LogAccessor(AbstractResource.class); + /** * This implementation checks whether a File can be opened, * falling back to whether an InputStream can be opened. @@ -61,6 +65,8 @@ public abstract class AbstractResource implements Resource { return true; } catch (Throwable isEx) { + logAccessor.debug(ex, + () -> "Could not close InputStream for resource: " + getDescription()); return false; } } @@ -158,6 +164,8 @@ public abstract class AbstractResource implements Resource { is.close(); } catch (IOException ex) { + logAccessor.debug(ex, + () -> "Could not close InputStream for resource: " + getDescription()); } } }