|
9 | 9 | import io.vertx.core.http.HttpMethod; |
10 | 10 | import org.prebid.server.hooks.execution.model.EndpointExecutionPlan; |
11 | 11 | import org.prebid.server.hooks.execution.model.HookHttpEndpoint; |
| 12 | +import org.prebid.server.log.Logger; |
| 13 | +import org.prebid.server.log.LoggerFactory; |
12 | 14 | import org.prebid.server.model.Endpoint; |
13 | 15 |
|
14 | 16 | import java.io.IOException; |
|
21 | 23 | public class ExecutionPlanEndpointsConfigDeserializer |
22 | 24 | extends StdDeserializer<Map<HookHttpEndpoint, EndpointExecutionPlan>> { |
23 | 25 |
|
| 26 | + private static final Logger logger = LoggerFactory.getLogger(ExecutionPlanEndpointsConfigDeserializer.class); |
24 | 27 | private static final TypeReference<Map<ConfigKey, EndpointExecutionPlan>> TEMP_MAP_REFERENCE = |
25 | 28 | new TypeReference<>() { |
26 | 29 | }; |
@@ -58,12 +61,24 @@ private static Map<ConfigKey, EndpointExecutionPlan> unpack(Map<ConfigKey, Endpo |
58 | 61 | Arrays.stream(HookHttpEndpoint.values()) |
59 | 62 | .filter(httpEndpoint -> httpEndpoint.endpoint() == endpoint) |
60 | 63 | .map(HookHttpEndpoint::httpMethod) |
61 | | - .forEach(newHttpMethod -> unpacked.putIfAbsent(new ConfigKey(newHttpMethod, endpoint), value)); |
| 64 | + .forEach(newHttpMethod -> putOrLogWarn(unpacked, new ConfigKey(newHttpMethod, endpoint), value)); |
62 | 65 | } |
63 | 66 |
|
64 | 67 | return unpacked; |
65 | 68 | } |
66 | 69 |
|
| 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 | + |
67 | 82 | private static Map<HookHttpEndpoint, EndpointExecutionPlan> convertKeys(Map<ConfigKey, EndpointExecutionPlan> map, |
68 | 83 | DeserializationContext context) |
69 | 84 | throws JsonMappingException { |
|
0 commit comments