• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #4179

26 Nov 2024 01:33PM CUT coverage: 71.751% (-0.02%) from 71.773%
#4179

Pull #1277

github

web-flow
Merge 0153e0c5a into fc1a3e3da
Pull Request #1277: fix: Correctly calculate `Content-Length` when reading from a stream

5 of 10 new or added lines in 1 file covered. (50.0%)

7 existing lines in 1 file now uncovered.

8077 of 11257 relevant lines covered (71.75%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdk/InMemoryLRUAccessTokenCache.java
1
package com.box.sdk;
2

3
import java.util.LinkedHashMap;
4
import java.util.Map;
5

6
/**
7
 * Use this class to create an in-memory LRU (least recently used) access token cache to be
8
 * passed to BoxDeveloperEditionAPIConnection.
9
 */
10
public class InMemoryLRUAccessTokenCache implements IAccessTokenCache {
11

12
    private final Map<String, String> cache;
13

14
    /**
15
     * Creates an in-memory LRU access token cache.
16
     *
17
     * @param maxEntries maximum number of entries to store.
18
     */
19
    public InMemoryLRUAccessTokenCache(final int maxEntries) {
×
20
        this.cache = new LinkedHashMap<String, String>(maxEntries, 0.75F, true) {
×
21
            private static final long serialVersionUID = -187234623489L;
22

23
            @Override
24
            protected boolean removeEldestEntry(java.util.Map.Entry<String, String> eldest) {
25
                return size() > maxEntries;
×
26
            }
27
        };
28
    }
×
29

30
    /**
31
     * Add an entry to the cache.
32
     *
33
     * @param key   key to use.
34
     * @param value access token information to store.
35
     */
36
    public void put(String key, String value) {
37
        synchronized (this.cache) {
×
38
            this.cache.put(key, value);
×
39
        }
×
40
    }
×
41

42
    /**
43
     * Get an entry from the cache.
44
     *
45
     * @param key key to look for.
46
     * @return access token information.
47
     */
48
    public String get(String key) {
49
        synchronized (this.cache) {
×
50
            return this.cache.get(key);
×
51
        }
52
    }
53
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc