[jsondb] Restore zero byte files from backup (#2155)

* Restore zero byte files from backup
* Also handle zero byte backup files

Signed-off-by: Mike Major <mike_j_major@hotmail.com>
This commit is contained in:
Mike Major 2021-01-26 16:12:46 +00:00 committed by GitHub
parent 12659595a6
commit 86a447c23a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -216,6 +216,11 @@ public class JsonStorage<T> implements Storage<T> {
@SuppressWarnings("unchecked")
private @Nullable Map<String, StorageEntry> readDatabase(File inputFile) {
if (inputFile.length() == 0) {
logger.warn("Json storage file at '{}' is empty - ignoring corrupt file.", inputFile.getAbsolutePath());
return null;
}
try {
final Map<String, StorageEntry> inputMap = new ConcurrentHashMap<>();