Skip to content

Commit c89e441

Browse files
committed
Add warning
1 parent fbdad00 commit c89e441

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

src/main/java/org/prebid/server/json/deserializer/ExecutionPlanEndpointsConfigDeserializer.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import io.vertx.core.http.HttpMethod;
1010
import org.prebid.server.hooks.execution.model.EndpointExecutionPlan;
1111
import org.prebid.server.hooks.execution.model.HookHttpEndpoint;
12+
import org.prebid.server.log.Logger;
13+
import org.prebid.server.log.LoggerFactory;
1214
import org.prebid.server.model.Endpoint;
1315

1416
import java.io.IOException;
@@ -21,6 +23,7 @@
2123
public class ExecutionPlanEndpointsConfigDeserializer
2224
extends StdDeserializer<Map<HookHttpEndpoint, EndpointExecutionPlan>> {
2325

26+
private static final Logger logger = LoggerFactory.getLogger(ExecutionPlanEndpointsConfigDeserializer.class);
2427
private static final TypeReference<Map<ConfigKey, EndpointExecutionPlan>> TEMP_MAP_REFERENCE =
2528
new TypeReference<>() {
2629
};
@@ -58,12 +61,24 @@ private static Map<ConfigKey, EndpointExecutionPlan> unpack(Map<ConfigKey, Endpo
5861
Arrays.stream(HookHttpEndpoint.values())
5962
.filter(httpEndpoint -> httpEndpoint.endpoint() == endpoint)
6063
.map(HookHttpEndpoint::httpMethod)
61-
.forEach(newHttpMethod -> unpacked.putIfAbsent(new ConfigKey(newHttpMethod, endpoint), value));
64+
.forEach(newHttpMethod -> putOrLogWarn(unpacked, new ConfigKey(newHttpMethod, endpoint), value));
6265
}
6366

6467
return unpacked;
6568
}
6669

70+
private static void putOrLogWarn(Map<ConfigKey, EndpointExecutionPlan> map,
71+
ConfigKey key,
72+
EndpointExecutionPlan value) {
73+
74+
final Object old = map.putIfAbsent(key, value);
75+
if (old != null) {
76+
logger.warn("""
77+
Combination of old and new config for EndpointExecutionPlan found.
78+
Replace old config with new one for endpoint: {}""", key.endpoint());
79+
}
80+
}
81+
6782
private static Map<HookHttpEndpoint, EndpointExecutionPlan> convertKeys(Map<ConfigKey, EndpointExecutionPlan> map,
6883
DeserializationContext context)
6984
throws JsonMappingException {

0 commit comments

Comments
 (0)