From 382917033a3323fca452e893e3764c3486149d44 Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sat, 20 Apr 2024 11:38:52 -0500 Subject: [PATCH] Fix a few warnings --- .../file/AbstractNewDataSourceHandler.java | 37 +++++++++---------- .../FullDataSourceProviderV2.java | 3 +- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java index 1495dc2a4..499e812d1 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/AbstractNewDataSourceHandler.java @@ -98,9 +98,6 @@ public abstract class AbstractNewDataSourceHandler protected abstract TDataSource createDataSourceFromDto(TDTO dto) throws InterruptedException, IOException; protected abstract TDTO createDtoFromDataSource(TDataSource dataSource); - /** Creates a new data source using any DTOs already present in the database. */ - protected abstract TDataSource createNewDataSourceFromExistingDtos(DhSectionPos pos); - protected abstract TDataSource makeEmptyDataSource(DhSectionPos pos); @@ -153,8 +150,10 @@ public abstract class AbstractNewDataSourceHandler } else { - // attempt to create from any existing files - dataSource = this.createNewDataSourceFromExistingDtos(pos); + // 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); } } catch (InterruptedException ignore) { } @@ -228,29 +227,27 @@ public abstract class AbstractNewDataSourceHandler updateLock.lock(); this.lockedPosSet.add(updatePos); } - else - { - methodLocked = false; - } // get or create the data source try (TDataSource recipientDataSource = this.get(updatePos)) { - boolean dataModified = recipientDataSource.update(inputData, this.level); - - if (dataModified) + if (recipientDataSource != null) { - // save the updated data to the database - TDTO dto = this.createDtoFromDataSource(recipientDataSource); - this.repo.save(dto); - - - for (IDataSourceUpdateFunc listener : this.dateSourceUpdateListeners) + boolean dataModified = recipientDataSource.update(inputData, this.level); + if (dataModified) { - if (listener != null) + // save the updated data to the database + TDTO dto = this.createDtoFromDataSource(recipientDataSource); + this.repo.save(dto); + + + for (IDataSourceUpdateFunc listener : this.dateSourceUpdateListeners) { - listener.OnDataSourceUpdated(recipientDataSource); + if (listener != null) + { + listener.OnDataSourceUpdated(recipientDataSource); + } } } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java index ced9c204e..769ff34d5 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataSourceProviderV2.java @@ -260,7 +260,8 @@ public class FullDataSourceProviderV2 try (FullDataSourceV2 dataSource = this.get(childPos)) { - if (dataSource != null) // can return null when the file handler is being shut down + // can return null when the file handler is being shut down + if (dataSource != null) { this.updateDataSourceAtPos(parentUpdatePos, dataSource, false); this.repo.setApplyToParent(childPos, false);