(Object aa, Object bb)
| 156 | } |
| 157 | |
| 158 | public static Map<String, Object> Extend(Object aa, Object bb) { |
| 159 | Map<String, Object> a = (Map<String, Object>) aa; |
| 160 | Map<String, Object> out = new LinkedHashMap<>(); |
| 161 | // Snapshot the source maps before iterating: callers commonly pass |
| 162 | // shared state like Exchange.options (Collections.synchronizedMap-wrapped) |
| 163 | // that another thread may be writing concurrently. Iterating directly |
| 164 | // would throw ConcurrentModificationException; the snapshot is cheap |
| 165 | // and decouples us from the caller's locking discipline. |
| 166 | for (Map.Entry<String, Object> e : snapshotEntries(a)) { |
| 167 | out.put(e.getKey(), e.getValue()); |
| 168 | } |
| 169 | if (bb != null) { |
| 170 | Map<String, Object> b = (Map<String, Object>) bb; |
| 171 | for (Map.Entry<String, Object> e : snapshotEntries(b)) { |
| 172 | out.put(e.getKey(), e.getValue()); |
| 173 | } |
| 174 | } |
| 175 | return out; |
| 176 | } |
| 177 | |
| 178 | private static List<Map.Entry<String, Object>> snapshotEntries(Map<String, Object> map) { |
| 179 | // synchronized() is a no-op for an unwrapped HashMap and the correct |
no test coverage detected