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

alibaba / jetcache / #448

23 May 2026 01:38PM UTC coverage: 89.341% (+0.4%) from 88.921%
#448

push

areyouok
fix: init fail if Kryo not in classpath

0 of 4 new or added lines in 1 file covered. (0.0%)

27 existing lines in 9 files now uncovered.

5029 of 5629 relevant lines covered (89.34%)

0.89 hits per line

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

83.33
/jetcache-core/src/main/java/com/alicp/jetcache/support/JavaValueEncoder.java
1
package com.alicp.jetcache.support;
2

3
import java.io.ByteArrayOutputStream;
4
import java.io.IOException;
5
import java.io.ObjectOutputStream;
6

7
/**
8
 * Created on 2016/10/4.
9
 *
10
 * @author huangli
11
 */
12
public class JavaValueEncoder extends AbstractValueEncoder {
13

14
    public static final JavaValueEncoder INSTANCE = new JavaValueEncoder(true);
1✔
15

16
    private static final int INIT_BUF_SIZE = 2048;
17

18
    public JavaValueEncoder(boolean useIdentityNumber) {
19
        super(useIdentityNumber);
1✔
20
    }
1✔
21

22
    static ObjectPool<ByteArrayOutputStream> bosPool = new ObjectPool<>(16, new ObjectPool.ObjectFactory<ByteArrayOutputStream>() {
1✔
23
        @Override
24
        public ByteArrayOutputStream create() {
25
            return new ByteArrayOutputStream(INIT_BUF_SIZE);
1✔
26
        }
27

28
        @Override
29
        public void reset(ByteArrayOutputStream obj) {
30
            obj.reset();
1✔
31
        }
1✔
32
    });
33

34
    @Override
35
    public byte[] apply(Object value) {
36
        ByteArrayOutputStream bos = null;
1✔
37
        try {
38
            bos = bosPool.borrowObject();
1✔
39
            if (useIdentityNumber) {
1✔
40
                bos.write((DecoderMap.IDENTITY_NUMBER_JAVA >> 24) & 0xFF);
1✔
41
                bos.write((DecoderMap.IDENTITY_NUMBER_JAVA >> 16) & 0xFF);
1✔
42
                bos.write((DecoderMap.IDENTITY_NUMBER_JAVA >> 8) & 0xFF);
1✔
43
                bos.write(DecoderMap.IDENTITY_NUMBER_JAVA & 0xFF);
1✔
44
            }
45
            ObjectOutputStream oos = new ObjectOutputStream(bos);
1✔
46
            oos.writeObject(value);
1✔
47
            oos.flush();
1✔
48
            return bos.toByteArray();
1✔
UNCOV
49
        } catch (IOException e) {
×
UNCOV
50
            StringBuilder sb = new StringBuilder("Java Encode error. ");
×
UNCOV
51
            sb.append("msg=").append(e.getMessage());
×
52
            throw new CacheEncodeException(sb.toString(), e);
×
53
        } finally {
54
            if (bos != null) {
1✔
55
                bosPool.returnObject(bos);
1✔
56
            }
57
        }
58
    }
59
}
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

© 2026 Coveralls, Inc