camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [04/11] camel git commit: Fixed CS
Date Fri, 04 Mar 2016 14:00:37 GMT
Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/aace1744
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/aace1744
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/aace1744

Branch: refs/heads/master
Commit: aace1744f9ffa4527394900d9e7701eb486d711b
Parents: 39543f1
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Mar 4 14:23:28 2016 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Mar 4 14:23:28 2016 +0100

----------------------------------------------------------------------
 .../component/mllp/MllpTcpClientProducer.java   | 64 ++++++++++----------
 .../component/mllp/MllpTcpServerConsumer.java   |  6 +-
 .../camel/component/mllp/impl/MllpUtil.java     |  4 +-
 ...llpTcpClientProducerAcknowledgementTest.java |  4 +-
 .../MllpTcpServerConsumerBindTimeoutTest.java   |  4 +-
 .../MllpTcpServerConsumerBlueprintTest.java     |  7 +--
 .../junit/rule/mllp/MllpServerResource.java     | 54 ++++++++---------
 7 files changed, 68 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
index 17979c4..2e74f6c 100644
--- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
+++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpClientProducer.java
@@ -150,39 +150,39 @@ public class MllpTcpClientProducer extends DefaultProducer {
                             } else {
                                 String acknowledgemenTypeString;
                                 switch (acknowledgementBytes[i + 6]) {
-                                    case bA:
-                                        // We have an AA or CA- make sure that's the end
of the field
-                                        if (fieldDelim != acknowledgementBytes[i + 7]) {
-                                            exchange.setException(new MllpInvalidAcknowledgementException(new
String(acknowledgementBytes)));
-                                        }
-                                        if (bA == acknowledgementBytes[i + 5]) {
-                                            message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE,
"AA");
-                                        } else {
-                                            message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE,
"CA");
-                                        }
-                                        break;
-                                    case bE:
-                                        // We have an AE or CE
-                                        if (bA == acknowledgementBytes[i + 5]) {
-                                            message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE,
"AE");
-                                            exchange.setException(new MllpApplicationErrorAcknowledgementException(new
String(acknowledgementBytes)));
-                                        } else {
-                                            message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE,
"CE");
-                                            exchange.setException(new MllpCommitErrorAcknowledgementException(new
String(acknowledgementBytes)));
-                                        }
-                                        break;
-                                    case bR:
-                                        // We have an AR or CR
-                                        if (bA == acknowledgementBytes[i + 5]) {
-                                            message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE,
"AR");
-                                            exchange.setException(new MllpApplicationRejectAcknowledgementException(new
String(acknowledgementBytes)));
-                                        } else {
-                                            message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE,
"CR");
-                                            exchange.setException(new MllpCommitRejectAcknowledgementException(new
String(acknowledgementBytes)));
-                                        }
-                                        break;
-                                    default:
+                                case bA:
+                                    // We have an AA or CA- make sure that's the end of the
field
+                                    if (fieldDelim != acknowledgementBytes[i + 7]) {
                                         exchange.setException(new MllpInvalidAcknowledgementException(new
String(acknowledgementBytes)));
+                                    }
+                                    if (bA == acknowledgementBytes[i + 5]) {
+                                        message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AA");
+                                    } else {
+                                        message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "CA");
+                                    }
+                                    break;
+                                case bE:
+                                    // We have an AE or CE
+                                    if (bA == acknowledgementBytes[i + 5]) {
+                                        message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AE");
+                                        exchange.setException(new MllpApplicationErrorAcknowledgementException(new
String(acknowledgementBytes)));
+                                    } else {
+                                        message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "CE");
+                                        exchange.setException(new MllpCommitErrorAcknowledgementException(new
String(acknowledgementBytes)));
+                                    }
+                                    break;
+                                case bR:
+                                    // We have an AR or CR
+                                    if (bA == acknowledgementBytes[i + 5]) {
+                                        message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "AR");
+                                        exchange.setException(new MllpApplicationRejectAcknowledgementException(new
String(acknowledgementBytes)));
+                                    } else {
+                                        message.setHeader(MLLP_ACKNOWLEDGEMENT_TYPE, "CR");
+                                        exchange.setException(new MllpCommitRejectAcknowledgementException(new
String(acknowledgementBytes)));
+                                    }
+                                    break;
+                                default:
+                                    exchange.setException(new MllpInvalidAcknowledgementException(new
String(acknowledgementBytes)));
                                 }
                             }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
