• 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/support/DecoderMap.java
1
/**
2
 * Created on 2018/3/20.
3
 */
4
package com.alicp.jetcache.support;
5

6
import com.alicp.jetcache.anno.SerialPolicy;
7

8
import java.util.concurrent.ConcurrentHashMap;
9
import java.util.concurrent.locks.ReentrantLock;
10

11
/**
12
 * @author huangli
13
 */
14
public class DecoderMap {
15

16
    private final ConcurrentHashMap<Integer, AbstractValueDecoder> decoderMap = new ConcurrentHashMap<>();
×
17
    private volatile boolean inited = false;
×
18
    private final ReentrantLock reentrantLock = new ReentrantLock();
×
19

20
    private static final DecoderMap instance = new DecoderMap();
×
21

22
    public DecoderMap() {
×
23
    }
×
24

25
    public static DecoderMap defaultInstance() {
26
        return instance;
×
27
    }
28

29
    public AbstractValueDecoder getDecoder(int identityNumber) {
30
        return decoderMap.get(identityNumber);
×
31
    }
32

33
    public void register(int identityNumber, AbstractValueDecoder decoder) {
34
        decoderMap.put(identityNumber, decoder);
×
35
    }
×
36

37
    public void clear() {
38
        decoderMap.clear();
×
39
    }
×
40

41
    public ReentrantLock getLock() {
42
        return reentrantLock;
×
43
    }
44

45
    public void setInited(boolean inited) {
46
        this.inited = inited;
×
47
    }
×
48

49
    public void initDefaultDecoder() {
50
        if (inited) {
×
51
            return;
×
52
        }
53
        reentrantLock.lock();
×
54
        try {
55
            if (inited) {
×
56
                return;
×
57
            }
58
            register(SerialPolicy.IDENTITY_NUMBER_JAVA, defaultJavaValueDecoder());
×
59
            register(SerialPolicy.IDENTITY_NUMBER_KRYO4, KryoValueDecoder.INSTANCE);
×
60
            register(SerialPolicy.IDENTITY_NUMBER_KRYO5, Kryo5ValueDecoder.INSTANCE);
×
61
            // register(SerialPolicy.IDENTITY_NUMBER_FASTJSON2, Fastjson2ValueDecoder.INSTANCE);
62
            inited = true;
×
63
        } finally {
64
            reentrantLock.unlock();
×
65
        }
66
    }
×
67

68
    public static JavaValueDecoder defaultJavaValueDecoder() {
69
        try {
70
            Class.forName("org.springframework.core.ConfigurableObjectInputStream");
×
71
            return SpringJavaValueDecoder.INSTANCE;
×
72
        } catch (ClassNotFoundException e) {
×
73
            return JavaValueDecoder.INSTANCE;
×
74
        }
75
    }
76

77

78
}
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