[hibernate-commits] Hibernate SVN: r18356 - core/trunk/core/src/main/java/org/hibernate/hql/ast/util.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Tue Dec 29 18:21:44 EST 2009


Author: stliu
Date: 2009-12-29 18:21:44 -0500 (Tue, 29 Dec 2009)
New Revision: 18356

Modified:
   core/trunk/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java
Log:
HHH-2166  Long 'in' lists in queries results in a Java stack overflow exception.

Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java	2009-12-29 23:20:19 UTC (rev 18355)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java	2009-12-29 23:21:44 UTC (rev 18356)
@@ -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() );
 			}
 		}
 	}
+
+	
 }



More information about the hibernate-commits mailing list