svn commit: r1818582 - in /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms: JmsListenerFactory.java JmsServiceEngine.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1818582 - in /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms: JmsListenerFactory.java JmsServiceEngine.java

mbrohl
Author: mbrohl
Date: Mon Dec 18 14:59:53 2017
New Revision: 1818582

URL: http://svn.apache.org/viewvc?rev=1818582&view=rev
Log:
Improved: Fixing defects reported by code analysis tools, package
org.apache.ofbiz.service.jms.
(OFBIZ-10061)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsServiceEngine.java

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java?rev=1818582&r1=1818581&r2=1818582&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsListenerFactory.java Mon Dec 18 14:59:53 2017
@@ -19,11 +19,13 @@
 package org.apache.ofbiz.service.jms;
 
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.ofbiz.base.config.GenericConfigException;
 import org.apache.ofbiz.base.util.Debug;
 import org.apache.ofbiz.base.util.UtilGenerics;
 import org.apache.ofbiz.base.util.UtilMisc;
@@ -123,7 +125,7 @@ public class JmsListenerFactory implemen
                     }
                 }
             }
-        } catch (Exception e) {
+        } catch (GenericConfigException e) {
             Debug.logError(e, "Exception thrown while loading JMS listeners: ", module);
         }
     }
@@ -157,7 +159,8 @@ public class JmsListenerFactory implemen
                         Constructor<GenericMessageListener> cn = UtilGenerics.cast(c.getConstructor(Delegator.class, String.class, String.class, String.class, String.class, String.class));
 
                         listener = cn.newInstance(delegator, serverName, jndiName, queueName, userName, password);
-                    } catch (Exception e) {
+                    } catch (RuntimeException | NoSuchMethodException | InstantiationException | IllegalAccessException
+                            | InvocationTargetException | ClassNotFoundException e) {
                         throw new GenericServiceException(e.getMessage(), e);
                     }
                     if (listener != null)

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsServiceEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsServiceEngine.java?rev=1818582&r1=1818581&r2=1818582&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsServiceEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/jms/JmsServiceEngine.java Mon Dec 18 14:59:53 2017
@@ -18,6 +18,7 @@
  *******************************************************************************/
 package org.apache.ofbiz.service.jms;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -50,6 +51,7 @@ import org.apache.ofbiz.base.util.Genera
 import org.apache.ofbiz.base.util.JNDIContextFactory;
 import org.apache.ofbiz.base.util.UtilValidate;
 import org.apache.ofbiz.base.util.UtilXml;
+import org.apache.ofbiz.entity.serialize.SerializeException;
 import org.apache.ofbiz.entity.transaction.GenericTransactionException;
 import org.apache.ofbiz.entity.transaction.TransactionUtil;
 import org.apache.ofbiz.service.GenericRequester;
@@ -94,7 +96,7 @@ public class JmsServiceEngine extends Ab
         try {
             if (Debug.verboseOn()) Debug.logVerbose("Serializing Context --> " + context, module);
             xmlContext = JmsSerializer.serialize(context);
-        } catch (Exception e) {
+        } catch (SerializeException | IOException e) {
             throw new GenericServiceException("Cannot serialize context.", e);
         }
         MapMessage message = session.createMapMessage();
@@ -266,7 +268,7 @@ public class JmsServiceEngine extends Ab
         try {
             con = factory.createXAQueueConnection(userName, password);
 
-            if (clientId != null && clientId.length() > 1)
+            if (clientId.length() > 1)
                 con.setClientID(userName);
             con.start();