1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -55,8 +55,7 @@ public boolean exists() {
55
55
catch (IOException ex ) {
56
56
// Fall back to stream existence: can we open the stream?
57
57
try {
58
- InputStream is = getInputStream ();
59
- is .close ();
58
+ getInputStream ().close ();
60
59
return true ;
61
60
}
62
61
catch (Throwable isEx ) {
@@ -126,7 +125,7 @@ public long contentLength() throws IOException {
126
125
Assert .state (is != null , "Resource InputStream must not be null" );
127
126
try {
128
127
long size = 0 ;
129
- byte [] buf = new byte [255 ];
128
+ byte [] buf = new byte [256 ];
130
129
int read ;
131
130
while ((read = is .read (buf )) != -1 ) {
132
131
size += read ;
@@ -149,10 +148,11 @@ public long contentLength() throws IOException {
149
148
*/
150
149
@ Override
151
150
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 ()) {
154
154
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" );
156
156
}
157
157
return lastModified ;
158
158
}
0 commit comments