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

@ -46,7 +46,7 @@ public class NodeTraverser {
public NodeTraverser( VisitationStrategy strategy ) {
this.strategy = strategy;
}
/**
* Traverse the AST tree depth first.
*
@ -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() );
}
}
}
}