From 8c357cfc256c8dde5ce198bc4ddc1722a2d7cf5e Mon Sep 17 00:00:00 2001 From: Nathaniel Date: Sat, 6 Jan 2024 14:51:41 -0700 Subject: [PATCH] fix bug when no changes are attempted to save --- build.gradle | 2 +- .../tables/connection/ConnectionHandler.java | 13 +++++++++++++ .../library/database/tables/table/DataTable.java | 6 ++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0d61bbd..e56b78e 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'com.nucleodb' -version = '1.14.3' +version = '1.14.4' repositories { mavenCentral() diff --git a/src/main/java/com/nucleodb/library/database/tables/connection/ConnectionHandler.java b/src/main/java/com/nucleodb/library/database/tables/connection/ConnectionHandler.java index 23f6e80..09e789c 100644 --- a/src/main/java/com/nucleodb/library/database/tables/connection/ConnectionHandler.java +++ b/src/main/java/com/nucleodb/library/database/tables/connection/ConnectionHandler.java @@ -451,6 +451,13 @@ private boolean saveInternal(Connection connection, String changeUUID) { connection.versionIncrease(); List changes = null; Connection oldConnection = connectionByUUID.get(connection.getUuid()); + if(oldConnection==null){ + try { + consumerResponse(null, changeUUID); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } + } JsonPatch patch = JsonDiff.asJsonPatch(fromObject(oldConnection), fromObject(connection)); try { String json = Serializer.getObjectMapper().getOmNonType().writeValueAsString(patch); @@ -459,6 +466,12 @@ private boolean saveInternal(Connection connection, String changeUUID) { ConnectionUpdate updateEntry = new ConnectionUpdate(connection.getVersion(), json, changeUUID, connection.getUuid()); producer.push(updateEntry.getUuid(), updateEntry.getVersion(), updateEntry, null); return true; + }else{ + try { + consumerResponse(null, changeUUID); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } } } catch (JsonProcessingException e) { throw new RuntimeException(e); diff --git a/src/main/java/com/nucleodb/library/database/tables/table/DataTable.java b/src/main/java/com/nucleodb/library/database/tables/table/DataTable.java index bd4a848..e121e64 100644 --- a/src/main/java/com/nucleodb/library/database/tables/table/DataTable.java +++ b/src/main/java/com/nucleodb/library/database/tables/table/DataTable.java @@ -555,6 +555,12 @@ private boolean saveInternal(DataEntry entry, String changeUUID) { Update updateEntry = new Update(changeUUID, entry, json); producer.push(updateEntry.getKey(), updateEntry.getVersion(), updateEntry, null); return true; + }else{ + try { + consumerResponse(null, changeUUID); + } catch (ExecutionException e) { + throw new RuntimeException(e); + } } } catch (JsonProcessingException e) { e.printStackTrace();