{"record":{"id":"b6b7fe1faf0ebc79","repo":"apache/seatunnel","slug":"common-illegal-argument-b6b7fe","errorCode":"COMMON_ILLEGAL_ARGUMENT","errorMessage":"bytes == null","messagePattern":"bytes == null","errorType":"error_code","errorClass":"JdbcConnectorException","httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/xa/XidImpl.java","lineNumber":115,"sourceCode":"                + \":\"\n                + byteToHexString(branchQualifier);\n    }\n\n    /**\n     * Given an array of bytes it will convert the bytes to a hex string representation of the\n     * bytes.\n     *\n     * @param bytes the bytes to convert in a hex string\n     * @param start start index, inclusively\n     * @param end end index, exclusively\n     * @return hex string representation of the byte array\n     */\n    public static String byteToHexString(final byte[] bytes, final int start, final int end) {\n        final int number0xf0 = 0xF0;\n        final int number0x0f = 0x0F;\n        final int number4 = 4;\n        if (bytes == null) {\n            throw new JdbcConnectorException(\n                    CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT, \"bytes == null\");\n        }\n\n        int length = end - start;\n        char[] out = new char[length * 2];\n\n        for (int i = start, j = 0; i < end; i++) {\n            out[j++] = HEX_CHARS[(number0xf0 & bytes[i]) >>> number4];\n            out[j++] = HEX_CHARS[number0x0f & bytes[i]];\n        }\n\n        return new String(out);\n    }\n\n    /**\n     * Given an array of bytes it will convert the bytes to a hex string representation of the\n     * bytes.\n     *","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/xa/XidImpl.java#L97-L133","documentation":"XidImpl.byteToHexString renders XID branch/global qualifier bytes as a hex string for logging/comparison. It validates its input first and throws ILLEGAL_ARGUMENT with 'bytes == null' when a null byte array is passed, since a null qualifier cannot be rendered.","triggerScenarios":"Calling byteToHexString(bytes, start, end) (or the overload that delegates to it) with a null byte[] — typically when an Xid was constructed with null branch/global qualifier bytes and then formatted.","commonSituations":"Custom Xid construction with missing globalTransactionId or branchQualifier; deserializing a corrupt/foreign Xid from a checkpoint state; driver returning an Xid with null fields during recovery.","solutions":["Ensure Xid instances are built with non-null globalTransactionId and branchQualifier arrays (use empty arrays instead of null).","Validate/normalize Xid data before passing it into XidImpl utility methods.","Guard the call site with a null check and substitute a placeholder like \"\" or \"null\" for logging.","Fix the upstream producer of the Xid (checkpoint deserialization or driver recovery) that returned null bytes."],"exampleFix":"// before\nString s = XidImpl.byteToHexString(xid.getBranchQualifier(), 0, xid.getBranchQualifier().length);\n// after\nbyte[] bq = xid.getBranchQualifier();\nString s = bq == null ? \"\" : XidImpl.byteToHexString(bq, 0, bq.length);","handlingStrategy":"type-guard","validationCode":"if (bytes == null) {\n  bytes = new byte[0]; // or skip formatting entirely\n}","typeGuard":"String safeHex(byte[] b) {\n  return b == null ? \"\" : XidImpl.byteToHexString(b, 0, b.length);\n}","tryCatchPattern":"try {\n  String s = XidImpl.byteToHexString(bytes, start, end);\n} catch (JdbcConnectorException e) {\n  if (CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT.equals(e.getErrorCode())) {\n    log.warn(\"Xid qualifier bytes were null; using placeholder\");\n  }\n}","preventionTips":["Always construct Xid instances with non-null (possibly empty) byte arrays.","Validate Xids deserialized from checkpoints before using them.","Sanitize driver-provided Xids during recovery formatting.","Prefer helper wrappers that null-check before hex formatting."],"tags":["jdbc","xa","xid","null-argument"],"backgroundTag":"null-argument","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}