HHH-2166 Long 'in' lists in queries results in a Java stack overflow exception.

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18356 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Strong Liu 2009-12-29 23:21:44 +00:00
parent 01432e3a16
commit 95e10ad81d
1 changed files with 18 additions and 12 deletions

View File

@ -63,20 +63,26 @@ public class NodeTraverser {
throw new IllegalArgumentException(
"node to traverse cannot be null!" );
}
AST node = ast.getFirstChild();
visitDepthFirst( ast.getFirstChild() );
}
private void visitDepthFirst(AST ast){
if(ast==null){
return;
}
Stack stack = new Stack();
if ( node != null ) {
stack.push( node );
if ( ast != null ) {
stack.push( ast );
while (!stack.empty()) {
node = (AST) stack.pop();
strategy.visit( node );
if ( node.getFirstChild() != null ) {
stack.push( node.getFirstChild() );
}
if ( node.getNextSibling() != null ) {
stack.push( node.getNextSibling() );
}
ast = (AST) stack.pop();
strategy.visit( ast );
if ( ast.getNextSibling() != null )
stack.push( ast.getNextSibling() );
if ( ast.getFirstChild() != null )
stack.push( ast.getFirstChild() );
}
}
}
}