[hibernate-commits] Hibernate SVN: r18355 - core/branches/Branch_3_3_2_GA_CP/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:20:20 EST 2009


Author: stliu
Date: 2009-12-29 18:20:19 -0500 (Tue, 29 Dec 2009)
New Revision: 18355

Modified:
   core/branches/Branch_3_3_2_GA_CP/core/src/main/java/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_3_2_GA_CP/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java
===================================================================
--- core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java	2009-12-29 22:14:46 UTC (rev 18354)
+++ core/branches/Branch_3_3_2_GA_CP/core/src/main/java/org/hibernate/hql/ast/util/NodeTraverser.java	2009-12-29 23:20:19 UTC (rev 18355)
@@ -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