From e6ceba63f71b745d674d8b8d1d25ac2f7fb5bd45 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 20 Dec 2024 13:49:17 -0600 Subject: [PATCH] Fix null pointer in DataSourceHandler error handler --- .../core/file/AbstractDataSourceHandler.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java index 2a20b3a4a..ad9790846 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractDataSourceHandler.java @@ -150,12 +150,16 @@ public abstract class AbstractDataSourceHandler } catch (DataCorruptedException e) { + // there's a rare issue where the exception doesn't + // have a message, which can cause problems + String message = (e.getMessage() == null) ? e.getMessage() : "No Error message for exception ["+e.getClass().getSimpleName()+"]"; + // Only log each message type once. // This is done to prevent logging "No compression mode with the value [2]" 10,000 times // if the user is migrating from a nightly build and used ZStd. - if (CORRUPT_DATA_ERRORS_LOGGED.add(e.getMessage())) + if (CORRUPT_DATA_ERRORS_LOGGED.add(message)) { - LOGGER.warn("Corrupted data found at pos [" + DhSectionPos.toString(pos) + "]. Data at position will be deleted so it can be re-generated to prevent issues. Future errors with this same message won't be logged. Error: [" + e.getMessage() + "].", e); + LOGGER.warn("Corrupted data found at pos [" + DhSectionPos.toString(pos) + "]. Data at position will be deleted so it can be re-generated to prevent issues. Future errors with this same message won't be logged. Error: [" + message + "].", e); } this.repo.deleteWithKey(pos); @@ -163,9 +167,6 @@ public abstract class AbstractDataSourceHandler } else { - // TODO does this need any special logic to be populated from the existing DTOs? - // and/or is that necessary? - // Everything already appears to be populating correctly. dataSource = this.makeEmptyDataSource(pos); } }