Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ dependencies {

annotationProcessor depLibs.lombok
testAnnotationProcessor depLibs.lombok
testImplementation depLibs.junit
}

jar {
Expand Down
8 changes: 8 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ plugins {
id "com.github.vlsi.stage-vote-release" version "1.73"
id 'checkstyle'
id 'org.nosphere.apache.rat'
id 'com.github.spotbugs'
}

subprojects {
Expand Down Expand Up @@ -68,6 +69,7 @@ allprojects {
apply plugin: 'signing'
apply plugin: 'org.nosphere.apache.rat'
apply plugin: "checkstyle"
apply plugin: 'com.github.spotbugs'
checkstyle {
toolVersion "${checkStyleVersion}"
configFile file("$rootDir/buildtools/src/main/resources/bookkeeper/checkstyle.xml")
Expand All @@ -79,6 +81,12 @@ allprojects {
source ='src/test/java'
}
}

spotbugs {
toolVersion = '3.1.8'
excludeFilter = file("$rootDir/buildtools/src/main/resources/bookkeeper/findbugsExclude.xml")
reportLevel = 'high'
}

task testJar(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
Expand Down
160 changes: 160 additions & 0 deletions buildtools/src/main/resources/bookkeeper/findbugsExclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,164 @@
<Match>
<Class name="~org.apache.bookkeeper.proto.statestore.*" />
</Match>

<!-- Java array itself can be made const but contents for it can always be modified -->
<Match>
<Class name="org.apache.bookkeeper.statelib.impl.Constants" />
<Bug pattern="MS_MUTABLE_ARRAY"/>
</Match>

<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~org\.apache\.distributedlog\.tests\.generated.*" />
</Match>
<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~org\.apache\.distributedlog\.thrift.*" />
</Match>
<!-- distributedlog-benchmark -->
<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~org\.apache\.distributedlog\.benchmark\.thrift.*" />
</Match>
<!-- distributedlog-common -->
<Match>
<Class name="org.apache.distributedlog.util.OrderedScheduler"/>
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS" />
</Match>
<!-- distributedlog-core -->
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.Entry$Builder" />
<Method name="setData" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.Entry" />
<Method name="getRawData" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<Match>
<Class name="org.apache.distributedlog.BKAsyncLogReader" />
<Method name="run" />
<Bug pattern="JLM_JSR166_UTILCONCURRENT_MONITORENTER" />
</Match>
<Match>
<Class name="org.apache.distributedlog.BKLogReadHandler$1" />
<Method name="onSuccess" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.BookKeeperClient$2" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.ReadUtils" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.ReadUtils$2" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.auditor.DLAuditor$2" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.auditor.DLAuditor$8" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.bk.SimpleLedgerAllocator$4" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.bk.SimpleLedgerAllocator$4$1" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.bk.SimpleLedgerAllocator$5" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.impl.acl.ZKAccessControl$4" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.impl.acl.ZKAccessControlManager$1" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.impl.acl.ZKAccessControlManager$1$1" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.impl.metadata.ZKLogStreamMetadataStore$1$1" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.lock.ZKSessionLock" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.lock.ZKSessionLock$12" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.lock.ZKSessionLock$13$1" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.util.Utils" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<Match>
<Class name="org.apache.distributedlog.util.Utils$6" />
<Bug pattern="NP_NONNULL_PARAM_VIOLATION" />
</Match>
<!-- distributedlog-protocol -->
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.LogRecord" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.LogRecord" />
<Method name="getPayload" />
<Bug pattern="EI_EXPOSE_REP" />
</Match>
<!-- distributedlog-proxy-server -->
<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~org\.apache\.distributedlog\.service\.placement\.thrift.*" />
</Match>
<Match>
<!-- it is safe to cast exception here. //-->
<Class name="org.apache.distributedlog.service.DistributedLogServiceImpl$Stream$2" />
<Method name="onFailure" />
<Bug pattern="BC_UNCONFIRMED_CAST" />
</Match>
<Match>
<!-- it is safe to cast exception here. //-->
<Class name="org.apache.distributedlog.service.stream.BulkWriteOp" />
<Method name="isDefiniteFailure" />
<Bug pattern="BC_IMPOSSIBLE_INSTANCEOF" />
</Match>
<!-- distributedlog-messaging -->
<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~.*\.TransformedRecord" />
</Match>
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.messaging.PartitionedMultiWriter" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.messaging.RRMultiWriter" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
</FindBugsFilter>
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ apcheRatPluginVersion=0.7.0
shadowPluginVersion=6.1.0
licenseGradlePluginVersion=0.15.0
checkStyleVersion=6.19
spotbugsPlugin=4.7.0
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pluginManagement {
id "org.nosphere.apache.rat" version "${apcheRatPluginVersion}"
id "com.github.johnrengelman.shadow" version "${shadowPluginVersion}"
id "com.github.hierynomus.license" version "${licenseGradlePluginVersion}"
id "com.github.spotbugs" version "${spotbugsPlugin}"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ synchronized RangeResult<K, V> processRange(RangeOp<K, V> rangeOp) {

// raw key
byte[] rawKey = (null != key) ? keyCoder.encode(key) : NULL_START_KEY;

byte[] rawEndKey = NULL_END_KEY;
if (null == endKey) {
// point lookup
MVCCRecord record = getKeyRecord(key, rawKey);
Expand All @@ -988,8 +988,9 @@ synchronized RangeResult<K, V> processRange(RangeOp<K, V> rangeOp) {
record.recycle();
}
}
} else {
rawEndKey = keyCoder.encode(endKey);
}
byte[] rawEndKey = (null != endKey) ? keyCoder.encode(endKey) : NULL_END_KEY;
Pair<byte[], byte[]> realRange = getRealRange(rawKey, rawEndKey);
rawKey = realRange.getLeft();
rawEndKey = realRange.getRight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private void loadMetadata(List<KeyValue<byte[], byte[]>> kvs) {
}
}

private void loadStreamMetadata(long streamId, byte[] streamMetadataBytes) {
private synchronized void loadStreamMetadata(long streamId, byte[] streamMetadataBytes) {
this.streamId = streamId;
StreamMetadata metadata;
try {
Expand Down