hangc0276 opened a new pull request, #3998:
URL: https://github.com/apache/bookkeeper/pull/3998

   ### Motivation
   When I use `curl -XPUT http://<ip>:<port>/api/v1/bookie/gc` command to 
trigger garbage compaction, the bookie server returns `Internal Server Error`. 
Then I checked the bookie server's log, and nothing was found.
   
   After a deep debugging of the server, I found the following exception.
   ```
       org.apache.bookkeeper.common.util.JsonUtil$ParseJsonException: Failed to 
deserialize Object from Json string
        at org.apache.bookkeeper.common.util.JsonUtil.fromJson(JsonUtil.java:41)
        at 
org.apache.bookkeeper.server.http.service.TriggerGCService.handle(TriggerGCService.java:71)
        at 
org.apache.bookkeeper.http.vertx.VertxAbstractHandler.processRequest(VertxAbstractHandler.java:55)
        at 
org.apache.bookkeeper.http.vertx.VertxHttpHandlerFactory$1.handle(VertxHttpHandlerFactory.java:47)
        at 
org.apache.bookkeeper.http.vertx.VertxHttpHandlerFactory$1.handle(VertxHttpHandlerFactory.java:43)
        at io.vertx.ext.web.impl.RouteState.handleContext(RouteState.java:1038)
        at 
io.vertx.ext.web.impl.RoutingContextImplBase.iterateNext(RoutingContextImplBase.java:137)
        at 
io.vertx.ext.web.impl.RoutingContextImpl.next(RoutingContextImpl.java:132)
        at 
io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.doEnd(BodyHandlerImpl.java:296)
        at 
io.vertx.ext.web.handler.impl.BodyHandlerImpl$BHandler.end(BodyHandlerImpl.java:276)
        at 
io.vertx.ext.web.handler.impl.BodyHandlerImpl.lambda$handle$0(BodyHandlerImpl.java:87)
        at 
io.vertx.core.http.impl.HttpServerRequestImpl.onEnd(HttpServerRequestImpl.java:525)
        at 
io.vertx.core.http.impl.HttpServerRequestImpl.handleEnd(HttpServerRequestImpl.java:511)
        at 
io.vertx.core.http.impl.Http1xServerConnection.handleEnd(Http1xServerConnection.java:176)
        at 
io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:138)
        at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:366)
        at io.vertx.core.impl.EventLoopContext.execute(EventLoopContext.java:43)
   ```
   
   This bug is introduced by https://github.com/apache/bookkeeper/pull/3205. 
When we use `curl -XPUT http://<ip>:<port>/api/v1/bookie/gc` command to trigger 
gc, the request body is empty string, but not `null`. 
   
https://github.com/apache/bookkeeper/blob/ffc8e8bec19e54dc76710c3de133401248f243d6/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/TriggerGCService.java#L67-L75
   
   It will enter Line#68 but goes into Line#71. It uses `JsonUtil.fromJson` to 
parse an empty string will throw the above exception and will return `500` to 
the client but no logs in the server side.
   
   ### Changes
   - Fix the request body check bug
   - Add a unit test to cover this logic
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to