Skip to content

Commit 9998b4a

Browse files
committed
fix: preserve Lucee thread merge scope
1 parent 9698afc commit 9998b4a

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

‎models/QuickBuilder.cfc‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -709,38 +709,37 @@ component accessors="true" transientCache="false" {
709709
timeout = 60000
710710
);
711711

712-
for ( var threadIndex = 1; threadIndex <= threadNames.len(); threadIndex++ ) {
713-
var completedThreadName = threadNames[ threadIndex ];
714-
if ( cfthread[ completedThreadName ].status == "TERMINATED" ) {
715-
var threadError = cfthread[ completedThreadName ].error;
712+
threadNames.each( function( threadName ) {
713+
if ( cfthread[ threadName ].status == "TERMINATED" ) {
714+
var threadError = cfthread[ threadName ].error;
716715
throw(
717716
type = "QuickParallelEagerLoadingException",
718717
message = threadError.keyExists( "message" ) ? threadError.message : "A parallel eager-loading thread failed.",
719718
extendedInfo = serializeJSON( threadError )
720719
);
721720
}
722-
if ( cfthread[ completedThreadName ].status != "COMPLETED" ) {
721+
if ( cfthread[ threadName ].status != "COMPLETED" ) {
723722
throw(
724723
type = "QuickParallelEagerLoadingTimeout",
725724
message = "Parallel eager loading did not complete within 60 seconds."
726725
);
727726
}
728727

729-
var completedRelationName = threadRelations[ completedThreadName ];
730-
var eagerLoadedEntities = cfthread[ completedThreadName ].entities;
728+
var relationName = threadRelations[ threadName ];
729+
var eagerLoadedEntities = cfthread[ threadName ].entities;
731730
for ( var i = 1; i <= targetEntities.len(); i++ ) {
732731
if ( structKeyExists( targetEntities[ i ], "isQuickEntity" ) ) {
733-
var relationshipValue = eagerLoadedEntities[ i ].retrieveRelationship( completedRelationName );
732+
var relationshipValue = eagerLoadedEntities[ i ].retrieveRelationship( relationName );
734733
if ( isNull( relationshipValue ) ) {
735-
targetEntities[ i ].assignRelationship( completedRelationName );
734+
targetEntities[ i ].assignRelationship( relationName );
736735
} else {
737-
targetEntities[ i ].assignRelationship( completedRelationName, relationshipValue );
736+
targetEntities[ i ].assignRelationship( relationName, relationshipValue );
738737
}
739-
} else if ( eagerLoadedEntities[ i ].keyExists( completedRelationName ) ) {
740-
targetEntities[ i ][ completedRelationName ] = eagerLoadedEntities[ i ][ completedRelationName ];
738+
} else if ( eagerLoadedEntities[ i ].keyExists( relationName ) ) {
739+
targetEntities[ i ][ relationName ] = eagerLoadedEntities[ i ][ relationName ];
741740
}
742741
}
743-
}
742+
} );
744743
}
745744

746745
/**

0 commit comments

Comments
 (0)