Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.6.3
-
Fix Version/s: 1.6.4, 1.7-beta-1
-
Component/s: Compiler
-
Labels:None
-
Environment:All
-
Patch Submitted:Yes
-
Number of attachments :
Description
I'm trying to read the source code out of a SourceUnit. The API has this method declared:
org.codehaus.groovy.control.io.ReaderSource.getLine( int lineNumber, Janitor janitor );
Which is implemented in AbstractReaderSource.
The API/doc says that Janitor is optional, and the code does let you pass a null.
However, if you do pass a null janitor then the function always returns null.
The method is trying to return a field named 'line', but if the janitor is null then cleanup() is called, and line is set to null, so the method always returns null.
I'll submit a patch myself in the next few days. It is easy to write a test for.
Patch and test case for issue.
cleanup() is still called if there is no janitor, but the line field is assigned to a temporary variable and then returned from method in that case.