Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spotbug check failed test #27

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
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
48 changes: 47 additions & 1 deletion .github/workflows/bk-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,16 @@ jobs:
distribution: 'temurin'
java-version: 11

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: Validate pull request
if: steps.check_changes.outputs.docs_only != 'true'
run: mvn clean -T 1C -B -nsu apache-rat:check checkstyle:check spotbugs:check package -Ddistributedlog -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
run: |
mvn -T 1C -B -nsu clean install -Ddistributedlog -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO
mvn -T 1C -B -nsu apache-rat:check checkstyle:check spotbugs:check package -Ddistributedlog -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO

- name: Check license files
if: steps.check_changes.outputs.docs_only != 'true'
Expand Down Expand Up @@ -152,6 +159,11 @@ jobs:
distribution: 'temurin'
java-version: 11

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: Build
run: |
projects_list=
Expand Down Expand Up @@ -194,6 +206,10 @@ jobs:
path: surefire-reports
retention-days: 7

- name: Setup tmate session
if: failure()
uses: mxschmitt/action-tmate@v3

integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -223,6 +239,11 @@ jobs:
distribution: 'temurin'
java-version: 11

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: Build with Maven
run: mvn -B -nsu clean install -Pdocker -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO

Expand Down Expand Up @@ -265,6 +286,11 @@ jobs:
distribution: 'temurin'
java-version: 8

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: Build with Maven
run: mvn -B -nsu clean install -DskipTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO

Expand Down Expand Up @@ -311,6 +337,11 @@ jobs:
distribution: 'temurin'
java-version: 11

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: mvn package
run: mvn -B -nsu clean package -DskipTests

Expand Down Expand Up @@ -343,6 +374,11 @@ jobs:
distribution: 'temurin'
java-version: 11

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: mvn package
run: mvn -B -nsu clean package -DskipTests

Expand Down Expand Up @@ -387,6 +423,11 @@ jobs:
distribution: 'temurin'
java-version: ${{ matrix.jdk_version }}

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: Build with Maven
run: mvn clean package -B -nsu -DskipBookKeeperServerTests -Dorg.slf4j.simpleLogger.defaultLogLevel=INFO

Expand Down Expand Up @@ -422,6 +463,11 @@ jobs:
with:
java-version: 11

- name: Set up Maven
uses: apache/pulsar-test-infra/setup-maven@master
with:
maven-version: 3.8.7

- name: run "clean install verify" to trigger dependency check
# excluding dlfs because it includes hadoop lib with
# CVEs that we cannot patch up anyways
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.apache.bookkeeper.proto.BookieProtocol.FLAG_RECOVERY_ADD;

import com.google.common.collect.ImmutableMap;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.buffer.ByteBuf;
import io.netty.util.Recycler;
import io.netty.util.Recycler.Handle;
Expand Down Expand Up @@ -80,6 +81,7 @@ class PendingAddOp implements WriteCallback {
boolean allowFailFast = false;
List<BookieId> ensemble;

@SuppressFBWarnings("IS2_INCONSISTENT_SYNC")
static PendingAddOp create(LedgerHandle lh, ClientContext clientCtx,
List<BookieId> ensemble,
ByteBuf payload, EnumSet<WriteFlag> writeFlags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void bestEffortRemoveFromPageCache(int fd, long offset, long len)
}
try {
NATIVE_IO.posix_fadvise(fd, offset, len, POSIX_FADV_DONTNEED);
} catch (Exception e) {
} catch (Throwable e) {
log.warn("Failed to perform posix_fadvise: {}", e.getMessage());
fadvisePossible = false;
}
Expand Down
5 changes: 5 additions & 0 deletions buildtools/src/main/resources/bookkeeper/findbugsExclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~.*\.TransformedRecord" />
</Match>
<!-- micro-benchmarks -->
<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~org\.apache\.bookkeeper\.bookie\.generated.*" />
</Match>
<Match>
<!-- it is safe to store external bytes reference here. //-->
<Class name="org.apache.distributedlog.messaging.PartitionedMultiWriter" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.bookie.storage.ldb.ArrayGroupSort;
import org.openjdk.jmh.annotations.Benchmark;
Expand Down Expand Up @@ -55,7 +56,7 @@ public static class TestState {
private long[] items;

public TestState() {
Random r = new Random();
Random r = ThreadLocalRandom.current();
for (int i = 0; i < (N * 4); i++) {
randomItems[i] = r.nextLong();
}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<os-maven-plugin.version>1.4.1.Final</os-maven-plugin.version>
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
<puppycrawl.checkstyle.version>9.3</puppycrawl.checkstyle.version>
<spotbugs-maven-plugin.version>4.6.0.0</spotbugs-maven-plugin.version>
<spotbugs-maven-plugin.version>4.7.3.2</spotbugs-maven-plugin.version>
<forkCount.variable>1</forkCount.variable>
<servlet-api.version>4.0.0</servlet-api.version>
<rxjava.version>3.0.1</rxjava.version>
Expand Down Expand Up @@ -1118,7 +1118,7 @@
<version>${maven-surefire-plugin.version}</version>
<configuration>
<!-- @{argLine} is a variable injected by JaCoCo-->
<argLine>@{argLine} -Xmx2G -Djava.net.preferIPv4Stack=true -Dio.netty.leakDetection.level=paranoid</argLine>
<argLine>-Xmx2G -Djava.net.preferIPv4Stack=true -Dio.netty.leakDetection.level=paranoid ${test.additional.args}</argLine>
<redirectTestOutputToFile>${redirectTestOutputToFile}</redirectTestOutputToFile>
<forkCount>${forkCount.variable}</forkCount>
<reuseForks>false</reuseForks>
Expand Down