From 05ae65b2a52ff8a1d264ffd6bb65fe9c90e75d64 Mon Sep 17 00:00:00 2001 From: zymap Date: Fri, 8 Dec 2023 14:57:00 +0800 Subject: [PATCH 1/2] Fix the CI spotbugs failure in the branch-4.15 --- .../src/main/resources/bookkeeper/findbugsExclude.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/buildtools/src/main/resources/bookkeeper/findbugsExclude.xml b/buildtools/src/main/resources/bookkeeper/findbugsExclude.xml index 09daf196569..e3e9dfb085c 100644 --- a/buildtools/src/main/resources/bookkeeper/findbugsExclude.xml +++ b/buildtools/src/main/resources/bookkeeper/findbugsExclude.xml @@ -327,4 +327,13 @@ + + + + + + + + + From d31f15f713d9a16b794edbb0735cf24a3515aa1b Mon Sep 17 00:00:00 2001 From: zymap Date: Tue, 12 Dec 2023 09:42:12 +0800 Subject: [PATCH 2/2] Fix the failure tests --- .../server/http/service/TriggerGCService.java | 2 +- .../server/http/service/TriggerGCServiceTest.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerGCService.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerGCService.java index c1e25f55549..d702d545c24 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerGCService.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerGCService.java @@ -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") diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/TriggerGCServiceTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/TriggerGCServiceTest.java index 7a07ed59e24..0cef60209e9 100644 --- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/TriggerGCServiceTest.java +++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/server/http/service/TriggerGCServiceTest.java @@ -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()); @@ -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()); @@ -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()); @@ -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()); @@ -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());