Re: Possible bug in ServerErrorMessage.java
От | Fedechicco |
---|---|
Тема | Re: Possible bug in ServerErrorMessage.java |
Дата | |
Msg-id | CAO+LWty8kgXkr1h2fPQ4-ZZhEoaROMOXov0akc_QTCWLcQRA1Q@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Possible bug in ServerErrorMessage.java (Maciek Sakrejda <msakrejda@truviso.com>) |
Список | pgsql-jdbc |
I used the package postgresql-9.1-902.jdbc4.jar downloaded from the official site and the version 8.3-603 downloaded through the Ubuntu repository. The postgresql i'm using is the 9.1.3. I can hardly send you a repeatable test, since it is obviously a problem with my postgre settings (aka I probably did something wrong while setting the database up). Anyway, IMO, the exception thrown by that piece of code is misleading, since an out of bound exception is thrown while building another exception that should signal another more useful error (which would have probably told me what was my real problem). I don't have the permission of my boss to work in first person on the bug fix, i just felt it was useful to report it. I would point out anyway that the second part of this boolean condition (l_pos < l_length) is completely useless: while(l_chars[l_pos] != '\0' && l_pos < l_length) since it would evaluate false when and only when an out of bound exception has already been thrown by the first part (l_chars[l_pos] != '\0'). Regards, Fedechicco 2012/4/27 Maciek Sakrejda <msakrejda@truviso.com>: >> From what I've seen the line 48 and the following are: >> >> while (l_chars[l_pos] != '\0' && l_pos < l_length) >> { >> l_pos++; >> } >> >> which IMO should be changed in: >> while (l_pos < l_length && l_chars[l_pos] != '\0') > > This seems to be the code in question, to decode the wire ErrorResponse message: > > https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/util/ServerErrorMessage.java#L32 > > Although what you suggested would be more defensive coding, if you > look at the message specification [1], I believe the current code > *should* process any well-formed ErrorResponse message correctly. As > Dave asked, is this consistently reproducible? Also, are you in a > position to make the change you suggested, rebuild the driver, and > retry it yourself? If so, do you get a different message? > > [1]: http://www.postgresql.org/docs/9.1/static/protocol-message-formats.html > --- > Maciek Sakrejda | System Architect | Truviso > > 1065 E. Hillsdale Blvd., Suite 215 > Foster City, CA 94404 > (650) 242-3500 Main > www.truviso.com
В списке pgsql-jdbc по дате отправления: