mirror of https://github.com/grpc/grpc-java.git
alts: add close to TsiHandshaker to avoid resource leak for some impls (#6186)
* alts: add close to TsiHandshaker to avoid resource leak for some implementations * fix linter error
This commit is contained in:
parent
694de41107
commit
1ab651073d
|
|
@ -192,4 +192,9 @@ public final class AltsTsiHandshaker implements TsiHandshaker {
|
||||||
public TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) {
|
public TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) {
|
||||||
return createFrameProtector(AltsTsiFrameProtector.getMaxAllowedFrameBytes(), alloc);
|
return createFrameProtector(AltsTsiFrameProtector.getMaxAllowedFrameBytes(), alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
handshaker.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,4 +149,8 @@ public final class NettyTsiHandshaker {
|
||||||
unwrapper = null;
|
unwrapper = null;
|
||||||
return internalHandshaker.createFrameProtector(alloc);
|
return internalHandshaker.createFrameProtector(alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void close() {
|
||||||
|
internalHandshaker.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,4 +185,9 @@ public final class TsiHandshakeHandler extends ByteToMessageDecoder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handlerRemoved0(ChannelHandlerContext ctx) throws Exception {
|
||||||
|
handshaker.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -106,4 +106,9 @@ public interface TsiHandshaker {
|
||||||
* @return a new TsiFrameProtector.
|
* @return a new TsiFrameProtector.
|
||||||
*/
|
*/
|
||||||
TsiFrameProtector createFrameProtector(ByteBufAllocator alloc);
|
TsiFrameProtector createFrameProtector(ByteBufAllocator alloc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes resources.
|
||||||
|
*/
|
||||||
|
void close();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -479,6 +479,11 @@ public class AltsProtocolNegotiatorTest {
|
||||||
protectors.add(protector);
|
protectors.add(protector);
|
||||||
return protector;
|
return protector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
delegate.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class InterceptingProtector implements TsiFrameProtector {
|
private static class InterceptingProtector implements TsiFrameProtector {
|
||||||
|
|
|
||||||
|
|
@ -226,4 +226,9 @@ public class FakeTsiHandshaker implements TsiHandshaker {
|
||||||
public TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) {
|
public TsiFrameProtector createFrameProtector(ByteBufAllocator alloc) {
|
||||||
return createFrameProtector(AltsTsiFrameProtector.getMaxAllowedFrameBytes(), alloc);
|
return createFrameProtector(AltsTsiFrameProtector.getMaxAllowedFrameBytes(), alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
// No-op
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue