Skip to content

Commit e4d0f76

Browse files
Use LinkedHashMap for deterministic iterations (OpenFeign#1165)
1 parent 17735a3 commit e4d0f76

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

mock/src/main/java/feign/mock/RequestHeaders.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2012-2019 The Feign Authors
2+
* Copyright 2012-2020 The Feign Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
* in compliance with the License. You may obtain a copy of the License at
@@ -17,14 +17,15 @@
1717
import java.util.Arrays;
1818
import java.util.Collection;
1919
import java.util.Collections;
20-
import java.util.HashMap;
20+
import java.util.LinkedHashMap;
2121
import java.util.Map;
2222

2323
public class RequestHeaders {
2424

2525
public static class Builder {
2626

27-
private Map<String, Collection<String>> headers = new HashMap<String, Collection<String>>();
27+
private Map<String, Collection<String>> headers =
28+
new LinkedHashMap<String, Collection<String>>();
2829

2930
private Builder() {}
3031

mock/src/test/java/feign/mock/RequestHeadersTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2012-2019 The Feign Authors
2+
* Copyright 2012-2020 The Feign Authors
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
* in compliance with the License. You may obtain a copy of the License at
@@ -83,6 +83,6 @@ public void shouldPrintHeaders() {
8383
.add("other header", "val2")
8484
.add("header", Arrays.asList("val3", "val4"))
8585
.build();
86-
assertThat(headers.toString()).isEqualTo("other header=[val2], header=[val, val3, val4]");
86+
assertThat(headers.toString()).isEqualTo("header=[val, val3, val4], other header=[val2]");
8787
}
8888
}

0 commit comments

Comments
 (0)