This is an automated email from the ASF dual-hosted git repository.

jsinovassinnaik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/master by this push:
     new 9fd07d622 UNOMI-930: sync startup log display to avoid to see it twice 
(#749)
9fd07d622 is described below

commit 9fd07d622910d638cd7c0532ddc0b6300d24003e
Author: Jonathan SINOVASSIN-NAIK <[email protected]>
AuthorDate: Fri Mar 6 16:20:39 2026 +0100

    UNOMI-930: sync startup log display to avoid to see it twice (#749)
---
 .../apache/unomi/lifecycle/BundleWatcherImpl.java  | 63 +++++++++++-----------
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git 
a/lifecycle-watcher/src/main/java/org/apache/unomi/lifecycle/BundleWatcherImpl.java
 
b/lifecycle-watcher/src/main/java/org/apache/unomi/lifecycle/BundleWatcherImpl.java
index c18ea6e64..c5930ba1e 100644
--- 
a/lifecycle-watcher/src/main/java/org/apache/unomi/lifecycle/BundleWatcherImpl.java
+++ 
b/lifecycle-watcher/src/main/java/org/apache/unomi/lifecycle/BundleWatcherImpl.java
@@ -51,13 +51,16 @@ public class BundleWatcherImpl implements 
SynchronousBundleListener, ServiceList
     private long matchedRequiredServicesCount = 0;
 
     private BundleContext bundleContext;
-    private boolean startupMessageAlreadyDisplayed = false;
+    private volatile boolean startupMessageAlreadyDisplayed = false;
     private boolean shutdownMessageAlreadyDisplayed = false;
 
     private Integer checkStartupStateRefreshInterval = 60;
 
     private List<ServerInfo> serverInfos = new ArrayList<>();
 
+    // Lock object to synchronize startup message display
+    private final Object startupMessageLock = new Object();
+
     public void setRequiredBundles(Map<String, Boolean> requiredBundles) {
         this.requiredBundles = new ConcurrentHashMap<>(requiredBundles);
     }
@@ -269,48 +272,48 @@ public class BundleWatcherImpl implements 
SynchronousBundleListener, ServiceList
     }
 
     private void destroyScheduler() {
-        scheduledFuture.cancel(true);
+        scheduledFuture.cancel(false);
         scheduledFuture = null;
     }
 
     private void checkStartupComplete() {
-        if (!isStartupComplete()) {
-            startScheduler(getBundleCheckTask());
-            return;
-        }
         if (scheduledFuture != null) {
             destroyScheduler();
         }
-        if (!allAdditionalBundleStarted()) {
+        if (!isStartupComplete()) {
+            startScheduler(getBundleCheckTask());
+            return;
+        } else if (!allAdditionalBundleStarted()) {
             startScheduler(getAdditionalBundleCheckTask());
             return;
         }
-        if (scheduledFuture != null) {
-            destroyScheduler();
-        }
         if (!startupMessageAlreadyDisplayed) {
-            long totalStartupTime = System.currentTimeMillis() - startupTime;
+            synchronized (startupMessageLock) {
+                if (!startupMessageAlreadyDisplayed) {
+                    long totalStartupTime = System.currentTimeMillis() - 
startupTime;
 
-            List<String> logoLines = serverInfos.get(serverInfos.size() - 
1).getLogoLines();
-            if (logoLines != null && !logoLines.isEmpty()) {
-                logoLines.forEach(System.out::println);
+                    List<String> logoLines = 
serverInfos.get(serverInfos.size() - 1).getLogoLines();
+                    if (logoLines != null && !logoLines.isEmpty()) {
+                        logoLines.forEach(System.out::println);
+                    }
+                    
System.out.println("--------------------------------------------------------------------------------------------");
+                    serverInfos.forEach(serverInfo -> {
+                        String versionMessage = MessageFormat.format(" {0} {1} 
({2,date,yyyy-MM-dd HH:mm:ssZ} // {3} // {4} // {5}) ",
+                                
StringUtils.rightPad(serverInfo.getServerIdentifier(), 12, " "), 
serverInfo.getServerVersion(),
+                                serverInfo.getServerBuildDate(), 
serverInfo.getServerTimestamp(), serverInfo.getServerScmBranch(),
+                                serverInfo.getServerBuildNumber());
+                        System.out.println(versionMessage);
+                        LOGGER.info(versionMessage);
+                    });
+                    
System.out.println("--------------------------------------------------------------------------------------------");
+                    System.out.println("Server successfully started " + 
requiredBundles.size() + " bundles and " + requiredServicesFilters.size()
+                            + " required " + "services in " + totalStartupTime 
+ " ms");
+                    LOGGER.info("Server successfully started {} bundles and {} 
required services in {} ms", requiredBundles.size(),
+                            requiredServicesFilters.size(), totalStartupTime);
+                    startupMessageAlreadyDisplayed = true;
+                    shutdownMessageAlreadyDisplayed = false;
+                }
             }
-            
System.out.println("--------------------------------------------------------------------------------------------");
-            serverInfos.forEach(serverInfo -> {
-                String versionMessage = MessageFormat.format(" {0} {1} 
({2,date,yyyy-MM-dd HH:mm:ssZ} // {3} // {4} // {5}) ",
-                        StringUtils.rightPad(serverInfo.getServerIdentifier(), 
12, " "), serverInfo.getServerVersion(),
-                        serverInfo.getServerBuildDate(), 
serverInfo.getServerTimestamp(), serverInfo.getServerScmBranch(),
-                        serverInfo.getServerBuildNumber());
-                System.out.println(versionMessage);
-                LOGGER.info(versionMessage);
-            });
-            
System.out.println("--------------------------------------------------------------------------------------------");
-            System.out.println("Server successfully started " + 
requiredBundles.size() + " bundles and " + requiredServicesFilters.size()
-                    + " required " + "services in " + totalStartupTime + " 
ms");
-            LOGGER.info("Server successfully started {} bundles and {} 
required services in {} ms", requiredBundles.size(),
-                    requiredServicesFilters.size(), totalStartupTime);
-            startupMessageAlreadyDisplayed = true;
-            shutdownMessageAlreadyDisplayed = false;
         }
     }
 

Reply via email to