Github user revans2 commented on a diff in the pull request:

    https://github.com/apache/storm/pull/1043#discussion_r50897886
  
    --- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
    @@ -1382,5 +1422,438 @@ public static TopologyInfo getTopologyInfo(String 
name, String asUser, Map storm
         public static int toPositive(int number) {
             return number & Integer.MAX_VALUE;
         }
    -}
     
    +
    +
    +    //Everything from here on is translated from the old util.clj 
(storm-core/src/clj/backtype.storm/util.clj)
    +
    +    //Wraps an exception in a RuntimeException if needed
    +    public static Exception wrapInRuntime (Exception e) {
    +        if (e instanceof RuntimeException) {
    +            return e;
    +        } else {
    +            return (new RuntimeException(e));
    +        }
    +    }
    +
    +    public static final boolean isOnWindows = 
"Windows_NT".equals(System.getenv("OS"));
    +
    +    public static final String filePathSeparator = 
System.getProperty("file.separator");
    +
    +    public static final String classPathSeparator = 
System.getProperty("path.separator");
    +
    +
    +    /*
    +        Returns the first item of coll for which (pred item) returns 
logical true.
    +        Consumes sequences up to the first match, will consume the entire 
sequence
    +        and return nil if no match is found.
    +     */
    +    public static Object findFirst (IPredicate pred, Collection coll) {
    +        if (coll == null || pred == null) {
    +            return null;
    +        } else {
    +            Iterator<Object> iter = coll.iterator();
    +            if (iter==null || !iter.hasNext()) {
    +                return null;
    +            } else {
    +                do {
    +                    Object obj = iter.next();
    +                    if (pred.test(obj)) {
    +                        return obj;
    +                    }
    +                } while (iter.hasNext());
    +                return null;
    +            }
    +        }
    +    }
    +
    +    public static Object findFirst (IPredicate pred, Map map) {
    +        if (map == null || pred == null) {
    +            return null;
    +        } else {
    +            Iterator<Object> iter = map.entrySet().iterator();
    +            if (iter==null || !iter.hasNext()) {
    +                return null;
    +            } else {
    +                do {
    +                    Object obj = iter.next();
    +                    if (pred.test(obj)) {
    +                        return obj;
    +                    }
    +                } while (iter.hasNext());
    +                return null;
    +            }
    +        }
    +    }
    +    /*
    +        Note: since the following functions are nowhere used in Storm, 
they were not translated:
    +        dissoc-in
    +        indexed
    +        positions
    +        assoc-conj
    +        set-delta
    +
    +        clojurify-structure  because it wouldn't make sense without clojure
    +     */
    +
    +
    +    public static String localHostname () throws UnknownHostException {
    +        return _instance.localHostnameImpl();
    +    }
    +
    +    protected String localHostnameImpl () throws UnknownHostException {
    +        return InetAddress.getLocalHost().getCanonicalHostName();
    +    }
    +
    +    private static String memoizedLocalHostnameString = null;
    +
    +    public static String memoizedLocalHostname () throws 
UnknownHostException {
    +        if (memoizedLocalHostnameString == null) {
    +            memoizedLocalHostnameString = localHostname();
    +        }
    +        return memoizedLocalHostnameString;
    +    }
    +
    +    /*
    +        checks conf for STORM_LOCAL_HOSTNAME.
    +        when unconfigured, falls back to (memoized) guess by 
`local-hostname`.
    +    */
    +    public static String hostname (Map<String, Object> conf) throws 
UnknownHostException  {
    +        if (conf == null) {
    +            return memoizedLocalHostname();
    +        }
    +        Object hostnameString = conf.get(Config.STORM_LOCAL_HOSTNAME);
    +        if (hostnameString == null ) {
    +            return memoizedLocalHostname();
    +        }
    +        if (hostnameString.equals("")) {
    +            return memoizedLocalHostname();
    +        }
    +        return hostnameString.toString();
    --- End diff --
    
    Please just cast it to a string instead.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to