Comments (6)
@e-hubert-opti Can you describe the process leading to the ineffective value of _maxEntries? How do the multiple threads skip the check?
from jersey.
Maybe sharing simple unit tests helps more than long descriptions?
@Test
void test_sequential_usage_of_lru_map() {
Map<Integer, Integer> lruMap = new LRUMap<>(16, 120);
for (int i = 0; i < 100000; i++) {
lruMap.put(i, i);
}
assertThat(lruMap.size()).isLessThanOrEqualTo(120);
}
@Test
void test_concurrent_usage_of_lru_map() {
Map<Integer, Integer> lruMap = new LRUMap<>(16, 120);
ExecutorService executorService = Executors.newFixedThreadPool(10);
for (int i = 0; i < 100000; i++) {
int tmp = i;
executorService.submit(() -> lruMap.put(tmp, tmp));
}
assertThat(lruMap.size()).isLessThanOrEqualTo(120);
}
While the first one obviously passes, the second one gives something like this:
java.lang.AssertionError:
Expecting actual:
33670
to be less than or equal to:
120
Replacing the LRUMap with a thread-safe implementation or synchronizing it (e,g. lruMap = Collections.synchronizedMap(new LRUMap<>(16, 120)) ) will of course also turn the second test green again.
from jersey.
As the Jackson maintainers were very responsive and immediately replaced the usage of com.fasterxml.jackson.jaxrs.util.LRUMap by com.fasterxml.jackson.databind.util.LRUMap (see FasterXML/jackson-jaxrs-providers@60e6941) I adjusted the import in the test above and it looks likes this implementation also fails. Will try to have a closer look.
from jersey.
All good with the change to com.fasterxml.jackson.databind.util.LRUMap. I had a look in the implementation of PrivateMaxEntriesMap and noticed the async draining, so it is just the test which needs to be adjusted for this.
from jersey.
@e-hubert-opti Thank you, we'll use Jackson 2.16.1 with the fix when available.
from jersey.
2.16.1 is released.
from jersey.
Related Issues (20)
- CVE-2023-4043 for jersey-media-json-binding dependency (parsson-1.1.1) HOT 2
- Injection error when using a `DynamicFeature` HOT 3
- Possible NPE in RequestContextFilter when other Filters prioritized
- Carrier Thread pinning on stack CommittingOutputStream.flushBuffer() HOT 9
- Jersey 3.1.7 release HOT 5
- Jersey 3.1.6 not closing request on Jetty earlyEOF HOT 3
- Connection is not stable (wrong detection if SSL context is configured) HOT 1
- Preserve whitespace in Content-Type header HOT 5
- Unexpected javax.net.ssl.SSLHandshakeException in seemingly simple usage scenario with Jersey Client 2 (>= 2.41) HOT 9
- What is the difference between jersey2.x, jersey 3.x and jersey4.x and which one is recommended? HOT 8
- Connection Leak when Circuit Breaker Hystrix Command timeout HOT 2
- 3.1.7 OSGi bundle issue HOT 12
- "MessageBodyWriter not found for media type=application/xml" error preventing upgrade from 2.32 to 2.33 HOT 6
- KeepAlive Caching stops working in 2.41 HOT 1
- Incosistent handling of inherited @Produces annotations HOT 2
- AsyncContext completion attempt after AsyncListener.onError is called HOT 5
- Process dump caused by malicious response headers HOT 3
- ChunkedInput.close is not sufficient to release client connections HOT 2
- Json Jackon Maven test failing for version 3.1.3 HOT 1
- NPE after switching to jersey-micrometer HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jersey.