diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2008-03-25 05:38:00 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2008-03-25 05:38:00 +0000 |
commit | 3db26bff365de7d2d4e7fc45ad31b8104c78a0ae (patch) | |
tree | a32ea36c3e356311559d984a4d61524193869f55 /src/main/java | |
parent | 5ad29e976d528214c6e26065f2fb39126a5ae10a (diff) |
Fixes for bugs as reported by FindBugs.
Diffstat (limited to 'src/main/java')
10 files changed, 25 insertions, 17 deletions
diff --git a/src/main/java/com/amazon/carbonado/filter/BinaryOpFilter.java b/src/main/java/com/amazon/carbonado/filter/BinaryOpFilter.java index 640c0ae..ffe81e7 100644 --- a/src/main/java/com/amazon/carbonado/filter/BinaryOpFilter.java +++ b/src/main/java/com/amazon/carbonado/filter/BinaryOpFilter.java @@ -69,11 +69,11 @@ public abstract class BinaryOpFilter<S extends Storable> extends Filter<S> { return accept(new Binder<S>(), null);
}
- public boolean isBound() {
+ public synchronized boolean isBound() {
return (mState & BOUND) != 0;
}
- void markBound() {
+ synchronized void markBound() {
mState |= BOUND;
}
diff --git a/src/main/java/com/amazon/carbonado/filter/FilterValues.java b/src/main/java/com/amazon/carbonado/filter/FilterValues.java index 954d3ac..6e7202c 100644 --- a/src/main/java/com/amazon/carbonado/filter/FilterValues.java +++ b/src/main/java/com/amazon/carbonado/filter/FilterValues.java @@ -36,6 +36,8 @@ import com.amazon.carbonado.util.Appender; * @author Brian S O'Neill
*/
public class FilterValues<S extends Storable> implements Serializable, Appender {
+ private static final long serialVersionUID = 1L;
+
private static final Object[] NO_VALUES = new Object[0];
static <S extends Storable> FilterValues<S>
diff --git a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java index d30fc8f..65151e8 100644 --- a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java +++ b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java @@ -395,7 +395,7 @@ public class ChainedProperty<S extends Storable> implements Serializable, Append System.arraycopy(mOuterJoin, 0, newOuterJoin, 0, mOuterJoin.length);
}
System.arraycopy(property.mOuterJoin, 0,
- newOuterJoin, mOuterJoin.length,
+ newOuterJoin, getChainCount() + 1,
property.mOuterJoin.length);
}
diff --git a/src/main/java/com/amazon/carbonado/qe/PropertyFilterList.java b/src/main/java/com/amazon/carbonado/qe/PropertyFilterList.java index 279430c..c58aacb 100644 --- a/src/main/java/com/amazon/carbonado/qe/PropertyFilterList.java +++ b/src/main/java/com/amazon/carbonado/qe/PropertyFilterList.java @@ -155,7 +155,7 @@ class PropertyFilterList<S extends Storable> extends AbstractList<PropertyFilter }
private static class PFComparator<S extends Storable>
- implements Comparator<PropertyFilter<S>>
+ implements Comparator<PropertyFilter<S>>, java.io.Serializable
{
public int compare(PropertyFilter<S> a, PropertyFilter<S> b) {
if (a.getOperator() != b.getOperator()) {
diff --git a/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java b/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java index 976d5a1..7055b21 100644 --- a/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java +++ b/src/main/java/com/amazon/carbonado/qe/StorableIndexSet.java @@ -472,7 +472,9 @@ public class StorableIndexSet<S extends Storable> extends TreeSet<StorableIndex< * Orders indexes such that they are grouped by property names. Within
* those groups, indexes are ordered most qualified to least qualified.
*/
- private static class StorableIndexComparator implements Comparator<StorableIndex<?>> {
+ private static class StorableIndexComparator
+ implements Comparator<StorableIndex<?>>, java.io.Serializable
+ {
public int compare(StorableIndex<?> a, StorableIndex<?> b) {
if (a == b) {
return 0;
diff --git a/src/main/java/com/amazon/carbonado/raw/DataEncoder.java b/src/main/java/com/amazon/carbonado/raw/DataEncoder.java index 1049644..6eebc93 100644 --- a/src/main/java/com/amazon/carbonado/raw/DataEncoder.java +++ b/src/main/java/com/amazon/carbonado/raw/DataEncoder.java @@ -44,11 +44,6 @@ public class DataEncoder { /** Byte to use for not-null, high ordering */
static final byte NOT_NULL_BYTE_LOW = (byte)~NOT_NULL_BYTE_HIGH;
- static final byte[] NULL_BYTE_ARRAY_HIGH = {NULL_BYTE_HIGH};
- static final byte[] NULL_BYTE_ARRAY_LOW = {NULL_BYTE_LOW};
- static final byte[] NOT_NULL_BYTE_ARRAY_HIGH = {NOT_NULL_BYTE_HIGH};
- static final byte[] NOT_NULL_BYTE_ARRAY_LOW = {NOT_NULL_BYTE_LOW};
-
/**
* Encodes the given signed integer into exactly 4 bytes.
*
@@ -604,12 +599,12 @@ public class DataEncoder { public static byte[] encodeSingleNullable(byte[] value, int prefixPadding, int suffixPadding) {
if (prefixPadding <= 0 && suffixPadding <= 0) {
if (value == null) {
- return NULL_BYTE_ARRAY_HIGH;
+ return new byte[] {NULL_BYTE_HIGH};
}
int length = value.length;
if (length == 0) {
- return NOT_NULL_BYTE_ARRAY_HIGH;
+ return new byte[] {NOT_NULL_BYTE_HIGH};
}
byte[] dst = new byte[1 + length];
diff --git a/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java b/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java index 44c5af5..5b11586 100644 --- a/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java +++ b/src/main/java/com/amazon/carbonado/raw/KeyEncoder.java @@ -708,12 +708,12 @@ public class KeyEncoder extends DataEncoder { int prefixPadding, int suffixPadding) {
if (prefixPadding <= 0 && suffixPadding <= 0) {
if (value == null) {
- return NULL_BYTE_ARRAY_LOW;
+ return new byte[] {NULL_BYTE_LOW};
}
int length = value.length;
if (length == 0) {
- return NOT_NULL_BYTE_ARRAY_LOW;
+ return new byte[] {NOT_NULL_BYTE_LOW};
}
byte[] dst = new byte[1 + length];
diff --git a/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java b/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java index 21c7215..9e69935 100644 --- a/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java +++ b/src/main/java/com/amazon/carbonado/repo/indexed/DerivedIndexesTrigger.java @@ -92,6 +92,11 @@ class DerivedIndexesTrigger<S extends Storable, D extends Storable> extends Trig }
@Override
+ public int hashCode() {
+ return mFetcher.hashCode();
+ }
+
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
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 4bf4e2b..f12a58e 100644 --- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java +++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java @@ -553,8 +553,12 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn> break;
}
- if (mSuspendUntil != Long.MIN_VALUE) {
- if (System.currentTimeMillis() < mSuspendUntil) {
+ long suspendUntil;
+ synchronized (this) {
+ suspendUntil = mSuspendUntil;
+ }
+ if (suspendUntil != Long.MIN_VALUE) {
+ if (System.currentTimeMillis() < suspendUntil) {
continue;
}
}
diff --git a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java index b73a9ce..3cfc94f 100644 --- a/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java +++ b/src/main/java/com/amazon/carbonado/spi/AbstractRepositoryBuilder.java @@ -62,7 +62,7 @@ public abstract class AbstractRepositoryBuilder implements RepositoryBuilder { public Iterable<TriggerFactory> getTriggerFactories() {
synchronized (mTriggerFactories) {
- if (mTriggerFactories == null || mTriggerFactories.size() == 0) {
+ if (mTriggerFactories.size() == 0) {
return Collections.emptyList();
} else {
return new ArrayList<TriggerFactory>(mTriggerFactories);
|