|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 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.
|
|
25 | 25 | import java.util.List;
|
26 | 26 | import java.util.Locale;
|
27 | 27 | import java.util.Map;
|
28 |
| -import java.util.Objects; |
29 | 28 | import java.util.Properties;
|
30 | 29 | import java.util.concurrent.ConcurrentHashMap;
|
31 | 30 | import java.util.concurrent.ConcurrentMap;
|
@@ -431,7 +430,7 @@ protected PropertiesHolder refreshProperties(String filename, @Nullable Properti
|
431 | 430 | long refreshTimestamp = (getCacheMillis() < 0 ? -1 : System.currentTimeMillis());
|
432 | 431 |
|
433 | 432 | Resource resource = resolveResource(filename);
|
434 |
| - if (resource.exists()) { |
| 433 | + if (resource != null) { |
435 | 434 | long fileTimestamp = -1;
|
436 | 435 | if (getCacheMillis() >= 0) {
|
437 | 436 | // Last-modified timestamp of file will just be read if caching with timeout.
|
@@ -508,18 +507,18 @@ protected PropertiesHolder refreshProperties(String filename, @Nullable Properti
|
508 | 507 | * {@link PropertiesPersister#load(Properties, InputStream) load} methods
|
509 | 508 | * for other types of resources.
|
510 | 509 | * @param filename the bundle filename (basename + Locale)
|
511 |
| - * @return the {@code Resource} to use |
| 510 | + * @return the {@code Resource} to use, or {@code null} if none found |
512 | 511 | * @since 6.1
|
513 | 512 | */
|
| 513 | + @Nullable |
514 | 514 | protected Resource resolveResource(String filename) {
|
515 |
| - Resource resource = null; |
516 | 515 | for (String fileExtension : this.fileExtensions) {
|
517 |
| - resource = this.resourceLoader.getResource(filename + fileExtension); |
| 516 | + Resource resource = this.resourceLoader.getResource(filename + fileExtension); |
518 | 517 | if (resource.exists()) {
|
519 | 518 | return resource;
|
520 | 519 | }
|
521 | 520 | }
|
522 |
| - return Objects.requireNonNull(resource); |
| 521 | + return null; |
523 | 522 | }
|
524 | 523 |
|
525 | 524 | /**
|
|
0 commit comments