|
20 | 20 | import java.io.IOException;
|
21 | 21 | import java.nio.ByteBuffer;
|
22 | 22 | import java.security.GeneralSecurityException;
|
| 23 | +import java.util.concurrent.TimeoutException; |
23 | 24 |
|
24 | 25 | import com.google.common.base.Throwables;
|
25 | 26 | import io.netty.buffer.ByteBuf;
|
@@ -82,13 +83,19 @@ public void doBootstrap(TransportClient client, Channel channel) {
|
82 | 83 | } catch (RuntimeException e) {
|
83 | 84 | // There isn't a good exception that can be caught here to know whether it's really
|
84 | 85 | // OK to switch back to SASL (because the server doesn't speak the new protocol). So
|
85 |
| - // try it anyway, and in the worst case things will fail again. |
86 |
| - if (conf.saslFallback()) { |
87 |
| - LOG.warn("New auth protocol failed, trying SASL.", e); |
88 |
| - doSaslAuth(client, channel); |
89 |
| - } else { |
| 86 | + // try it anyway, unless it's a timeout, which is locally fatal. In the worst case |
| 87 | + // things will fail again. |
| 88 | + if (!conf.saslFallback() || e.getCause() instanceof TimeoutException) { |
90 | 89 | throw e;
|
91 | 90 | }
|
| 91 | + |
| 92 | + if (LOG.isDebugEnabled()) { |
| 93 | + Throwable cause = e.getCause() != null ? e.getCause() : e; |
| 94 | + LOG.debug("New auth protocol failed, trying SASL.", cause); |
| 95 | + } else { |
| 96 | + LOG.info("New auth protocol failed, trying SASL."); |
| 97 | + } |
| 98 | + doSaslAuth(client, channel); |
92 | 99 | }
|
93 | 100 | }
|
94 | 101 |
|
|
0 commit comments