Class ThreadLocalPropertiesManager
java.lang.Object
com.shaft.properties.internal.ThreadLocalPropertiesManager
Manages per-thread property overrides for SHAFT properties.
When a property is set via the SHAFT.Properties API, it is stored in a
thread-local map so that each test thread has its own isolated configuration.
This prevents cross-thread contamination during parallel test execution.
Call clear() after each test class lifecycle completes to reset
per-thread overrides and prevent stale state when thread pools reuse threads.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear()Clears all thread-local property overrides for the current thread.static PropertiesReturns the live thread-local overrides map for the current thread.static voidsetProperty(String key, String value) Sets a property override for the current thread only.
-
Method Details
-
setProperty
-
getOverrides
Returns the live thread-local overrides map for the current thread. This map is passed toConfigFactory.create()as the highest-priority property source so that any overrides set by the current thread take precedence over system properties and file-based properties.- Returns:
- the current thread's property overrides
-
clear
public static void clear()Clears all thread-local property overrides for the current thread. Should be called at the start of each new test class lifecycle (before@BeforeClassruns) to prevent stale overrides from a previously executed test class on the same pooled thread.
-