@@ -24,7 +24,7 @@ public class AWSXRayRecorderBuilder {
2424 private static final Log logger =
2525 LogFactory .getLog (AWSXRayRecorderBuilder .class );
2626
27- private Collection <Plugin > plugins ;
27+ private final Collection <Plugin > plugins ;
2828
2929 private SamplingStrategy samplingStrategy ;
3030 private StreamingStrategy streamingStrategy ;
@@ -42,18 +42,15 @@ private AWSXRayRecorderBuilder() {
4242
4343 public static Optional <ContextMissingStrategy > contextMissingStrategyFromEnvironmentVariable () {
4444 String contextMissingStrategyOverrideValue = System .getenv (ContextMissingStrategy .CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY );
45- if (null != contextMissingStrategyOverrideValue ) {
46- if (contextMissingStrategyOverrideValue .equalsIgnoreCase (LogErrorContextMissingStrategy .OVERRIDE_VALUE )) {
47- return Optional .of (new LogErrorContextMissingStrategy ());
48- } else if (contextMissingStrategyOverrideValue .equalsIgnoreCase (RuntimeErrorContextMissingStrategy .OVERRIDE_VALUE )) {
49- return Optional .of (new RuntimeErrorContextMissingStrategy ());
50- }
51- }
52- return Optional .empty ();
45+ return getContextMissingStrategy (contextMissingStrategyOverrideValue );
5346 }
5447
5548 public static Optional <ContextMissingStrategy > contextMissingStrategyFromSystemProperty () {
5649 String contextMissingStrategyOverrideValue = System .getProperty (ContextMissingStrategy .CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY );
50+ return getContextMissingStrategy (contextMissingStrategyOverrideValue );
51+ }
52+
53+ private static Optional <ContextMissingStrategy > getContextMissingStrategy (String contextMissingStrategyOverrideValue ) {
5754 if (null != contextMissingStrategyOverrideValue ) {
5855 if (contextMissingStrategyOverrideValue .equalsIgnoreCase (LogErrorContextMissingStrategy .OVERRIDE_VALUE )) {
5956 return Optional .of (new LogErrorContextMissingStrategy ());
@@ -167,7 +164,7 @@ public AWSXRayRecorder build() {
167164 client .setEmitter (emitter );
168165 }
169166
170- plugins .stream ().filter (Objects ::nonNull ).forEach (( plugin ) -> {
167+ plugins .stream ().filter (Objects ::nonNull ).forEach (plugin -> {
171168 Map <String , Object > runtimeContext = plugin .getRuntimeContext ();
172169 if (!runtimeContext .isEmpty ()) {
173170 client .putRuntimeContext (plugin .getServiceName (), runtimeContext );
0 commit comments