merlimat closed pull request #1602: Proxy should close connections immediately 
after exception caught
URL: https://github.com/apache/incubator-pulsar/pull/1602
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
 
b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
index d2c7f9709..eaa006d88 100644
--- 
a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
+++ 
b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java
@@ -28,6 +28,7 @@
 
 import org.apache.pulsar.broker.authentication.AuthenticationDataCommand;
 import org.apache.pulsar.broker.authentication.AuthenticationDataSource;
+import org.apache.pulsar.client.impl.ClientCnx;
 import org.apache.pulsar.common.api.Commands;
 import org.apache.pulsar.common.api.PulsarHandler;
 import org.apache.pulsar.common.api.proto.PulsarApi;
@@ -88,7 +89,7 @@
     static final Counter rejectedConnections = Counter
             .build("pulsar_proxy_rejected_connections", "Counter for 
connections rejected due to throttling").create()
             .register();
-    
+
     public ProxyConnection(ProxyService proxyService) {
         super(30, TimeUnit.SECONDS);
         this.service = proxyService;
@@ -111,7 +112,7 @@ public void channelUnregistered(ChannelHandlerContext ctx) 
throws Exception {
         super.channelUnregistered(ctx);
         activeConnections.dec();
     }
-    
+
     @Override
     public void channelActive(ChannelHandlerContext ctx) throws Exception {
         super.channelActive(ctx);
@@ -126,6 +127,16 @@ public void channelInactive(ChannelHandlerContext ctx) 
throws Exception {
         if (directProxyHandler != null && directProxyHandler.outboundChannel 
!= null) {
             directProxyHandler.outboundChannel.close();
         }
+
+        LOG.info("[{}] Connection closed", remoteAddress);
+    }
+
+    @Override
+    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) 
throws Exception {
+        super.exceptionCaught(ctx, cause);
+        LOG.warn("[{}] Got exception {} : {}", remoteAddress, 
cause.getClass().getSimpleName(), cause.getMessage(),
+                ClientCnx.isKnownException(cause) ? null : cause);
+        ctx.close();
     }
 
     @Override


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to