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

alibaba / jetcache / #405

16 Apr 2024 05:58AM UTC coverage: 0.0% (-88.9%) from 88.866%
#405

push

areyouok
add encoding to fix coverage report

0 of 5353 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/jetcache-core/src/main/java/com/alicp/jetcache/CacheGetResult.java
1
/**
2
 * Created on  13-09-09 18:16
3
 */
4
package com.alicp.jetcache;
5

6
import java.util.concurrent.CompletableFuture;
7
import java.util.concurrent.CompletionStage;
8

9
/**
10
 * @author huangli
11
 */
12
public class CacheGetResult<V> extends CacheResult {
13
    private volatile V value;
14
    private volatile CacheValueHolder<V> holder;
15

16
    public static final CacheGetResult NOT_EXISTS_WITHOUT_MSG = new CacheGetResult(CacheResultCode.NOT_EXISTS, null, null);
×
17
    public static final CacheGetResult EXPIRED_WITHOUT_MSG = new CacheGetResult(CacheResultCode.EXPIRED, null ,null);
×
18

19
    public CacheGetResult(CacheResultCode resultCode, String message, CacheValueHolder<V> holder) {
20
        super(CompletableFuture.completedFuture(new ResultData(resultCode, message, holder)));
×
21
    }
×
22

23
    public CacheGetResult(CompletionStage<ResultData> future) {
24
        super(future);
×
25
    }
×
26

27
    public CacheGetResult(Throwable ex) {
28
        super(ex);
×
29
    }
×
30

31
    public V getValue() {
32
        waitForResult();
×
33
        return value;
×
34
    }
35

36
    @Override
37
    protected void fetchResultSuccess(ResultData resultData) {
38
        holder = (CacheValueHolder<V>) resultData.getOriginData();
×
39
        value = (V) unwrapValue(holder);
×
40
        super.fetchResultSuccess(resultData);
×
41
    }
×
42

43
    static Object unwrapValue(Object holder) {
44
        // if @Cached or @CacheCache change type from REMOTE to BOTH (or from BOTH to REMOTE),
45
        // during the dev/publish process, the value type which different application server put into cache server will be different
46
        // (CacheValueHolder<V> and CacheValueHolder<CacheValueHolder<V>>, respectively).
47
        // So we need correct the problem at here and in MultiLevelCache.unwrapHolder
48
        Object v = holder;
×
49
        while (v != null && v instanceof CacheValueHolder) {
×
50
            v = ((CacheValueHolder) v).getValue();
×
51
        }
52
        return v;
×
53
    }
54

55

56
    @Override
57
    protected void fetchResultFail(Throwable e) {
58
        value = null;
×
59
        super.fetchResultFail(e);
×
60
    }
×
61

62
    protected CacheValueHolder<V> getHolder() {
63
        waitForResult();
×
64
        return holder;
×
65
    }
66
}
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