From 7b3f1408f30bbb45d0b7af5fa3799cdf97359f34 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 26 Feb 2014 00:01:31 +0000 Subject: [PATCH] HHH-9001 Unnecessary Stack object being allocated in org.hibernate.engine.internal.Cascade --- .../org/hibernate/engine/internal/Cascade.java | 15 ++++++--------- .../hql/internal/ast/util/NodeTraverser.java | 1 - 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java index 453559c1a3..c052464cc4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java @@ -27,7 +27,6 @@ import java.io.Serializable; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; -import java.util.Stack; import org.hibernate.HibernateException; import org.hibernate.collection.spi.PersistentCollection; @@ -59,6 +58,8 @@ import org.jboss.logging.Logger; */ public final class Cascade { + private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Cascade.class.getName()); + /** * A cascade point that occurs just after the insertion of the parent entity and * just before deletion @@ -102,9 +103,7 @@ public final class Cascade { */ public static final int BEFORE_MERGE = 0; - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Cascade.class.getName()); - - + private int componentPathStackDepth = 0; private int cascadeTo; private EventSource eventSource; private CascadingAction action; @@ -230,7 +229,7 @@ public final class Cascade { final EntityEntry entry = eventSource.getPersistenceContext().getEntry( parent ); if ( entry != null && entry.getStatus() != Status.SAVING ) { final Object loadedValue; - if ( componentPathStack.isEmpty() ) { + if ( componentPathStackDepth == 0 ) { // association defined on entity loadedValue = entry.getLoadedValue( propertyName ); } @@ -298,8 +297,6 @@ public final class Cascade { return type.isEntityType() && ( (EntityType) type ).isLogicalOneToOne(); } - private Stack componentPathStack = new Stack(); - private boolean cascadeAssociationNow(AssociationType associationType) { return associationType.getForeignKeyDirection().cascadeNow(cascadeTo); } @@ -310,7 +307,7 @@ public final class Cascade { final CompositeType componentType, final String componentPropertyName, final Object anything) { - componentPathStack.push( componentPropertyName ); + componentPathStackDepth++; Object[] children = componentType.getPropertyValues( child, eventSource ); Type[] types = componentType.getSubtypes(); for ( int i=0; i