Repository navigation
fix(server): evaluate Hazelcast switches at runtime to support AOT - #5870
Merged
Merged
Conversation
@ConditionalOnProperty is evaluated at build time with AOT, so sent-notifications-enabled, notification-filters-enabled and hazelcast.enabled were ignored at runtime. Decide inside the factory methods instead: - sentNotificationsMap is null when disabled -> plain NotificationTrigger - notificationFiltersMap is a local map when disabled, so a user defined FilteringNotifier keeps working - hazelcast.enabled disables all three, consistently with the event store Related to #5739, #4773
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #5739.
Problem
@ConditionalOnPropertyis evaluated at build time when AOT is used. After #5739 it is still used onsentNotificationsMap,notificationFiltersMapand on the class (spring.boot.admin.hazelcast.enabled), so these switches are ignored at runtime when the application was built without them. The event store already decides at runtime, which leads to a mixed state withspring.boot.admin.hazelcast.enabled=false.Tested on master (
ac10137bf) in a 3 node cluster, image built without the properties, started with-Dspring.aot.enabled=true:sent-notifications-enabled=falseHazelcastNotificationTriggerNotificationTriggerhazelcast.enabled=falseHazelcastNotificationTrigger+ sent-notifications mapNotificationTriggerWithout AOT both behave correctly.
Changes
@ConditionalOnPropertyfromAdminServerHazelcastAutoConfigurationand decide inside the factory methods (isEnabled, which also checksspring.boot.admin.hazelcast.enabled).sentNotificationsMapreturnsnullwhen disabled, soAdminServerNotifierAutoConfigurationcreates the plainNotificationTrigger(theObjectProvideryields no map).notificationFiltersMapreturns a localConcurrentHashMapwhen disabled, so a user definedFilteringNotifierthat gets the bean injected keeps working. The declared return type changes fromIMaptoConcurrentMap. By default it is still the Hazelcast map.spring.boot.admin.hazelcast.enabled=falsenow disables all three consistently.Tests
AdminServerAutoConfigurationTest: local filters map when disabled, Hazelcast filters map by default,hazelcast.enabled=falsedisables event store and trigger.AdminServerHazelcastAutoConfigurationTest: guard that the class and its methods have no@ConditionalOnProperty. It checks the annotation only, not AOT behaviour.Starting AOT-processed), image built without the properties:HazelcastNotificationTriggerevent-store-enabled=falseHazelcastNotificationTriggersent-notifications-enabled=falseNotificationTriggerhazelcast.enabled=falseNotificationTriggerRelease notes
spring.boot.admin.hazelcast.sent-notifications-enabled,notification-filters-enabledandenabledare now evaluated at runtime and work with AOT.