@@ -25,15 +25,25 @@ public static String getEnvOrProperty(String key) {
25
25
}
26
26
27
27
/**
28
- * Fetches a parameter from the ParameterSet or falls back to environment/system properties.
28
+ * Fetches a parameter from the ParameterSet or falls back to
29
+ * environment/system properties.
29
30
*
30
31
* @param parameterSet the ParameterSet to search for the parameter
31
32
* @param parameter the Parameter to fetch from the ParameterSet
32
33
* @param envKey the environment/system property key to use as fallback
33
- * @return the parameter value, or the environment/system property value if the parameter is not set
34
+ * @return the parameter value
35
+ * @throws IllegalStateException if neither the parameter nor
36
+ * the environment/system property is found
34
37
*/
35
- public static String getRequiredOrFallback(ParameterSet parameterSet, Parameter<String> parameter, String envKey) {
36
- return Optional.ofNullable(parameterSet.getOptional(parameter))
37
- .orElse(getEnvOrProperty(envKey));
38
+ public static String getRequiredOrFallback(
39
+ ParameterSet parameterSet, Parameter<String> parameter, String envKey) {
40
+ String value = Optional.ofNullable(parameterSet.getOptional(parameter))
41
+ .orElse(getEnvOrProperty(envKey));
42
+
43
+ if (value == null || value.isEmpty()) {
44
+ throw new IllegalStateException(
45
+ "Required configuration '" + envKey + "' not found in ParameterSet, system properties, or environment variables.");
46
+ }
47
+ return value;
38
48
}
39
49
}
0 commit comments