Skip to content

Commit c10668d

Browse files
authored
Fix LiteCore callback signature and spotbugs stuff (#471)
1 parent 3fb6a7b commit c10668d

9 files changed

Lines changed: 13 additions & 18 deletions

File tree

common/main/cpp/native_c4multipeerreplicator.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,8 @@ namespace litecore::jni {
286286
// Callbacks
287287
//-------------------------------------------------------------------------
288288

289-
static void statusChangedCallback(C4PeerSync *ignored, bool started, C4Error error, void *context) {
289+
static void statusChangedCallback(C4PeerSync *ignored, C4PeerSyncProtocol protocol, bool started, C4Error error, void *context) {
290+
// TODO: Use protocol
290291
JNIEnv *env = nullptr;
291292
jint envState = attachJVM(&env, "p2pStatusChanged");
292293
if ((envState != JNI_OK) && (envState != JNI_EDETACHED))

common/main/java/com/couchbase/lite/BaseDatabase.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
import androidx.annotation.Nullable;
2121
import androidx.annotation.VisibleForTesting;
2222

23-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
24-
2523
import com.couchbase.lite.internal.core.C4BlobStore;
2624
import com.couchbase.lite.internal.core.C4Database;
2725
import com.couchbase.lite.internal.logging.Log;
@@ -104,7 +102,6 @@ protected C4Database getC4DbOrThrowLocked() throws CouchbaseLiteException {
104102
}
105103

106104
@VisibleForTesting
107-
@SuppressFBWarnings("NP_NONNULL_RETURN_VIOLATION")
108105
@NonNull
109106
C4Database getOpenC4Database() {
110107
synchronized (getDbLock()) { return getOpenC4DbLocked(); }

common/main/java/com/couchbase/lite/Blob.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,6 @@ private C4BlobKey getBlobKey(@NonNull C4BlobStore store) throws LiteCoreExceptio
655655
throw new CouchbaseLiteError(Log.lookupStandardMessage("BlobContentNull"));
656656
}
657657

658-
@SuppressFBWarnings("DE_MIGHT_IGNORE")
659658
private void readContentFromInitStream() {
660659
final ByteArrayOutputStream out = new ByteArrayOutputStream();
661660
try (InputStream in = Preconditions.assertNotNull(blobContentStream, "content stream")) {

common/main/java/com/couchbase/lite/Collection.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import java.util.Set;
2727
import java.util.concurrent.Executor;
2828

29-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
30-
3129
import com.couchbase.lite.internal.BaseCollection;
3230
import com.couchbase.lite.internal.CouchbaseLiteInternal;
3331
import com.couchbase.lite.internal.core.C4Collection;
@@ -919,7 +917,6 @@ private boolean saveConflicted(@NonNull Document document, boolean deleting) thr
919917

920918
// Low-level save method
921919
@GuardedBy("getDbLock()")
922-
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
923920
private void saveInTransaction(@NonNull Document document, @Nullable C4Document base, boolean deleting)
924921
throws CouchbaseLiteException {
925922
FLSliceResult body = null;

common/main/java/com/couchbase/lite/internal/core/C4Peer.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.util.concurrent.LinkedBlockingQueue;
2424
import java.util.concurrent.atomic.AtomicReference;
2525

26-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
27-
2826
import com.couchbase.lite.CouchbaseLiteError;
2927
import com.couchbase.lite.LogDomain;
3028
import com.couchbase.lite.internal.CouchbaseLiteInternal;
@@ -84,7 +82,6 @@ private static class PeerHolder implements Cleaner.Cleanable {
8482
/**
8583
* Cleanup: Release the native peer.
8684
*/
87-
@SuppressFBWarnings("JLM_JSR166_UTILCONCURRENT_MONITORENTER")
8885
public final void clean(boolean finalizing) {
8986
final C4Peer.PeerCleaner disposer = cleaner;
9087
if (disposer != null) {

common/main/java/com/couchbase/lite/internal/core/C4Socket.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import java.util.concurrent.Executor;
2323
import java.util.concurrent.atomic.AtomicReference;
2424

25-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
26-
2725
import com.couchbase.lite.LogDomain;
2826
import com.couchbase.lite.internal.BaseSocketFactory;
2927
import com.couchbase.lite.internal.CouchbaseLiteInternal;
@@ -186,8 +184,6 @@ static void open(
186184
}
187185

188186
// This method is used by reflection. Don't change its signature.
189-
// Apparently SpotBugs can't tel that `data` *is* null-checked
190-
@SuppressFBWarnings("NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE")
191187
static void write(long peer, @Nullable byte[] data) {
192188
final int nBytes = (data == null) ? 0 : data.length;
193189
Log.d(LOG_DOMAIN, "^C4Socket.write@%x(%d)", peer, nBytes);

common/main/java/com/couchbase/lite/internal/sockets/OkHttpSocket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ private interface SocketFactory {
7474

7575
.build();
7676

77+
@SuppressWarnings("PMD.CloseResource")
7778
public static void shutdownHttpClient() {
7879
final ExecutorService dispatcher = BASE_HTTP_CLIENT.dispatcher().executorService();
7980
ExecutorUtils.shutdownAndAwaitTermination(dispatcher, 5, LogDomain.NETWORK);

common/main/java/com/couchbase/lite/internal/utils/FileUtils.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import java.io.InputStream;
2424
import java.io.OutputStream;
2525

26-
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
27-
2826
import com.couchbase.lite.CouchbaseLiteError;
2927
import com.couchbase.lite.LogDomain;
3028
import com.couchbase.lite.internal.logging.Log;
@@ -70,7 +68,6 @@ public static boolean deleteContents(String fileOrDirectory) {
7068
return deleteContents((fileOrDirectory == null) ? null : new File(fileOrDirectory));
7169
}
7270

73-
@SuppressFBWarnings({"RV_RETURN_VALUE_IGNORED_BAD_PRACTICE"})
7471
public static boolean deleteContents(File fileOrDirectory) {
7572
if ((fileOrDirectory == null) || (!fileOrDirectory.isDirectory())) { return true; }
7673

etc/spotbugs/spotbugs.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,14 @@
2828
<Bug pattern="SF_SWITCH_NO_DEFAULT" />
2929
</Match>
3030

31+
<!-- Constructor throws are pre-existing in the API design -->
32+
<Match>
33+
<Bug pattern="CT_CONSTRUCTOR_THROW" />
34+
</Match>
35+
36+
<!-- Java 8 synthetic accessors and annotation staleness: not actionable -->
37+
<Match>
38+
<Bug pattern="AT_STALE_THREAD_WRITE_OF_PRIMITIVE" />
39+
</Match>
40+
3141
</FindBugsFilter>

0 commit comments

Comments
 (0)