You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Ben Harris (JIRA)" <ji...@apache.org> on 2015/03/20 01:40:39 UTC

[jira] [Updated] (CAMEL-8520) Camel XMPP doesn't use a DNS resolver to look at SRV records

     [ https://issues.apache.org/jira/browse/CAMEL-8520?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ben Harris updated CAMEL-8520:
------------------------------
    Description: 
Camel XMPP doesn't use a DNS resolver to look at SRV records, whereas in 2.14.1 it did.

In 2.15.0, ConnectionConfiguration calls {{DNSUtil.resolveXMPPDomain(serviceName)}} which runs this code:

{code:title=DNSUtil.java|borderStyle=solid}
public static List<HostAddress> resolveXMPPDomain(final String domain) {
        if (dnsResolver == null) {
            List<HostAddress> addresses = new ArrayList<HostAddress>(1);
            addresses.add(new HostAddress(domain, 5222));
            return addresses;
        }
        return resolveDomain(domain, 'c');
    }
{code}

dnsResolver is never initialised, so it returns the service name, in my case 'jabberzac.org', instead of the actual XMPP server from the SRV Record, 'xmpp.jabberzac.org', which then causes a timeout.

The dnsResolver is meant to be instantiated in init(), which is meant to be called by SmackConfiguration, but never is.

{code:title=DNSUtil.java|borderStyle=solid}
    /**
     * Initializes DNSUtil. This method is automatically called by SmackConfiguration, you don't
     * have to call it manually.
     */
    public static void init() {
        final String[] RESOLVERS = new String[] { "javax.JavaxResolver", "minidns.MiniDnsResolver",
                        "dnsjava.DNSJavaResolver" };
        for (String resolver :RESOLVERS) {
            DNSResolver availableResolver = null;
            String resolverFull = "org.jivesoftware.smack.util.dns" + resolver;
            try {
                Class<?> resolverClass = Class.forName(resolverFull);
                Method getInstanceMethod = resolverClass.getMethod("getInstance");
                availableResolver = (DNSResolver) getInstanceMethod.invoke(null);
                if (availableResolver != null) {
                    setDNSResolver(availableResolver);
                    break;
                }
            }
            catch (ClassNotFoundException|NoSuchMethodException|SecurityException|IllegalAccessException|IllegalArgumentException|InvocationTargetException e) {
                LOGGER.log(Level.FINE, "Exception on init", e);
            }
        }
    }
{code}

2.14.1 doesn't seem to have this problem as DNSUtil class in 2.14.1 doesn't have an init() function which is meant to be 'automatically called', it just has a static code block:

{code}
    static {
        try {
            Hashtable env = new Hashtable();
            env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
            context = new InitialDirContext(env);
        }
        catch (Exception e) {
            // Ignore.
        }
    }
{code}

  was:
Camel XMPP doesn't use a DNS resolver to look at SRV records, whereas in 2.14.1 it did.

In 2.15.0, ConnectionConfiguration calls {{DNSUtil.resolveXMPPDomain(serviceName)}} which runs this code:

{code:title=DNSUtil.java|borderStyle=solid}
public static List<HostAddress> resolveXMPPDomain(final String domain) {
        if (dnsResolver == null) {
            List<HostAddress> addresses = new ArrayList<HostAddress>(1);
            addresses.add(new HostAddress(domain, 5222));
            return addresses;
        }
        return resolveDomain(domain, 'c');
    }
{code}

dnsResolver is never initialised, so it returns the service name, in my case 'jabberzac.org', instead of the actual XMPP server from the SRV Record, 'xmpp.jabberzac.org', which then causes a timeout.

The dnsResolver is meant to be instantiated in init(), which is meant to be called by SmackConfiguration, but never is.

{code:title=DNSUtil.java|borderStyle=solid}
    /**
     * Initializes DNSUtil. This method is automatically called by SmackConfiguration, you don't
     * have to call it manually.
     */
    public static void init() {
        final String[] RESOLVERS = new String[] { "javax.JavaxResolver", "minidns.MiniDnsResolver",
                        "dnsjava.DNSJavaResolver" };
        for (String resolver :RESOLVERS) {
            DNSResolver availableResolver = null;
            String resolverFull = "org.jivesoftware.smack.util.dns" + resolver;
            try {
                Class<?> resolverClass = Class.forName(resolverFull);
                Method getInstanceMethod = resolverClass.getMethod("getInstance");
                availableResolver = (DNSResolver) getInstanceMethod.invoke(null);
                if (availableResolver != null) {
                    setDNSResolver(availableResolver);
                    break;
                }
            }
            catch (ClassNotFoundException|NoSuchMethodException|SecurityException|IllegalAccessException|IllegalArgumentException|InvocationTargetException e) {
                LOGGER.log(Level.FINE, "Exception on init", e);
            }
        }
    }
{code}

2.14.1 doesn't seem to have this problem as DNSUtil class in 2.14.1 doesn't have an init() function which is meant to be 'automatically called'.


> Camel XMPP doesn't use a DNS resolver to look at SRV records
> ------------------------------------------------------------
>
>                 Key: CAMEL-8520
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8520
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-xmpp
>    Affects Versions: 2.15.0
>            Reporter: Ben Harris
>
> Camel XMPP doesn't use a DNS resolver to look at SRV records, whereas in 2.14.1 it did.
> In 2.15.0, ConnectionConfiguration calls {{DNSUtil.resolveXMPPDomain(serviceName)}} which runs this code:
> {code:title=DNSUtil.java|borderStyle=solid}
> public static List<HostAddress> resolveXMPPDomain(final String domain) {
>         if (dnsResolver == null) {
>             List<HostAddress> addresses = new ArrayList<HostAddress>(1);
>             addresses.add(new HostAddress(domain, 5222));
>             return addresses;
>         }
>         return resolveDomain(domain, 'c');
>     }
> {code}
> dnsResolver is never initialised, so it returns the service name, in my case 'jabberzac.org', instead of the actual XMPP server from the SRV Record, 'xmpp.jabberzac.org', which then causes a timeout.
> The dnsResolver is meant to be instantiated in init(), which is meant to be called by SmackConfiguration, but never is.
> {code:title=DNSUtil.java|borderStyle=solid}
>     /**
>      * Initializes DNSUtil. This method is automatically called by SmackConfiguration, you don't
>      * have to call it manually.
>      */
>     public static void init() {
>         final String[] RESOLVERS = new String[] { "javax.JavaxResolver", "minidns.MiniDnsResolver",
>                         "dnsjava.DNSJavaResolver" };
>         for (String resolver :RESOLVERS) {
>             DNSResolver availableResolver = null;
>             String resolverFull = "org.jivesoftware.smack.util.dns" + resolver;
>             try {
>                 Class<?> resolverClass = Class.forName(resolverFull);
>                 Method getInstanceMethod = resolverClass.getMethod("getInstance");
>                 availableResolver = (DNSResolver) getInstanceMethod.invoke(null);
>                 if (availableResolver != null) {
>                     setDNSResolver(availableResolver);
>                     break;
>                 }
>             }
>             catch (ClassNotFoundException|NoSuchMethodException|SecurityException|IllegalAccessException|IllegalArgumentException|InvocationTargetException e) {
>                 LOGGER.log(Level.FINE, "Exception on init", e);
>             }
>         }
>     }
> {code}
> 2.14.1 doesn't seem to have this problem as DNSUtil class in 2.14.1 doesn't have an init() function which is meant to be 'automatically called', it just has a static code block:
> {code}
>     static {
>         try {
>             Hashtable env = new Hashtable();
>             env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
>             context = new InitialDirContext(env);
>         }
>         catch (Exception e) {
>             // Ignore.
>         }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)