You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by nt...@apache.org on 2017/12/07 16:18:08 UTC

ignite git commit: IGNITE-7008 TcpDiscoverySharedFsIpFinder fails with NPE if address can't be resolved. This closes #3087.

Repository: ignite
Updated Branches:
  refs/heads/master c5c512e46 -> e39283e88


IGNITE-7008 TcpDiscoverySharedFsIpFinder fails with NPE if address can't be resolved. This closes #3087.

Signed-off-by: nikolay_tikhonov <nt...@gridgain.com>


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

Branch: refs/heads/master
Commit: e39283e88d5948ebfe1d8a166e3ed74a9304b7b2
Parents: c5c512e
Author: Andrey V. Mashenkov <an...@gmail.com>
Authored: Thu Dec 7 19:16:25 2017 +0300
Committer: nikolay_tikhonov <nt...@gridgain.com>
Committed: Thu Dec 7 19:17:56 2017 +0300

----------------------------------------------------------------------
 .../sharedfs/TcpDiscoverySharedFsIpFinder.java  | 34 +++++++++-----------
 1 file changed, 15 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e39283e8/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
index a30309c..397af1a 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/sharedfs/TcpDiscoverySharedFsIpFinder.java
@@ -186,29 +186,24 @@ public class TcpDiscoverySharedFsIpFinder extends TcpDiscoveryIpFinderAdapter {
 
         Collection<InetSocketAddress> addrs = new LinkedList<>();
 
-        for (String fileName : folder.list())
-            if (!".svn".equals(fileName)) {
-                InetSocketAddress addr = null;
+        for (String fileName : folder.list()) {
+            StringTokenizer st = new StringTokenizer(fileName, DELIM);
 
-                StringTokenizer st = new StringTokenizer(fileName, DELIM);
+            if (st.countTokens() != 2)
+                continue;
 
-                if (st.countTokens() == 2) {
-                    String addrStr = st.nextToken();
-                    String portStr = st.nextToken();
+            String addrStr = st.nextToken();
+            String portStr = st.nextToken();
 
-                    try {
-                        int port = Integer.parseInt(portStr);
-
-                        addr = new InetSocketAddress(denormalizeAddress(addrStr), port);
-                    }
-                    catch (IllegalArgumentException e) {
-                        U.error(log, "Failed to parse file entry: " + fileName, e);
-                    }
-                }
+            try {
+                int port = Integer.parseInt(portStr);
 
-                if (addr != null)
-                    addrs.add(addr);
+                addrs.add(new InetSocketAddress(denormalizeAddress(addrStr), port));
             }
+            catch (IllegalArgumentException e) {
+                U.error(log, "Failed to parse file entry: " + fileName, e);
+            }
+        }
 
         return Collections.unmodifiableCollection(addrs);
     }
@@ -277,7 +272,8 @@ public class TcpDiscoverySharedFsIpFinder extends TcpDiscoveryIpFinderAdapter {
 
         SB sb = new SB();
 
-        sb.a(normalizeAddress(addr.getAddress().getHostAddress()))
+        // There is no need to normalize hostname as DNS name specification doesn't allow ':' and '_' chars.
+        sb.a(addr.isUnresolved() ? addr.getHostName() : normalizeAddress(addr.getAddress().getHostAddress()))
             .a(DELIM)
             .a(addr.getPort());