Description

The method org.apache.commons.digester.Digester.endDocument() pops the main
stack in a loop, but does not perform the same operation on stacksByName. This
is inconsistent, and may result in an ever-growing stack if a Digester instance
is cached and reused (notwithstanding documentation that Digester instances
should not be reused anyway).
An alternative to clearing stacksByName in endDocument() would be to do so in
clear().

It also would be more consistent (and useful) to have a method
public Object peek(String stackName, int n);