Skip to content

Commit

Permalink
[Branch-4.15] Fix the CI spotbugs failure in the branch-4.15 (#4150)
Browse files Browse the repository at this point in the history
### Motivation

Fix the CI spotbugs failure in the branch-4.15
  • Loading branch information
zymap committed Dec 12, 2023
1 parent 827293c commit 9f3be1c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public HttpServiceResponse handle(HttpServiceRequest request) throws Exception {
try {
if (HttpServer.Method.PUT == request.getMethod()) {
String requestBody = request.getBody();
if (StringUtils.isBlank(requestBody)) {
if (requestBody == null || StringUtils.isEmpty(requestBody.trim())) {
bookieServer.getBookie().getLedgerStorage().forceGC();
} else {
@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1}");
resp = service.handle(request);
verify(mockLedgerStorage, times(1)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(1)).forceGC(eq(false), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -91,7 +91,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMajor\":true}");
resp = service.handle(request);
verify(mockLedgerStorage, times(2)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(1)).forceGC(eq(true), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -101,7 +101,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMajor\":\"true\"}");
resp = service.handle(request);
verify(mockLedgerStorage, times(3)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(2)).forceGC(eq(true), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -111,7 +111,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMajor\":false}");
resp = service.handle(request);
verify(mockLedgerStorage, times(1)).forceGC(eq(false), eq(true));
verify(mockLedgerStorage, times(2)).forceGC(eq(false), eq(false));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand All @@ -121,7 +121,7 @@ public void testHandleRequest() throws Exception {
request.setMethod(HttpServer.Method.PUT);
request.setBody("{\"test\":1,\"forceMinor\":true}");
resp = service.handle(request);
verify(mockLedgerStorage, times(4)).forceGC(eq(true), eq(true));
verify(mockLedgerStorage, times(1)).forceGC(eq(false), eq(true));
assertEquals(HttpServer.StatusCode.OK.getValue(), resp.getStatusCode());
assertEquals("\"Triggered GC on BookieServer: " + mockBookieServer.getBookieId() + "\"",
resp.getBody());
Expand Down
9 changes: 9 additions & 0 deletions buildtools/src/main/resources/bookkeeper/findbugsExclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,13 @@
<Class name="org.apache.distributedlog.messaging.RRMultiWriter" />
<Bug pattern="EI_EXPOSE_REP2" />
</Match>

<Match>
<!-- generated code, we can't be held responsible for findbugs in it //-->
<Class name="~org\.apache\.bookkeeper\.bookie\.generated.*" />
</Match>
<Match>
<Class name="org.apache.bookkeeper.bookie.GroupSortBenchmark$TestState" />
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
</Match>
</FindBugsFilter>

0 comments on commit 9f3be1c

Please sign in to comment.