index afdc343..95a2d22 100644
--- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
+++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/MllpTcpServerConsumer.java
@@ -107,14 +107,14 @@ public class MllpTcpServerConsumer extends DefaultConsumer {
                 serverSocket.bind(socketAddress, endpoint.backlog);
             } catch (BindException bindException) {
                 if (System.currentTimeMillis() > startTicks + endpoint.getBindTimeout())
{
-                    log.error( "Failed to bind to address {} within timeout {}", socketAddress,
endpoint.getBindTimeout());
+                    log.error("Failed to bind to address {} within timeout {}", socketAddress,
endpoint.getBindTimeout());
                     throw bindException;
                 } else {
-                    log.warn( "Failed to bind to address {} - retrying in {} milliseconds",
socketAddress, endpoint.getBindRetryInterval());
+                    log.warn("Failed to bind to address {} - retrying in {} milliseconds",
socketAddress, endpoint.getBindRetryInterval());
                     Thread.sleep(endpoint.getBindRetryInterval());
                 }
             }
-        } while ( !serverSocket.isBound() );
+        } while (!serverSocket.isBound());
 
         serverSocketThread = new ServerSocketThread(serverSocket);
         serverSocketThread.start();

http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/impl/MllpUtil.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/impl/MllpUtil.java
b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/impl/MllpUtil.java
index 72c2514..2aab0a8 100644
--- a/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/impl/MllpUtil.java
+++ b/components/camel-mllp/src/main/java/org/apache/camel/component/mllp/impl/MllpUtil.java
@@ -87,9 +87,9 @@ public final class MllpUtil {
             } catch (SocketTimeoutException normaTimeoutEx) {
                 // Just pass this on - the caller will wrap it in a MllpTimeoutException
                 throw normaTimeoutEx;
-            } catch (SocketException socketEx ) {
+            } catch (SocketException socketEx) {
                 if (socket.isClosed()) {
-                    LOG.debug( "Socket closed while opening MLLP frame - ignoring exception",
socketEx);
+                    LOG.debug("Socket closed while opening MLLP frame - ignoring exception",
socketEx);
                     return false;
                 } else {
                     LOG.error("Unexpected Exception occurred opening MLLP frame - resetting
the connection");

http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerAcknowledgementTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerAcknowledgementTest.java
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerAcknowledgementTest.java
index 38838ae..03a7197 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerAcknowledgementTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpClientProducerAcknowledgementTest.java
@@ -33,13 +33,13 @@ import org.junit.Test;
 
 import static org.apache.camel.test.mllp.Hl7MessageGenerator.generateMessage;
 
-
 public class MllpTcpClientProducerAcknowledgementTest extends CamelTestSupport {
-    String mllpHost = "localhost";
 
     @Rule
     public MllpServerResource mllpServer = new MllpServerResource(mllpHost, AvailablePortFinder.getNextAvailable());
 
+    String mllpHost = "localhost";
+
     @EndpointInject(uri = "direct://source")
     ProducerTemplate source;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
index 3ea892f..d28e470 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBindTimeoutTest.java
@@ -22,13 +22,11 @@ import java.util.concurrent.TimeUnit;
 import org.apache.camel.CamelContext;
 import org.apache.camel.EndpointInject;
 import org.apache.camel.LoggingLevel;
-import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit.rule.mllp.MllpClientResource;
-import org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Rule;
 import org.junit.Test;
@@ -96,7 +94,7 @@ public class MllpTcpServerConsumerBindTimeoutTest extends CamelTestSupport
{
                     Thread.sleep(15000);
                     tmpSocket.close();
                 } catch (Exception ex) {
-                    throw new RuntimeException( "Exception caught in dummy listener", ex);
+                    throw new RuntimeException("Exception caught in dummy listener", ex);
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBlueprintTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBlueprintTest.java
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBlueprintTest.java
index 4cc8110..9e195f4 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBlueprintTest.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpTcpServerConsumerBlueprintTest.java
@@ -35,17 +35,16 @@ import org.junit.Test;
 import static org.apache.camel.test.mllp.Hl7MessageGenerator.generateMessage;
 
 public class MllpTcpServerConsumerBlueprintTest extends CamelBlueprintTestSupport {
-    String mllpHost = "localhost";
 
     @Rule
     public MllpClientResource mllpClient = new MllpClientResource();
 
     final String receivedUri = "mock://received";
+    final String mllpHost = "localhost";
 
     @EndpointInject(uri = receivedUri)
     MockEndpoint received;
 
-
     @Override
     protected String getBlueprintDescriptor() {
         return "OSGI-INF/blueprint/mllp-tcp-server-consumer-test.xml";
@@ -58,7 +57,6 @@ public class MllpTcpServerConsumerBlueprintTest extends CamelBlueprintTestSuppor
         services.put(ComponentResolver.class.getName(), asService(testResolver, "component",
"mllp"));
     }
 
-
     @Override
     protected Properties useOverridePropertiesWithPropertiesComponent() {
         mllpClient.setMllpHost(mllpHost);
@@ -67,7 +65,7 @@ public class MllpTcpServerConsumerBlueprintTest extends CamelBlueprintTestSuppor
         Properties props = new Properties();
 
         props.setProperty("receivedUri", receivedUri);
-        props.setProperty( "mllp.host", mllpClient.getMllpHost());
+        props.setProperty("mllp.host", mllpClient.getMllpHost());
         props.setProperty("mllp.port", Integer.toString(mllpClient.getMllpPort()));
 
         return props;
@@ -101,5 +99,4 @@ public class MllpTcpServerConsumerBlueprintTest extends CamelBlueprintTestSuppor
         assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/aace1744/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
----------------------------------------------------------------------
diff --git a/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
b/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
index dc68fbb..252e228 100644
--- a/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
+++ b/components/camel-mllp/src/test/java/org/apache/camel/test/junit/rule/mllp/MllpServerResource.java
@@ -38,7 +38,8 @@ import static org.apache.camel.component.mllp.MllpEndpoint.END_OF_DATA;
 import static org.apache.camel.component.mllp.MllpEndpoint.END_OF_STREAM;
 import static org.apache.camel.component.mllp.MllpEndpoint.MESSAGE_TERMINATOR;
 import static org.apache.camel.component.mllp.MllpEndpoint.SEGMENT_DELIMITER;
-import static  org.apache.camel.component.mllp.MllpEndpoint.START_OF_BLOCK;
+import static org.apache.camel.component.mllp.MllpEndpoint.START_OF_BLOCK;
+
 /**
  * MLLP Test Server packaged as a JUnit Rule
  *
@@ -127,7 +128,7 @@ public class MllpServerResource extends ExternalResource {
     public void startup() throws IOException {
         this.active = true;
 
-        if ( null != listenHost ) {
+        if (null != listenHost) {
             serverSocketThread = new ServerSocketThread(listenHost, listenPort, backlog);
         } else {
             serverSocketThread = new ServerSocketThread(listenPort, backlog);
@@ -181,7 +182,6 @@ public class MllpServerResource extends ExternalResource {
         return evaluateModulus(messageCount, this.sendApplicationErrorAcknowledgementModulus);
     }
 
-
     public boolean excludeStartOfBlock(int messageCount) {
         return evaluateModulus(messageCount, excludeStartOfBlockModulus);
     }
@@ -218,7 +218,6 @@ public class MllpServerResource extends ExternalResource {
             return true;
         default:
             return (messageCount % modulus == 0) ? true : false;
-
         }
     }
 
@@ -467,7 +466,7 @@ public class MllpServerResource extends ExternalResource {
     }
 
     void resetConnection(Socket socket) {
-        if (null != socket  && !socket.isClosed()) {
+        if (null != socket && !socket.isClosed()) {
             try {
                 socket.setSoLinger(true, 0);
             } catch (SocketException socketEx) {
@@ -536,23 +535,23 @@ public class MllpServerResource extends ExternalResource {
             serverSocket.setReuseAddress(true);
 
             InetSocketAddress listenAddress;
-            if ( null != this.listenHost ) {
+            if (null != this.listenHost) {
                 listenAddress = new InetSocketAddress(this.listenHost, this.listenPort);
             } else {
-                listenAddress = new InetSocketAddress( this.listenPort );
+                listenAddress = new InetSocketAddress(this.listenPort);
             }
 
             long startTicks = System.currentTimeMillis();
             while (!serverSocket.isBound()) {
                 try {
                     serverSocket.bind(listenAddress, backlog);
-                } catch ( BindException bindEx ) {
-                    if ( System.currentTimeMillis() < startTicks + bindTimeout) {
-                        log.warn( "Unable to bind to {} - retrying in {} milliseconds", listenAddress.toString(),
bindRetryDelay);
+                } catch (BindException bindEx) {
+                    if (System.currentTimeMillis() < startTicks + bindTimeout) {
+                        log.warn("Unable to bind to {} - retrying in {} milliseconds", listenAddress.toString(),
bindRetryDelay);
                         try {
                             Thread.sleep(bindRetryDelay);
                         } catch (InterruptedException interruptedEx) {
-                            log.error( "Wait for bind retry was interrupted - rethrowing
BindException");
+                            log.error("Wait for bind retry was interrupted - rethrowing BindException");
                             throw bindEx;
                         }
                     }
@@ -573,7 +572,7 @@ public class MllpServerResource extends ExternalResource {
         public void run() {
             log.info("Accepting connections on port {}", serverSocket.getLocalPort());
             this.setName("MllpServerResource$ServerSocketThread - " + serverSocket.getLocalSocketAddress().toString());
-            while (!isInterrupted()  &&  serverSocket.isBound()  && !serverSocket.isClosed())
{
+            while (!isInterrupted() && serverSocket.isBound() && !serverSocket.isClosed())
{
                 Socket clientSocket = null;
                 try {
                     clientSocket = serverSocket.accept();
@@ -607,11 +606,11 @@ public class MllpServerResource extends ExternalResource {
                         clientSocketThreads.add(clientSocketThread);
                     } catch (Exception unexpectedEx) {
                         log.warn("Unexpected exception encountered configuring client socket");
-                            try {
-                                clientSocket.close();
-                            } catch (IOException ingoreEx) {
-                                log.warn("Exceptiong encountered closing client socket after
attempting to accept connection", ingoreEx);
-                            }
+                        try {
+                            clientSocket.close();
+                        } catch (IOException ingoreEx) {
+                            log.warn("Exceptiong encountered closing client socket after
attempting to accept connection", ingoreEx);
+                        }
                         throw new MllpJUnitResourceException("Unexpected exception encountered
configuring client socket", unexpectedEx);
                     }
                 }
@@ -673,11 +672,11 @@ public class MllpServerResource extends ExternalResource {
 
         @Override
         public void interrupt() {
-            for (ClientSocketThread clientSocketThread: clientSocketThreads) {
+            for (ClientSocketThread clientSocketThread : clientSocketThreads) {
                 clientSocketThread.interrupt();
             }
 
-            if (serverSocket != null  &&  serverSocket.isBound()  &&  !serverSocket.isClosed())
{
+            if (serverSocket != null && serverSocket.isBound() && !serverSocket.isClosed())
{
                 try {
                     serverSocket.close();
                 } catch (Exception ex) {
@@ -725,19 +724,19 @@ public class MllpServerResource extends ExternalResource {
             log.info("Handling Connection: {} -> {}", localAddress, remoteAddress);
 
             try {
-                while (!isInterrupted()  &&  null != clientSocket && clientSocket.isConnected()
&& !clientSocket.isClosed()) {
+                while (!isInterrupted() && null != clientSocket && clientSocket.isConnected()
&& !clientSocket.isClosed()) {
                     InputStream instream;
                     try {
                         instream = clientSocket.getInputStream();
                     } catch (IOException ioEx) {
                         if (clientSocket.isClosed()) {
-                            log.debug( "Client socket was closed - ignoring exception", clientSocket);
+                            log.debug("Client socket was closed - ignoring exception", clientSocket);
                             break;
                         } else {
-                            throw new MllpJUnitResourceException( "Unexpected IOException
encounted getting input stream", ioEx);
+                            throw new MllpJUnitResourceException("Unexpected IOException
encounted getting input stream", ioEx);
                         }
                     } catch (Exception unexpectedEx) {
-                        throw new MllpJUnitResourceException( "Unexpected exception encounted
getting input stream", unexpectedEx);
+                        throw new MllpJUnitResourceException("Unexpected exception encounted
getting input stream", unexpectedEx);
                     }
                     String parsedHL7Message = getMessage(instream);
 
@@ -850,8 +849,8 @@ public class MllpServerResource extends ExternalResource {
             } catch (SocketException socketEx) {
                 if (clientSocket.isClosed()) {
                     log.info("Client socket closed while waiting for MLLP_ENVELOPE_START_OF_BLOCK");
-                } else if ( clientSocket.isConnected() ) {
-                    log.info( "SocketException encountered while waiting for MLLP_ENVELOPE_START_OF_BLOCK");
+                } else if (clientSocket.isConnected()) {
+                    log.info("SocketException encountered while waiting for MLLP_ENVELOPE_START_OF_BLOCK");
                     resetConnection(clientSocket);
                 } else {
                     log.error("Unable to read from socket stream when expected bMLLP_ENVELOPE_START_OF_BLOCK
- resetting connection ", socketEx);
@@ -930,7 +929,7 @@ public class MllpServerResource extends ExternalResource {
                 char fieldSeparator = mshSegment.charAt(3);
                 String fieldSeparatorPattern = Pattern.quote("" + fieldSeparator);
                 String[] mshFields = mshSegment.split(fieldSeparatorPattern);
-                if (null == mshFields || 0 == mshFields.length) {
+                if (mshFields.length == 0) {
                     log.error("Failed to split MSH Segment into fields");
                 } else {
                     StringBuilder ackBuilder = new StringBuilder(mshSegment.length() + 25);
@@ -981,7 +980,7 @@ public class MllpServerResource extends ExternalResource {
 
         @Override
         public void interrupt() {
-            if (null != clientSocket  &&  clientSocket.isConnected()  &&
 !clientSocket.isClosed()) {
+            if (clientSocket != null && clientSocket.isConnected() && !clientSocket.isClosed())
{
                 try {
                     clientSocket.close();
                 } catch (Exception ex) {
@@ -992,5 +991,4 @@ public class MllpServerResource extends ExternalResource {
         }
     }
 
-
 }


Mime
View raw message