mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:03:22 +08:00
Merge branch '1.2.x'
This commit is contained in:
commit
d3c70fa198
@ -63,7 +63,7 @@ public class InMemoryTraceRepository implements TraceRepository {
|
||||
Trace trace = new Trace(new Date(), map);
|
||||
synchronized (this.traces) {
|
||||
while (this.traces.size() >= this.capacity) {
|
||||
this.traces.remove(this.capacity - 1);
|
||||
this.traces.remove(this.reverse ? this.capacity - 1 : 0);
|
||||
}
|
||||
if (this.reverse) {
|
||||
this.traces.add(0, trace);
|
||||
|
@ -41,6 +41,20 @@ public class InMemoryTraceRepositoryTests {
|
||||
List<Trace> traces = this.repository.findAll();
|
||||
assertEquals(2, traces.size());
|
||||
assertEquals("bar", traces.get(0).getInfo().get("bar"));
|
||||
assertEquals("foo", traces.get(1).getInfo().get("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reverseFalse() {
|
||||
this.repository.setReverse(false);
|
||||
this.repository.setCapacity(2);
|
||||
this.repository.add(Collections.<String, Object> singletonMap("foo", "bar"));
|
||||
this.repository.add(Collections.<String, Object> singletonMap("bar", "foo"));
|
||||
this.repository.add(Collections.<String, Object> singletonMap("bar", "bar"));
|
||||
List<Trace> traces = this.repository.findAll();
|
||||
assertEquals(2, traces.size());
|
||||
assertEquals("bar", traces.get(1).getInfo().get("bar"));
|
||||
assertEquals("foo", traces.get(0).getInfo().get("bar"));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user