diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/CustomIOHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/CustomIOHandler.java index 3b93e7a783ab..ab4a68459700 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/CustomIOHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/CustomIOHandler.java @@ -10,14 +10,11 @@ import org.apache.qpid.proton.engine.Transport; import org.apache.qpid.proton.reactor.impl.IOHandler; -public class CustomIOHandler extends IOHandler -{ +public class CustomIOHandler extends IOHandler { @Override - public void onConnectionLocalOpen(Event event) - { + public void onConnectionLocalOpen(Event event) { Connection connection = event.getConnection(); - if (connection.getRemoteState() != EndpointState.UNINITIALIZED) - { + if (connection.getRemoteState() != EndpointState.UNINITIALIZED) { return; } @@ -28,10 +25,8 @@ public void onConnectionLocalOpen(Event event) } @Override - public void onTransportClosed(Event event) - { - if(event.getTransport() != null) - { + public void onTransportClosed(Event event) { + if (event.getTransport() != null) { event.getTransport().unbind(); } } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/DispatchHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/DispatchHandler.java index 1aca0da32126..11367cbafc40 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/DispatchHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/DispatchHandler.java @@ -6,10 +6,8 @@ import org.apache.qpid.proton.engine.BaseHandler; import org.apache.qpid.proton.engine.Event; -public abstract class DispatchHandler extends BaseHandler -{ - @Override public void onTimerTask(Event e) - { +public abstract class DispatchHandler extends BaseHandler { + @Override public void onTimerTask(Event e) { this.onEvent(); } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpConnection.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpConnection.java index 89d519df6082..e98e09b5c1ef 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpConnection.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpConnection.java @@ -3,12 +3,10 @@ package com.microsoft.azure.servicebus.amqp; -import com.microsoft.azure.servicebus.ClientSettings; import org.apache.qpid.proton.amqp.transport.ErrorCondition; import org.apache.qpid.proton.engine.Link; -public interface IAmqpConnection -{ +public interface IAmqpConnection { String getHostName(); void onConnectionOpen(); diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpLink.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpLink.java index 7cc7fa24a1ee..73e3cfb12289 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpLink.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpLink.java @@ -5,8 +5,7 @@ import org.apache.qpid.proton.amqp.transport.ErrorCondition; -public interface IAmqpLink -{ +public interface IAmqpLink { /** * @param completionException completionException=null if open is successful */ diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpReceiver.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpReceiver.java index 53d033f78981..62e1bc0d76df 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpReceiver.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpReceiver.java @@ -5,7 +5,6 @@ import org.apache.qpid.proton.engine.Delivery; -public interface IAmqpReceiver extends IAmqpLink -{ +public interface IAmqpReceiver extends IAmqpLink { void onReceiveComplete(Delivery delivery); } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpSender.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpSender.java index 1f19cbd2e5a1..71742ef24de0 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpSender.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/IAmqpSender.java @@ -5,8 +5,7 @@ import org.apache.qpid.proton.engine.Delivery; -public interface IAmqpSender extends IAmqpLink -{ +public interface IAmqpSender extends IAmqpLink { void onFlow(final int creditIssued); void onSendComplete(final Delivery delivery); diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/LoggingHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/LoggingHandler.java index 5bf031bde0fe..b4edaa6fe9e6 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/LoggingHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/LoggingHandler.java @@ -13,10 +13,8 @@ public class LoggingHandler extends BaseHandler { private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(LoggingHandler.class); @Override - public void onUnhandled(Event event) - { - if(TRACE_LOGGER.isTraceEnabled() && event.getType() != Type.REACTOR_QUIESCED ) // Too may REACTOR_QUIESCED events will be raised - { + public void onUnhandled(Event event) { + if (TRACE_LOGGER.isTraceEnabled() && event.getType() != Type.REACTOR_QUIESCED) { // Too may REACTOR_QUIESCED events will be raised TRACE_LOGGER.trace("Event raised by protonj: {}", event.toString()); } } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProtonUtil.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProtonUtil.java index 498866881208..6b01737e194e 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProtonUtil.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProtonUtil.java @@ -8,14 +8,11 @@ import org.apache.qpid.proton.reactor.Reactor; import org.apache.qpid.proton.reactor.ReactorOptions; -public final class ProtonUtil -{ - private ProtonUtil() - { +public final class ProtonUtil { + private ProtonUtil() { } - public static Reactor reactor(ReactorHandler reactorHandler, final int maxFrameSize) throws IOException - { + public static Reactor reactor(ReactorHandler reactorHandler, final int maxFrameSize) throws IOException { final ReactorOptions reactorOptions = new ReactorOptions(); reactorOptions.setMaxFrameSize(maxFrameSize); diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProxyConnectionHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProxyConnectionHandler.java index a6208042849c..3169fe25b7c1 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProxyConnectionHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ProxyConnectionHandler.java @@ -9,7 +9,6 @@ import com.microsoft.azure.servicebus.primitives.ClientConstants; import com.microsoft.azure.servicebus.primitives.StringUtil; -import com.microsoft.azure.servicebus.primitives.MessagingFactory; import org.apache.qpid.proton.amqp.transport.ConnectionError; import org.apache.qpid.proton.amqp.transport.ErrorCondition; import org.apache.qpid.proton.engine.Connection; @@ -20,7 +19,13 @@ import org.slf4j.LoggerFactory; import java.io.IOException; -import java.net.*; + +import java.net.Authenticator; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.URI; import java.util.Base64; import java.util.HashMap; import java.util.List; @@ -43,7 +48,9 @@ public static boolean shouldUseProxy(final String hostName) { return isProxyAddressLegal(proxies); } - public ProxyConnectionHandler(IAmqpConnection messagingFactory) { super(messagingFactory); } + public ProxyConnectionHandler(IAmqpConnection messagingFactory) { + super(messagingFactory); + } @Override public void addTransportLayers(final Event event, final TransportInternal transport) { diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorDispatcher.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorDispatcher.java index 167da84545f1..2af73a2fc3cf 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorDispatcher.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorDispatcher.java @@ -73,7 +73,7 @@ private static final class DelayHandler extends BaseHandler { final BaseHandler timerCallback; final Reactor reactor; - public DelayHandler(final Reactor reactor, final int delay, final DispatchHandler timerCallback) { + DelayHandler(final Reactor reactor, final int delay, final DispatchHandler timerCallback) { this.delay = delay; this.timerCallback = timerCallback; this.reactor = reactor; @@ -91,8 +91,7 @@ public void run(Selectable selectable) { try { ioSignal.source().read(ByteBuffer.allocate(1024)); } catch (ClosedChannelException ignorePipeClosedDuringReactorShutdown) { - - } catch(IOException ioException) { + } catch (IOException ioException) { throw new RuntimeException(ioException); } @@ -108,15 +107,13 @@ private final class CloseHandler implements Callback { public void run(Selectable selectable) { try { selectable.getChannel().close(); - } catch (IOException ignore) { - } + } catch (IOException ignore) { } try { if (ioSignal.sink().isOpen()) { ioSignal.sink().close(); } - } catch (IOException ignore) { - } + } catch (IOException ignore) { } workScheduler.run(null); @@ -124,8 +121,7 @@ public void run(Selectable selectable) { if (ioSignal.source().isOpen()) { ioSignal.source().close(); } - } catch (IOException ignore) { - } + } catch (IOException ignore) { } } } } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorHandler.java index fe4a5c250268..339d95103930 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReactorHandler.java @@ -11,13 +11,11 @@ import com.microsoft.azure.servicebus.primitives.ClientConstants; -public class ReactorHandler extends BaseHandler -{ +public class ReactorHandler extends BaseHandler { private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(ReactorHandler.class); @Override - public void onReactorInit(Event e) - { + public void onReactorInit(Event e) { TRACE_LOGGER.debug("reactor.onReactorInit"); final Reactor reactor = e.getReactor(); @@ -25,8 +23,7 @@ public void onReactorInit(Event e) } @Override - public void onReactorFinal(Event e) - { + public void onReactorFinal(Event e) { TRACE_LOGGER.debug("reactor.onReactorFinal"); } } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReceiveLinkHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReceiveLinkHandler.java index 1f61e407f01b..804ab36fd1e6 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReceiveLinkHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/ReceiveLinkHandler.java @@ -12,16 +12,14 @@ // ServiceBus <-> ProtonReactor interaction // handles all recvLink - reactor events -public final class ReceiveLinkHandler extends BaseLinkHandler -{ +public final class ReceiveLinkHandler extends BaseLinkHandler { private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(ReceiveLinkHandler.class); private final IAmqpReceiver amqpReceiver; private final Object firstResponse; private boolean isFirstResponse; - public ReceiveLinkHandler(final IAmqpReceiver receiver) - { + public ReceiveLinkHandler(final IAmqpReceiver receiver) { super(receiver); this.amqpReceiver = receiver; @@ -30,47 +28,36 @@ public ReceiveLinkHandler(final IAmqpReceiver receiver) } @Override - public void onLinkLocalOpen(Event evt) - { + public void onLinkLocalOpen(Event evt) { Link link = evt.getLink(); - if (link instanceof Receiver) - { + if (link instanceof Receiver) { Receiver receiver = (Receiver) link; TRACE_LOGGER.debug("onLinkLocalOpen: linkName:{}, localSource:{}", receiver.getName(), receiver.getSource()); } } @Override - public void onLinkRemoteOpen(Event event) - { + public void onLinkRemoteOpen(Event event) { Link link = event.getLink(); - if (link != null && link instanceof Receiver) - { + if (link != null && link instanceof Receiver) { Receiver receiver = (Receiver) link; - if (link.getRemoteSource() != null) - { + if (link.getRemoteSource() != null) { TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteSource:{}", receiver.getName(), receiver.getRemoteSource()); - synchronized (this.firstResponse) - { + synchronized (this.firstResponse) { this.isFirstResponse = false; this.amqpReceiver.onOpenComplete(null); } - } - else - { + } else { TRACE_LOGGER.debug("onLinkRemoteOpen: linkName:{}, remoteTarget:{}, remoteTarget:{}, action:{}", receiver.getName(), null, null, "waitingForError"); } } } @Override - public void onDelivery(Event event) - { - synchronized (this.firstResponse) - { - if (this.isFirstResponse) - { + public void onDelivery(Event event) { + synchronized (this.firstResponse) { + if (this.isFirstResponse) { this.isFirstResponse = false; this.amqpReceiver.onOpenComplete(null); } @@ -87,8 +74,7 @@ public void onDelivery(Event event) // If a message spans across deliveries (for ex: 200k message will be 4 frames (deliveries) 64k 64k 64k 8k), // all until "last-1" deliveries will be partial // reactor will raise onDelivery event for all of these - we only need the last one - if (!delivery.isPartial()) - { + if (!delivery.isPartial()) { this.amqpReceiver.onReceiveComplete(delivery); } } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/SessionHandler.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/SessionHandler.java index e5d35d224364..d00833720ec5 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/SessionHandler.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/SessionHandler.java @@ -10,51 +10,43 @@ import org.slf4j.LoggerFactory; import org.slf4j.Logger; -public class SessionHandler extends BaseHandler -{ +public class SessionHandler extends BaseHandler { protected static final Logger TRACE_LOGGER = LoggerFactory.getLogger(SessionHandler.class); private final String name; - public SessionHandler(final String name) - { + public SessionHandler(final String name) { this.name = name; } @Override - public void onSessionRemoteOpen(Event e) - { + public void onSessionRemoteOpen(Event e) { TRACE_LOGGER.debug("onSessionRemoteOpen - entityName: {}, sessionIncCapacity: {}, sessionOutgoingWindow: {}", this.name, e.getSession().getIncomingCapacity(), e.getSession().getOutgoingWindow()); Session session = e.getSession(); - if (session != null && session.getLocalState() == EndpointState.UNINITIALIZED) - { + if (session != null && session.getLocalState() == EndpointState.UNINITIALIZED) { session.open(); } } @Override - public void onSessionLocalClose(Event e) - { + public void onSessionLocalClose(Event e) { TRACE_LOGGER.debug("onSessionLocalClose - entityName: {}, condition: {}", this.name, e.getSession().getCondition() == null ? "none" : e.getSession().getCondition().toString()); } @Override - public void onSessionRemoteClose(Event e) - { + public void onSessionRemoteClose(Event e) { TRACE_LOGGER.debug("onSessionRemoteClose - entityName: {}, condition: {}", this.name, e.getSession().getCondition() == null ? "none" : e.getSession().getCondition().toString()); Session session = e.getSession(); - if (session != null && session.getLocalState() != EndpointState.CLOSED) - { + if (session != null && session.getLocalState() != EndpointState.CLOSED) { session.close(); } } @Override - public void onSessionFinal(Event e) - { + public void onSessionFinal(Event e) { TRACE_LOGGER.debug("onSessionFinal - entityName: {}", this.name); } } diff --git a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/StrictTLSContextSpi.java b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/StrictTLSContextSpi.java index 550948d7e9d9..df14dc39a410 100644 --- a/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/StrictTLSContextSpi.java +++ b/servicebus/data-plane/azure-servicebus/src/main/java/com/microsoft/azure/servicebus/amqp/StrictTLSContextSpi.java @@ -17,9 +17,9 @@ import javax.net.ssl.TrustManager; // Wraps over a standard SSL context and disables the SSLv2Hello protocol. -public class StrictTLSContextSpi extends SSLContextSpi{ +public class StrictTLSContextSpi extends SSLContextSpi { - private static final String SSLv2Hello = "SSLv2Hello"; + private static final String SSL_V2_HELLO = "SSLv2Hello"; SSLContext innerContext; public StrictTLSContextSpi(SSLContext innerContext) { @@ -65,26 +65,20 @@ protected void engineInit(KeyManager[] km, TrustManager[] tm, SecureRandom sr) t this.innerContext.init(km, tm, sr); } - private void removeSSLv2Hello(SSLEngine engine) - { + private void removeSSLv2Hello(SSLEngine engine) { String[] enabledProtocols = engine.getEnabledProtocols(); boolean sslv2HelloFound = false; - for(String protocol : enabledProtocols) - { - if(protocol.equalsIgnoreCase(SSLv2Hello)) - { + for (String protocol : enabledProtocols) { + if (protocol.equalsIgnoreCase(SSL_V2_HELLO)) { sslv2HelloFound = true; break; } } - if(sslv2HelloFound) - { + if (sslv2HelloFound) { ArrayList modifiedProtocols = new ArrayList(); - for(String protocol : enabledProtocols) - { - if(!protocol.equalsIgnoreCase(SSLv2Hello)) - { + for (String protocol : enabledProtocols) { + if (!protocol.equalsIgnoreCase(SSL_V2_HELLO)) { modifiedProtocols.add(protocol); } }