File tree Expand file tree Collapse file tree
main/java/org/apache/hadoop/hbase
test/java/org/apache/hadoop/hbase/ipc Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -550,6 +550,10 @@ private void endBlock() throws IOException {
550550 */
551551 @ Override
552552 public void recoverAndClose (CancelableProgressable reporter ) throws IOException {
553+ if (buf != null ) {
554+ buf .release ();
555+ buf = null ;
556+ }
553557 datanodeList .forEach (ch -> ch .close ());
554558 datanodeList .forEach (ch -> ch .closeFuture ().awaitUninterruptibly ());
555559 endFileLease (client , fileId );
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ public void setStatus(MonitoredRPCHandler status) {
8888 * Cleanup after ourselves... let go of references.
8989 */
9090 private void cleanup () {
91+ this .call .cleanup ();
9192 this .call = null ;
9293 this .rpcServer = null ;
9394 }
Original file line number Diff line number Diff line change @@ -45,4 +45,30 @@ public void testSimpleCall() {
4545 cr .setStatus (new MonitoredRPCHandlerImpl ());
4646 cr .run ();
4747 }
48+
49+ @ Test
50+ public void testCallCleanup () {
51+ RpcServerInterface mockRpcServer = Mockito .mock (RpcServerInterface .class );
52+ Mockito .when (mockRpcServer .isStarted ()).thenReturn (true );
53+ ServerCall mockCall = Mockito .mock (ServerCall .class );
54+ Mockito .when (mockCall .disconnectSince ()).thenReturn (1L );
55+
56+ CallRunner cr = new CallRunner (mockRpcServer , mockCall );
57+ cr .setStatus (new MonitoredRPCHandlerImpl ());
58+ cr .run ();
59+ Mockito .verify (mockCall , Mockito .times (1 )).cleanup ();
60+ }
61+
62+ @ Test
63+ public void testCallRunnerDrop () {
64+ RpcServerInterface mockRpcServer = Mockito .mock (RpcServerInterface .class );
65+ Mockito .when (mockRpcServer .isStarted ()).thenReturn (true );
66+ ServerCall mockCall = Mockito .mock (ServerCall .class );
67+ Mockito .when (mockCall .disconnectSince ()).thenReturn (1L );
68+
69+ CallRunner cr = new CallRunner (mockRpcServer , mockCall );
70+ cr .setStatus (new MonitoredRPCHandlerImpl ());
71+ cr .drop ();
72+ Mockito .verify (mockCall , Mockito .times (1 )).cleanup ();
73+ }
4874}
You can’t perform that action at this time.
0 commit comments