{"record":{"id":"c490dd5ef5ff260d","repo":"nathanmarz/storm","slug":"don-t-know-how-to-convert-o-to-int","errorCode":null,"errorMessage":"Don't know how to convert ${o} + to int","messagePattern":"Don't know how to convert (.+?) \\+ to int","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"storm-core/src/jvm/backtype/storm/utils/Utils.java","lineNumber":296,"sourceCode":"        }\n        if(topology.get_bolts().containsKey(id)) {\n            return topology.get_bolts().get(id).get_common();\n        }\n        if(topology.get_state_spouts().containsKey(id)) {\n            return topology.get_state_spouts().get(id).get_common();\n        }\n        throw new IllegalArgumentException(\"Could not find component with id \" + id);\n    }\n    \n    public static Integer getInt(Object o) {\n        if(o instanceof Long) {\n            return ((Long) o ).intValue();\n        } else if (o instanceof Integer) {\n            return (Integer) o;\n        } else if (o instanceof Short) {\n            return ((Short) o).intValue();\n        } else {\n            throw new IllegalArgumentException(\"Don't know how to convert \" + o + \" + to int\");\n        }\n    }\n    \n    public static long secureRandomLong() {\n        return UUID.randomUUID().getLeastSignificantBits();\n    }\n    \n    \n    public static CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root) {\n        return newCurator(conf, servers, port, root, null);\n    }\n\n    public static class BoundedExponentialBackoffRetry extends ExponentialBackoffRetry {\n\n        protected final int maxRetryInterval;\n\n        public BoundedExponentialBackoffRetry(int baseSleepTimeMs, \n                int maxRetries, int maxSleepTimeMs) {","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/nathanmarz/storm/blob/cdb116e942666973bc4eaa0df098d5bab82739e7/storm-core/src/jvm/backtype/storm/utils/Utils.java#L278-L314","documentation":"Utils.getInt converts a config value object (typically from a Conf map) into an int. It only supports Long, Integer, and Short; any other type (e.g. String, Double) causes an IllegalArgumentException. It exists because Thrift/JSON config values deserializing from YAML often arrive as Long.","triggerScenarios":"Calling Utils.getInt(o) with a String (e.g. \"10\" loaded from an untyped config file), a Double, or a null; passing a config key whose value was set programmatically as a non-integral type into an API that calls getInt internally.","commonSituations":"YAML/JSON config files where a numeric setting was quoted (\"topology.max.spout.pending: \"20\"\"), making it a String at runtime; configs set via a generic Map<String,Object> API with wrong value types.","solutions":["Quote-free the value in the config: remove surrounding quotes so it parses as a number, then restart.","Convert before calling: Utils.getInt(Long.valueOf(o.toString())) or Integer.parseInt(o.toString()) if the value is a numeric String.","Pass an Integer/Long/Short object (cast or re-set the config value with the correct type).","For null, ensure the config key is actually set before reading."],"exampleFix":"// before\nint maxPending = Utils.getInt(conf.get(\"topology.max.spout.pending\")); // value is String \"20\"\n// after\nObject v = conf.get(\"topology.max.spout.pending\");\nint maxPending = (v instanceof Number) ? Utils.getInt(v) : Integer.parseInt(String.valueOf(v));","handlingStrategy":"type-guard","validationCode":"Object v = conf.get(key);\nif (!(v instanceof Long || v instanceof Integer || v instanceof Short)) {\n    throw new IllegalArgumentException(key + \" must be numeric, got: \" + (v == null ? \"null\" : v.getClass().getName()));\n}","typeGuard":"boolean isIntLike(Object o) {\n    return o instanceof Long || o instanceof Integer || o instanceof Short;\n}","tryCatchPattern":"try {\n    int value = Utils.getInt(o);\n} catch (IllegalArgumentException e) {\n    int value = Integer.parseInt(String.valueOf(o)); // handle numeric strings\n}","preventionTips":["Never quote numeric values in YAML/JSON configs","Normalize config maps to typed getters before passing to Storm APIs","Check value class at config-load time and fail fast with a clear message"],"tags":["java","type-conversion","config","storm"],"backgroundTag":"invalid-argument-format","analyzedSha":"cdb116e942666973bc4eaa0df098d5bab82739e7","analyzedAt":"2026-09-12T14:30:00.714Z","contentChangedAt":"2026-09-12T14:30:00.714Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}