{"record":{"id":"df57450ad6a2955a","repo":"alibaba/canal","slug":"address-is-illegal-eg-127-0-0-1-3306","errorCode":null,"errorMessage":"address[{}] is illegal, eg.127.0.0.1:3306","messagePattern":"address\\[(.+?)\\] is illegal, eg\\.127\\.0\\.0\\.1:3306","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"instance/spring/src/main/java/com/alibaba/otter/canal/instance/spring/support/SocketAddressEditor.java","lineNumber":21,"sourceCode":"import java.beans.PropertyEditorSupport;\nimport java.net.InetSocketAddress;\n\nimport org.springframework.beans.PropertyEditorRegistrar;\nimport org.springframework.beans.PropertyEditorRegistry;\n\nimport com.alibaba.otter.canal.common.utils.AddressUtils;\n\npublic class SocketAddressEditor extends PropertyEditorSupport implements PropertyEditorRegistrar {\n\n    public void registerCustomEditors(PropertyEditorRegistry registry) {\n        registry.registerCustomEditor(InetSocketAddress.class, this);\n    }\n\n    public void setAsText(String text) throws IllegalArgumentException {\n        String[] addresses = AddressUtils.splitIPAndPort(text);\n        if (addresses.length > 0) {\n            if (addresses.length != 2) {\n                throw new RuntimeException(\"address[\" + text + \"] is illegal, eg.127.0.0.1:3306\");\n            } else {\n                setValue(new InetSocketAddress(addresses[0], Integer.valueOf(addresses[1])));\n            }\n        } else {\n            setValue(null);\n        }\n    }\n}\n","sourceCodeStart":3,"sourceCodeEnd":30,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/instance/spring/src/main/java/com/alibaba/otter/canal/instance/spring/support/SocketAddressEditor.java#L3-L30","documentation":"Thrown by SocketAddressEditor.setAsText when Spring is binding a string property to an InetSocketAddress but the text does not split into exactly an IP and a port. AddressUtils.splitIPAndPort uses lastIndexOf(':') to split; if there is no colon the array is empty (sets null), but if there are extra colons or multiple parts it yields length != 2 and this RuntimeException fires. The expected form is ip:port, e.g. 127.0.0.1:3306.","triggerScenarios":"Spring injects a value into an InetSocketAddress-typed property (canal.instance.master.address, canal.instance.standby.address, data source addresses). The provided string fails the 2-part split, e.g. 'localhost' (no port), '127.0.0.1' (no port), ':3306' (empty host), or a value with a stray colon.","commonSituations":"Typo in instance.properties master.address (missing port), copy-paste leaving a trailing colon, or passing a hostname with a port already baked in incorrectly. Note Integer.valueOf(addresses[1]) can also throw NumberFormatException for a non-numeric port, producing a different exception.","solutions":["Set the address property in ip:port form, e.g. canal.instance.master.address = 127.0.0.1:3306.","For IPv6 use bracketed form [::1]:3306 (splitIPAndPort strips brackets).","Ensure exactly one colon separates host and port; quote the value if your shell/config strips colons.","Verify the port component is numeric to avoid a follow-on NumberFormatException."],"exampleFix":"// before\ncanal.instance.master.address = 127.0.0.1\n\n// after\ncanal.instance.master.address = 127.0.0.1:3306","handlingStrategy":"validation","validationCode":"static InetSocketAddress parse(String hostPort) {\n    int colon = hostPort.replace(\"[\",\"\").replace(\"]\",\"\").lastIndexOf(':');\n    if (colon <= 0) throw new IllegalArgumentException(\"address must be host:port, got: \" + hostPort);\n    String host = hostPort.substring(0, colon), portStr = hostPort.substring(colon + 1);\n    int port = Integer.parseInt(portStr); // throws if non-numeric -> fail fast\n    return new InetSocketAddress(host.replace(\"[\",\"\").replace(\"]\",\"\"), port);\n}","typeGuard":"boolean isHostPort(String s) {\n    int c = s == null ? -1 : s.replace(\"[\",\"\").replace(\"]\",\"\").lastIndexOf(':');\n    if (c <= 0) return false;\n    try { int p = Integer.parseInt(s.substring(c + 1)); return p > 0 && p < 65536; }\n    catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Always specify addresses as ip:port in instance.properties.","Validate address strings in config-loading tests.","Use bracketed form for IPv6 ([::1]:3306)."],"tags":["config","spring","network","property-binding"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}