From 73a819362bc7318aa2d44750b779bde3f2627c28 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2020 19:01:38 +0100 Subject: [PATCH 1/2] Bump byte-buddy-parent from 1.10.17 to 1.10.18 (#7059) Bumps [byte-buddy-parent](https://github.com/raphw/byte-buddy) from 1.10.17 to 1.10.18. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.10.17...byte-buddy-1.10.18) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index d60add7d268..e58b659c2a7 100644 --- a/build.gradle +++ b/build.gradle @@ -204,7 +204,7 @@ dependencies { testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.0' testImplementation 'org.junit.platform:junit-platform-launcher:1.7.0' - testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.17' + testImplementation 'net.bytebuddy:byte-buddy-parent:1.10.18' testRuntime group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT' testRuntime group: 'org.apache.logging.log4j', name: 'log4j-jul', version: '3.0.0-SNAPSHOT' testImplementation 'org.mockito:mockito-core:3.6.0' From b5bcea4506b034975de3363a12efb7d56caa9f01 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 3 Nov 2020 19:54:54 +0100 Subject: [PATCH 2/2] Fix Shared Database Tests (#7040) * Fix Shared Database Tests Fix FieldChangeEvent Delta computation * Use length directly foir comparision * upgrade postgres to 13 rename delta to majorCharacterChange * revert unrelated change --- .github/workflows/tests.yml | 2 +- .../jabref/logic/util/CoarseChangeFilter.java | 2 +- .../model/entry/event/FieldChangedEvent.java | 20 ++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8272f44b43f..fe57e60d3d0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -91,7 +91,7 @@ jobs: runs-on: ubuntu-latest services: postgres: - image: postgres:10.8 + image: postgres:13-alpine env: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres diff --git a/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java b/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java index ead72efe4d5..ed3ef873aaa 100644 --- a/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java +++ b/src/main/java/org/jabref/logic/util/CoarseChangeFilter.java @@ -46,7 +46,7 @@ public synchronized void listen(BibDatabaseContextChangedEvent event) { boolean isChangedEntry = lastEntryChanged.filter(e -> !e.equals(fieldChange.getBibEntry())).isPresent(); boolean isEditChanged = !isNewEdit && (isChangedField || isChangedEntry); // Only deltas of 1 when typing in manually, major change means pasting something (more than one character) - boolean isMajorChange = fieldChange.getDelta() > 1; + boolean isMajorChange = fieldChange.getMajorCharacterChange() > 1; fieldChange.setFilteredOut(!(isEditChanged || isMajorChange)); // Post each FieldChangedEvent - even the ones being marked as "filtered" diff --git a/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java b/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java index 45d9ae2ec1d..3f4eda3838e 100644 --- a/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java +++ b/src/main/java/org/jabref/model/entry/event/FieldChangedEvent.java @@ -12,7 +12,7 @@ public class FieldChangedEvent extends EntryChangedEvent { private final Field field; private final String newValue; private final String oldValue; - private int delta = 0; + private int majorCharacterChange = 0; /** * @param bibEntry Affected BibEntry object @@ -27,7 +27,7 @@ public FieldChangedEvent(BibEntry bibEntry, Field field, String newValue, String this.field = field; this.newValue = newValue; this.oldValue = oldValue; - this.delta = computeDelta(oldValue, newValue); + this.majorCharacterChange = computeMajorCharacterChange(oldValue, newValue); } /** @@ -40,7 +40,7 @@ public FieldChangedEvent(BibEntry bibEntry, Field field, String newValue, String this.field = field; this.newValue = newValue; this.oldValue = oldValue; - this.delta = computeDelta(oldValue, newValue); + this.majorCharacterChange = computeMajorCharacterChange(oldValue, newValue); } /** @@ -51,20 +51,22 @@ public FieldChangedEvent(FieldChange fieldChange, EntriesEventSource location) { this.field = fieldChange.getField(); this.newValue = fieldChange.getNewValue(); this.oldValue = fieldChange.getOldValue(); - this.delta = computeDelta(oldValue, newValue); + this.majorCharacterChange = computeMajorCharacterChange(oldValue, newValue); } public FieldChangedEvent(FieldChange fieldChange) { this(fieldChange, EntriesEventSource.LOCAL); } - private int computeDelta(String oldValue, String newValue) { + private int computeMajorCharacterChange(String oldValue, String newValue) { if (oldValue == newValue) { return 0; - } else if (oldValue == null && newValue != null) { + } else if ((oldValue == null) && (newValue != null)) { return newValue.length(); - } else if (newValue == null && oldValue != null) { + } else if ((newValue == null) && (oldValue != null)) { return oldValue.length(); + } else if ((oldValue.length() == newValue.length()) && !oldValue.equals(newValue)) { + return newValue.length(); } else { return Math.abs(newValue.length() - oldValue.length()); } @@ -82,7 +84,7 @@ public String getOldValue() { return oldValue; } - public int getDelta() { - return delta; + public int getMajorCharacterChange() { + return majorCharacterChange; } }