{"record":{"id":"a473549fa72146fb","repo":"paascloud/paascloud-master","slug":"tpc100500011","errorCode":"TPC100500011","errorMessage":"TPC100500011","messagePattern":"TPC100500011","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"paascloud-common/paascloud-common-core/src/main/java/com/paascloud/core/mq/MqMessage.java","lineNumber":127,"sourceCode":"\t * Instantiates a new Mq message.\n\t *\n\t * @param message the message\n\t */\n\tpublic MqMessage(Message message) {\n\t\tthis.body = new String(message.getBody());\n\t\tthis.topic = message.getTopic();\n\t\tthis.key = message.getKeys();\n\t\tthis.tag = message.getTags();\n\n\t}\n\n\tprivate static Message buildMessage(String body, String topic, String tag, String key) {\n\t\tMessage message = new Message();\n\t\ttry {\n\t\t\tmessage.setBody(body.getBytes(RemotingHelper.DEFAULT_CHARSET));\n\t\t} catch (UnsupportedEncodingException e) {\n\t\t\tlog.error(\"编码转换,出现异常={}\", e.getMessage(), e);\n\t\t\tthrow new BusinessException(ErrorCodeEnum.TPC100500011);\n\t\t}\n\t\tmessage.setKeys(key);\n\t\tmessage.setTopic(topic);\n\t\tmessage.setTags(tag);\n\t\treturn message;\n\t}\n\n\t/**\n\t * Instantiates a new Mq message.\n\t *\n\t * @param topic the topic\n\t * @param tag   the tag\n\t * @param key   the key\n\t * @param body  the body\n\t */\n\tpublic MqMessage(String topic, String tag, String key, String body) {\n\t\tthis.topic = topic;\n\t\tthis.tag = tag;","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/paascloud/paascloud-master/blob/781281a9503332ed3cef44ea618349d14230a127/paascloud-common/paascloud-common-core/src/main/java/com/paascloud/core/mq/MqMessage.java#L109-L145","documentation":"MqMessage.buildMessage throws ErrorCodeEnum.TPC100500011 when the message body cannot be converted to bytes using the platform default charset (UnsupportedEncodingException from RemotingHelper.DEFAULT_CHARSET). It indicates an internal charset problem while assembling the RocketMQ message.","triggerScenarios":"Calling MqMessage.buildMessage (via checkMessage) where body.getBytes(RemotingHelper.DEFAULT_CHARSET) throws UnsupportedEncodingException — practically only when the JVM does not support the configured default charset name.","commonSituations":"JVM started with an unusual -Dfile.encoding value on a minimal JRE lacking that charset, a broken/custom RemotingHelper constant, or running on a stripped-down runtime image.","solutions":["Check the JVM's file.encoding / default charset; run with a standard value like -Dfile.encoding=UTF-8.","Verify RemotingHelper.DEFAULT_CHARSET resolves to a supported charset name (UTF-8) in your environment.","Log the exception (already done) to confirm which charset name failed, and rebuild/fix the runtime image if the charset is missing."],"exampleFix":"// before\njava -Dfile.encoding=ISO-8859-x -jar app.jar\n// after\njava -Dfile.encoding=UTF-8 -jar app.jar","handlingStrategy":"try-catch","validationCode":"// ensure charset support at startup\nif (!Charset.isSupported(\"UTF-8\")) {\n    throw new IllegalStateException(\"JVM does not support UTF-8\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    Message msg = MqMessage.buildMessage(body, topic, tag, key);\n} catch (BusinessException e) {\n    log.error(\"MQ message charset failure: {}\", e.getMessage(), e);\n}","preventionTips":["Launch JVMs with -Dfile.encoding=UTF-8.","Verify charset support in container startup scripts.","Avoid overriding RemotingHelper.DEFAULT_CHARSET with exotic charsets."],"tags":["mq","rocketmq","encoding","charset"],"backgroundTag":"invalid-config-value","analyzedSha":"781281a9503332ed3cef44ea618349d14230a127","analyzedAt":"2026-09-10T10:59:02.070Z","contentChangedAt":"2026-09-10T10:59:02.070Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}