groovy

AbstractReaderSource.getLine always returns null when no Janitor

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major 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 :
    2

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.

Activity

Hide
Hamlet D'Arcy added a comment -

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.

Show
Hamlet D'Arcy added a comment - 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.
Hide
Hamlet D'Arcy added a comment -

this is fixed in the trunk, but I'm waiting to get branch access privileges to check into 1.6.4

Show
Hamlet D'Arcy added a comment - this is fixed in the trunk, but I'm waiting to get branch access privileges to check into 1.6.4
Hide
Hamlet D'Arcy added a comment -

This is the patch for the 1.6.x branch. i can't check it in myself.

Show
Hamlet D'Arcy added a comment - This is the patch for the 1.6.x branch. i can't check it in myself.
Hide
Hamlet D'Arcy added a comment -

Fixed AbstractReaderSource so that calling getLine with a null janitor no longer returns null and instead returns the source line.

Show
Hamlet D'Arcy added a comment - Fixed AbstractReaderSource so that calling getLine with a null janitor no longer returns null and instead returns the source line.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved:

Time Tracking

Estimated:
2h
Original Estimate - 2 hours
Remaining:
2h
Remaining Estimate - 2 hours
Logged:
Not Specified
Time Spent - Not Specified