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 6
6
import io .vertx .httpproxy .spi .cache .Cache ;
7
7
import io .vertx .httpproxy .spi .cache .Resource ;
8
8
9
- import java .util .HashMap ;
10
- import java .util .LinkedHashMap ;
11
- import java .util .LinkedList ;
12
- import java .util .Map ;
9
+ import java .util .*;
13
10
14
11
/**
15
12
* Simplistic implementation.
16
13
*/
17
14
public class CacheImpl implements Cache {
18
15
19
16
private final int maxSize ;
20
- private final LinkedHashMap <String , Resource > data ;
17
+ private final Map <String , Resource > data ;
21
18
22
19
public CacheImpl (CacheOptions options ) {
23
20
this .maxSize = options .getMaxSize ();
24
- this .data = new LinkedHashMap <>() {
21
+ this .data = Collections . synchronizedMap ( new LinkedHashMap <>() {
25
22
@ Override
26
23
protected boolean removeEldestEntry (Map .Entry <String , Resource > eldest ) {
27
24
return size () > maxSize ;
28
25
}
29
- };
26
+ }) ;
30
27
}
31
28
32
29
Original file line number Diff line number Diff line change @@ -122,10 +122,8 @@ private Future<ProxyResponse> tryHandleProxyRequestFromCache(ProxyContext contex
122
122
if (etag != null ) {
123
123
proxyRequest .headers ().set (HttpHeaders .IF_NONE_MATCH , resource .getEtag ());
124
124
context .set ("cached_resource" , resource );
125
- return context .sendRequest ();
126
- } else {
127
- return context .sendRequest ();
128
125
}
126
+ return context .sendRequest ();
129
127
}
130
128
}
131
129
}
Original file line number Diff line number Diff line change 16
16
import java .time .Instant ;
17
17
18
18
@ RunWith (VertxUnitRunner .class )
19
- public abstract class CacheSpiBase {
19
+ public abstract class CacheSpiTestBase {
20
20
21
21
protected Cache cache ;
22
22
protected CacheOptions cacheOptions ;
Original file line number Diff line number Diff line change 1
1
package io .vertx .tests .cache .spi ;
2
2
3
- import io .vertx .core .http .HttpClientOptions ;
4
- import io .vertx .ext .unit .TestContext ;
5
- import io .vertx .httpproxy .cache .CacheOptions ;
6
3
import io .vertx .httpproxy .impl .CacheImpl ;
7
4
8
- public class LocalCacheTest extends CacheSpiBase {
5
+ public class LocalCacheTest extends CacheSpiTestBase {
9
6
10
7
@ Override
11
8
public void setUp () {
You can’t perform that action at this time.
0 commit comments