From 0947834ac950fb4dd59b719cbdddc1726e68674b Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 11 Jan 2007 23:19:44 +0000 Subject: Fixes for bugs found using FindBugs. --- .../com/amazon/carbonado/repo/indexed/IndexedRepository.java | 4 ++-- .../carbonado/repo/replicated/ReplicatedRepository.java | 6 +++++- .../com/amazon/carbonado/repo/sleepycat/BDBRepository.java | 12 ++++++------ 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/amazon/carbonado/repo') diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java index 6fc6d57..b9380fc 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/IndexedRepository.java @@ -169,12 +169,12 @@ class IndexedRepository implements Repository, public boolean isSupported(Class type) { StorableInfoCapability cap = mRepository.getCapability(StorableInfoCapability.class); - return (cap == null) ? null : cap.isSupported(type); + return (cap == null) ? false : cap.isSupported(type); } public boolean isPropertySupported(Class type, String name) { StorableInfoCapability cap = mRepository.getCapability(StorableInfoCapability.class); - return (cap == null) ? null : cap.isPropertySupported(type, name); + return (cap == null) ? false : cap.isPropertySupported(type, name); } public void close() { diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java index 5edc42c..c292d9c 100644 --- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedRepository.java @@ -385,7 +385,7 @@ class ReplicatedRepository if (orderBy == null) { Set pkSet = StorableIntrospector.examine(type).getPrimaryKeyProperties().keySet(); - orderBy = pkSet.toArray(new String[0]); + orderBy = pkSet.toArray(new String[pkSet.size()]); } } @@ -565,11 +565,15 @@ class ReplicatedRepository lastMasterEntry = masterEntry; masterEntry = null; } else { + // If compare is zero, replicaEntry and masterEntry are + // either both null or both non-null. + if (replicaEntry == null && masterEntry == null) { // Both cursors exhausted -- resync is complete. break; } + // Both replicaEntry and masterEntry are non-null. if (!replicaEntry.equalProperties(masterEntry)) { // Replica is stale. resyncTask = prepareResyncTask(trigger, replicaEntry, masterEntry); diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java index 6aeb89e..7792536 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java @@ -718,6 +718,7 @@ abstract class BDBRepository } finally { synchronized (this) { mInProgress = false; + // Only wait condition is mInProgress, so okay to not call notifyAll. notify(); } repository = null; @@ -726,6 +727,7 @@ abstract class BDBRepository } finally { synchronized (this) { mInProgress = false; + // Only wait condition is mInProgress, so okay to not call notifyAll. notify(); } } @@ -802,12 +804,10 @@ abstract class BDBRepository public void run() { while (true) { - synchronized (this) { - try { - wait(mSleepInterval); - } catch (InterruptedException e) { - break; - } + try { + Thread.sleep(mSleepInterval); + } catch (InterruptedException e) { + break; } BDBRepository repository = mRepository.get(); -- cgit v1.2.3