11/*
2- * Copyright 2002-2017 the original author or authors.
2+ * Copyright 2002-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -55,8 +55,7 @@ public boolean exists() {
5555 catch (IOException ex ) {
5656 // Fall back to stream existence: can we open the stream?
5757 try {
58- InputStream is = getInputStream ();
59- is .close ();
58+ getInputStream ().close ();
6059 return true ;
6160 }
6261 catch (Throwable isEx ) {
@@ -126,7 +125,7 @@ public long contentLength() throws IOException {
126125 Assert .state (is != null , "Resource InputStream must not be null" );
127126 try {
128127 long size = 0 ;
129- byte [] buf = new byte [255 ];
128+ byte [] buf = new byte [256 ];
130129 int read ;
131130 while ((read = is .read (buf )) != -1 ) {
132131 size += read ;
@@ -149,10 +148,11 @@ public long contentLength() throws IOException {
149148 */
150149 @ Override
151150 public long lastModified () throws IOException {
152- long lastModified = getFileForLastModifiedCheck ().lastModified ();
153- if (lastModified == 0L ) {
151+ File fileToCheck = getFileForLastModifiedCheck ();
152+ long lastModified = fileToCheck .lastModified ();
153+ if (lastModified == 0L && !fileToCheck .exists ()) {
154154 throw new FileNotFoundException (getDescription () +
155- " cannot be resolved in the file system for resolving its last-modified timestamp" );
155+ " cannot be resolved in the file system for checking its last-modified timestamp" );
156156 }
157157 return lastModified ;
158158 }
0 commit comments