From 452fd4f9ebba8bb8fe555dfd69ef8f047a4777e6 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 08 Jul 2026 16:13:14 +0000
Subject: [PATCH] [#696] Fix embedded server setup failing with "Time service not started" (#687)
---
opendj-server-legacy/src/main/java/org/opends/server/util/TimeThread.java | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/TimeThread.java b/opendj-server-legacy/src/main/java/org/opends/server/util/TimeThread.java
index 103b513..a038dea 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/TimeThread.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/TimeThread.java
@@ -13,6 +13,7 @@
*
* Copyright 2006-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS.
+ * Portions Copyright 2026 3A Systems, LLC
*/
package org.opends.server.util;
@@ -267,13 +268,19 @@
*
* @return A string containing the current time in the local time
* zone.
- * @throws IllegalStateException
- * If the time service has not been started.
*/
- public static String getLocalTime() throws IllegalStateException
+ public static String getLocalTime()
{
- checkState();
- return INSTANCE.timeInfo.localTimestamp;
+ TimeThread instance = INSTANCE;
+ if (instance == null)
+ {
+ // The time service is not running: this happens in offline tools and in
+ // an embedded server that has not been started (or has been stopped),
+ // while log publishers may still emit messages. Compute the timestamp
+ // on demand instead of failing.
+ return new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss Z").format(new Date());
+ }
+ return instance.timeInfo.localTimestamp;
}
--
Gitblit v1.10.0