BasicFormatterImpl throws NullPointerException when printing and formatting sql that starts with an open parenthesis

Description

When output sql and format sql are selected the BasicFormatterImpl spawns a thread to process logging the sql query. That process iterates through identifying tokens and appropriately formatting the output. If the SQL query starts with a parenthesis (valid according to the SQL spec) it passes to a method to handle open parenthesis. That method expects there to be a lastToken and attempts to get the first character of a null string throwing a NullPointerException and takes down the currently running session in Tomcat/Spring. This is most likely to affect development simply because you would never output SQL in a production environment. I was able to refactor the SQL that generated the exception to not use a starting parenthesis, but the code is significantly less readable because it is quite long with multiple nested queries and unions.

Environment

Windows 8.1, Spring 2.5, Tomcat 6.0.47

Activity

Show:
Brett Meyer
December 4, 2013, 4:03 AM

Can you please attach a test case we can use to reproduce this?

Brett Meyer
December 19, 2013, 10:31 PM

Note: In an attempt to clean up the HHH JIRA, we will be rejecting any ticket that sits in the "Awaiting Test Case" state for 2-3 months with no response. So, if this issue is critical to you, please attach a reproducing test case ASAP. Thanks!

Brett Meyer
March 3, 2014, 3:40 PM

Bulk rejecting issues lacking a test case or recent response.

Assignee

Unassigned

Reporter

Finnian Burn

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure