[ https://issues.apache.org/jira/browse/KAFKA-2100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14640448#comment-14640448 ]
David Jacot commented on KAFKA-2100: ------------------------------------ I have looked at how Errors are used in the java client and I see mainly two options for preserving original error code: 1. We could modify Errors to not default to UNKNOWN and returns an error which preserves the original error code. 2. We could log a warning message when a lookup is made with an unknown error code. Option 1 requires a refactoring of the Errors enum as it is not possible to create an new entry at runtime. One way would be to replace the enum by a class which defines static constants for each error. I think that it is quite clean approach but it is a bit less readable. Also, I'm wondering if not defaulting to UNKNOWN could impact logic of the client, for instance, if a retry is done based on an UNKNOWN error. I have attached a rough patch which show this. All tests pass with it. Option 2 doesn't require any changes in the code base and will warn the end user. I'm wondering how often this happens? Error codes are defined in the protocol so mapping between the client and the server (assuming they use the same version) should be one to one. I would be happy to have any feedback/advice on how to move forward with this. [~gwenshap] Is it what you had in mind? While reading the code of the client, I have noticed that few different ways are used to handle error codes. Mainly, the are keep as numerical values, and sometimes, they are converted to Errors. Would it be better to stay consistent and stick to one way or the other? > Client Error doesn't preserve or display original server error code when it > is an unknown code > ---------------------------------------------------------------------------------------------- > > Key: KAFKA-2100 > URL: https://issues.apache.org/jira/browse/KAFKA-2100 > Project: Kafka > Issue Type: Bug > Components: clients > Reporter: Gwen Shapira > Assignee: David Jacot > Labels: newbie > Attachments: KAFKA-2100-1.patch > > > When the java client receives an unfamiliar error code, it translates it into > UNKNOWN(-1, new UnknownServerException("The server experienced an unexpected > error when processing the request")) > This completely loses the original code, which makes troubleshooting from the > client impossible. > Will be better to preserve the original code and write it to the log when > logging the error. -- This message was sent by Atlassian JIRA (v6.3.4#6332)