db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Pendleton <bpendleton.de...@gmail.com>
Subject Re: [jira] [Updated] (DERBY-6803) Change Sqlca and SqlException in NetworkClient to call MessageUtils
Date Sun, 26 Jul 2015 15:46:28 GMT
On 7/25/2015 4:49 PM, Abhinav Gupta wrote:
> Hi Bryan,
> I studied your patch and it was helpful. But I still have doubts about the implementation
of getArgs() in MessageUtils

Hi Abhinav,

My idea for MessageUtils.getArgs() is that it will do the opposite
of MessageUtils.encodeMessageAndArgumentsAsSqlerrmc().

That is,  MessageUtils.encodeMessageAndArgumentsAsSqlerrmc() takes
a messageId and an Object[]args, and sticks them together into a string.

MessageUtils.getArgs() reverses that process, taking the sqlerrmc string,
and extracting each of the message arguments into a separate String,
which it then puts into an Object [] array and returns.

I think we have already seen the code for this, you can find it
in MessageUtils.getLocalizedMessage, just after the comment:

         // get messageId and arguments, messageId is necessary for us to look up
         // localized message from property file.  messageId was sent as the last
         // token in the sqlerrmc.

So my suggestion is to extract that bit of code from getLocalizedMessage
out into a separate method, called getArgs(), so that we can call
it both from getLocalizedMessage AND from Sqlca.getArgs().

As to the other question you asked, about whether the special
constants such as SQLERRMC_TOKEN_DELIMITER need to be private
in MessageUtils, I don't think that is a requirement.

Eventually, I'd like to see all these details about the encoding and
decoding of message ids and arguments in the sqlerrmc be fully
encapsulated in the MessageUtils class, but we can achieve that
incrementally, over time; we don't have to do that in the first

So it's fine in my opinion to leave them public, as you did in your
most recent patch proposal to DERBY-6801.



View raw message