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

alibaba / java-dns-cache-manipulator / 1267

pending completion
1267

push

Appveyor

oldratlee
chore(ci): upgrade CI JDK 🤖

527 of 645 relevant lines covered (81.71%)

0.82 hits per line

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

75.0
/library/src/main/java/com/alibaba/dcm/DnsCache.java
1
package com.alibaba.dcm;
2

3
import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
4
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
5

6
import javax.annotation.ParametersAreNonnullByDefault;
7
import javax.annotation.concurrent.Immutable;
8
import java.io.Serializable;
9
import java.util.ArrayList;
10
import java.util.List;
11

12
/**
13
 * JVM whole dns cache info, including negative cache.
14
 *
15
 * @author Jerry Lee (oldratlee at gmail dot com)
16
 * @see DnsCacheEntry
17
 * @since 1.2.0
18
 */
19
@Immutable
20
@ParametersAreNonnullByDefault
21
@ReturnValuesAreNonnullByDefault
22
public final class DnsCache implements Serializable {
23
    private static final long serialVersionUID = -8614746635950970028L;
24

25
    private final List<DnsCacheEntry> cache;
26
    private final List<DnsCacheEntry> negativeCache;
27

28
    /**
29
     * Construct a {@link DnsCache}.
30
     */
31
    public DnsCache(@SuppressFBWarnings("EI_EXPOSE_REP2") List<DnsCacheEntry> cache,
32
                    @SuppressFBWarnings("EI_EXPOSE_REP2") List<DnsCacheEntry> negativeCache) {
1✔
33
        this.cache = cache;
1✔
34
        this.negativeCache = negativeCache;
1✔
35
    }
1✔
36

37
    /**
38
     * DNS positive cache.
39
     */
40
    public List<DnsCacheEntry> getCache() {
41
        // defensive copy
42
        return new ArrayList<>(cache);
1✔
43
    }
44

45
    /**
46
     * DNS negative cache.
47
     */
48
    public List<DnsCacheEntry> getNegativeCache() {
49
        // defensive copy
50
        return new ArrayList<>(negativeCache);
1✔
51
    }
52

53
    /**
54
     * {@inheritDoc}
55
     */
56
    @Override
57
    public String toString() {
58
        return "DnsCache{" +
1✔
59
                "cache=" + cache +
60
                ", negativeCache=" + negativeCache +
61
                '}';
62
    }
63

64
    /**
65
     * {@inheritDoc}
66
     */
67
    @Override
68
    public boolean equals(Object o) {
69
        if (this == o) return true;
1✔
70
        if (o == null || getClass() != o.getClass()) return false;
1✔
71

72
        DnsCache dnsCache = (DnsCache) o;
1✔
73

74
        if (!cache.equals(dnsCache.cache))
1✔
75
            return false;
×
76
        return negativeCache.equals(dnsCache.negativeCache);
1✔
77
    }
78

79
    /**
80
     * {@inheritDoc}
81
     */
82
    @Override
83
    public int hashCode() {
84
        int result = cache.hashCode();
×
85
        result = 31 * result + negativeCache.hashCode();
×
86
        return result;
×
87
    }
88
}
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