Author: stliu
Date: 2009-12-29 18:22:37 -0500 (Tue, 29 Dec 2009)
New Revision: 18357
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/NodeTraverser.java
Log:
JBPAPP-3089 HHH-2166 Long 'in' lists in queries results in a Java stack overflow
exception.
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/NodeTraverser.java
===================================================================
---
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/NodeTraverser.java 2009-12-29
23:21:44 UTC (rev 18356)
+++
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/util/NodeTraverser.java 2009-12-29
23:22:37 UTC (rev 18357)
@@ -46,7 +46,7 @@
public NodeTraverser( VisitationStrategy strategy ) {
this.strategy = strategy;
}
-
+
/**
* Traverse the AST tree depth first.
*
@@ -63,20 +63,26 @@
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() );
}
}
}
+
+
}
Show replies by date