File tree Expand file tree Collapse file tree 4 files changed +7
-15
lines changed
main/java/io/vertx/httpproxy/impl
test/java/io/vertx/tests/cache/spi Expand file tree Collapse file tree 4 files changed +7
-15
lines changed Original file line number Diff line number Diff line change 66import io .vertx .httpproxy .spi .cache .Cache ;
77import io .vertx .httpproxy .spi .cache .Resource ;
88
9- import java .util .HashMap ;
10- import java .util .LinkedHashMap ;
11- import java .util .LinkedList ;
12- import java .util .Map ;
9+ import java .util .*;
1310
1411/**
1512 * Simplistic implementation.
1613 */
1714public class CacheImpl implements Cache {
1815
1916 private final int maxSize ;
20- private final LinkedHashMap <String , Resource > data ;
17+ private final Map <String , Resource > data ;
2118
2219 public CacheImpl (CacheOptions options ) {
2320 this .maxSize = options .getMaxSize ();
24- this .data = new LinkedHashMap <>() {
21+ this .data = Collections . synchronizedMap ( new LinkedHashMap <>() {
2522 @ Override
2623 protected boolean removeEldestEntry (Map .Entry <String , Resource > eldest ) {
2724 return size () > maxSize ;
2825 }
29- };
26+ }) ;
3027 }
3128
3229
Original file line number Diff line number Diff line change @@ -122,10 +122,8 @@ private Future<ProxyResponse> tryHandleProxyRequestFromCache(ProxyContext contex
122122 if (etag != null ) {
123123 proxyRequest .headers ().set (HttpHeaders .IF_NONE_MATCH , resource .getEtag ());
124124 context .set ("cached_resource" , resource );
125- return context .sendRequest ();
126- } else {
127- return context .sendRequest ();
128125 }
126+ return context .sendRequest ();
129127 }
130128 }
131129 }
Original file line number Diff line number Diff line change 1616import java .time .Instant ;
1717
1818@ RunWith (VertxUnitRunner .class )
19- public abstract class CacheSpiBase {
19+ public abstract class CacheSpiTestBase {
2020
2121 protected Cache cache ;
2222 protected CacheOptions cacheOptions ;
Original file line number Diff line number Diff line change 11package io .vertx .tests .cache .spi ;
22
3- import io .vertx .core .http .HttpClientOptions ;
4- import io .vertx .ext .unit .TestContext ;
5- import io .vertx .httpproxy .cache .CacheOptions ;
63import io .vertx .httpproxy .impl .CacheImpl ;
74
8- public class LocalCacheTest extends CacheSpiBase {
5+ public class LocalCacheTest extends CacheSpiTestBase {
96
107 @ Override
118 public void setUp () {
You can’t perform that action at this time.
0 commit comments