History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: ST-1
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Terence Parr
Reporter: Kay Röpke
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
StringTemplate

StripIterator is failing with nested ArrayLists containing nulls

Created: 07/Nov/06 09:03 PM   Updated: 11/Jun/08 02:18 AM
Component/s: Java version
Affects Version/s: 3.0
Fix Version/s: 3.1


 Description  « Hide
I just wrote this test:
public void testStripOpOfListOfListsWithNulls() throws Exception {
StringTemplate e = new StringTemplate(
"$strip(data):{list | $strip(list)$}; separator=\",\"$"
);
e = e.getInstanceOf();
List data = new ArrayList();
List dataOne = new ArrayList();
dataOne.add("Hi");
dataOne.add(null);
dataOne.add("mom");
data.add(dataOne);
data.add(null);
List dataTwo = new ArrayList();
dataTwo.add("Hi");
dataTwo.add(null);
dataTwo.add("dad");
dataTwo.add(null);
data.add(dataTwo);
e.setAttribute("data", data);
String expecting = "Himom,HiDad"; // nulls are skipped
assertEqual(e.toString(), expecting);
}

and it fails:
TEST: testStripOpOfListOfListsWithNulls
testStripOpOfListOfListsWithNulls failed: expecting "Himom,HiDad";
found "Hi"

successes: 0
failures: 1

It appears that everything past the first null is truncated. This
doesn't happen with flat lists, there are test cases for that which
pass.
The inner strip makes it trip. Weird. Could this be related to
Iterator sharing in nested ArrayLists? Can't imagine, but it surely
is weird.
Smells like a bug...I don't have time to investigate right now, but
I'll add the test to the testsuite and to the wiki.



 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Terence Parr - 10/Dec/06 12:45 PM
StripIterator had a bug. next() and hasNext() were not correct. Stopped after seeing a null in a list.