Repository: incubator-unomi
Updated Branches:
  refs/heads/master 1a9f9cdcb -> 46be00217


UNOMI-99 Improve network unavailable and connection timeout handling
- Try to improve error handling.

Signed-off-by: Serge Huber <shu...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/incubator-unomi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-unomi/commit/46be0021
Tree: http://git-wip-us.apache.org/repos/asf/incubator-unomi/tree/46be0021
Diff: http://git-wip-us.apache.org/repos/asf/incubator-unomi/diff/46be0021

Branch: refs/heads/master
Commit: 46be0021749e46503e5f85169e82b2066e903693
Parents: 1a9f9cd
Author: Serge Huber <shu...@apache.org>
Authored: Sun Jun 4 16:45:07 2017 +0200
Committer: Serge Huber <shu...@apache.org>
Committed: Sun Jun 4 16:45:07 2017 +0200

----------------------------------------------------------------------
 .../apache/unomi/services/services/ClusterServiceImpl.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-unomi/blob/46be0021/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
 
b/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
index b7f1594..a77b978 100644
--- 
a/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
+++ 
b/services/src/main/java/org/apache/unomi/services/services/ClusterServiceImpl.java
@@ -257,8 +257,9 @@ public class ClusterServiceImpl implements ClusterService {
             } catch (MalformedURLException e) {
                 logger.error("Error connecting to remote JMX server", e);
             } catch (ConnectException ce) {
-                if (ce.getMessage() != null && ce.getMessage().contains("timed 
out")) {
-                    logger.warn("RMI Connection timed out, will reconnect on 
next request.");
+                if (ce.getMessage() != null &&
+                        (ce.getMessage().contains("timed out") || 
ce.getMessage().contains("Network is unreachable"))) {
+                    logger.warn("RMI Connection timed out or network is 
unreachable, will reconnect on next request.");
                     JMXConnector jmxConnector = 
jmxConnectors.remove(serviceUrl);
                     try {
                         if (jmxConnector != null) {
@@ -323,7 +324,8 @@ public class ClusterServiceImpl implements ClusterService {
                 try {
                     jmxConnector.close();
                 } catch (IOException e1) {
-                    logger.error("Error closing invalid JMX connection", e1);
+                    logger.warn("Closing invalid JMX connection resulted in :" 
+ e1.getMessage() + ", this is probably ok.");
+                    logger.debug("Error closing invalid JMX connection", e1);
                 }
                 if (e.getMessage() != null && 
e.getMessage().contains("Connection closed")) {
                     logger.warn("JMX connection to url {} was closed 
(Cause:{}). Reconnecting...", url, e.getMessage());

Reply via email to