Skip to content

Commit

Permalink
Fix the initialization of ScriptExpressionFactory
Browse files Browse the repository at this point in the history
There was a cycle in Spring beans that was not completely visible
to Spring, because of the use of static ModelCommonBeans.get()
hack used right in the bean constructor.

The ScriptExpressionFactory construction is now done purely by Spring.

This should fix occasional Jenkins build failures.
  • Loading branch information
mederly committed Sep 20, 2023
1 parent ccddf2d commit 001e741
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public void init() {
instance = this;
}

/** BEWARE! Do not use in constructors of Spring beans! */
public static ModelCommonBeans get() {
return instance;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ public ScriptExpressionFactory(
@NotNull PrismContext prismContext,
@NotNull Collection<FunctionLibraryBinding> builtInLibraryBindings,
@NotNull Collection<ScriptEvaluator> evaluators,
@NotNull ObjectResolver objectResolver) {
@NotNull ObjectResolver objectResolver,
@NotNull FunctionLibraryManager functionLibraryManager) {
this.prismContext = prismContext;
this.builtInLibraryBindings = Collections.unmodifiableCollection(builtInLibraryBindings);
registerEvaluators(evaluators);
this.objectResolver = objectResolver;
this.functionLibraryManager = ModelCommonBeans.get().functionLibraryManager; // TODO initialize via spring?
this.functionLibraryManager = functionLibraryManager;
}

@VisibleForTesting
Expand Down
1 change: 1 addition & 0 deletions model/model-impl/src/main/resources/ctx-model.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
</list>
</constructor-arg>
<constructor-arg name="objectResolver" ref="modelObjectResolver"/>
<constructor-arg name="functionLibraryManager" ref="functionLibraryManager"/>
</bean>

<bean id="functionExpressionEvaluatorFactory"
Expand Down

0 comments on commit 001e741

Please sign in to comment.