[ 
https://issues.apache.org/jira/browse/DERBY-6169?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Knut Anders Hatlen updated DERBY-6169:
--------------------------------------

    Attachment: derby-6169-04-a.diff

Attaching derby-6169-04-a.diff which improves the encapsulation of the 
savedObjects field in GenericPreparedStatement.

The field is exposed through the public method getSavedObjects(), and since 
it's an array, the caller may modify it and change the state directly. And, in 
fact, VTIResultSet does exactly that during execution, which is a bit ugly. It 
does that in order to lazily initialize one of the saved objects. And when 
performing the lazy initialization, it also uses the broken double-checked 
locking idiom, which should be avoided.

The patch cleans up this usage by removing the lazy initialization code in 
VTIResultSet. Instead, it ensures that FromVTI creates a proper instance of the 
object so that lazy initialization is not needed. Also, it makes 
getSavedObjects() return a read-only view of the internal array (added helper 
method for this in ArrayUtil), so that no other callers are tempted to try the 
same.

In IndexRowToBaseRowResultSet, the call to getSavedObjects() is replaced with 
calls to getSavedObject(int) to make it retrieve only the objects it is 
interested in, rather than the full array.

When I ran the full tests, I saw one unrelated failure logged as DERBY-6196. 
All tests passed when I reran them.
                
> Reduce visibility of classes and methods under impl/sql
> -------------------------------------------------------
>
>                 Key: DERBY-6169
>                 URL: https://issues.apache.org/jira/browse/DERBY-6169
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 10.11.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>         Attachments: derby-6169-01-a.diff, derby-6169-02-a.diff, 
> derby-6169-03-a.diff, derby-6169-04-a.diff
>
>
> My IDE shows many warnings in the classes under impl/sql because they are 
> public and may make parts of the internal state more visible than necessary. 
> I'd like to reduce the visibility of classes and methods, if possible, to 
> make it clearer to IDEs and tools that perform static analysis that the code 
> is only accessed from the same package, and reduce some of the noise from the 
> tools.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to