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

alibaba / java-dns-cache-manipulator / 1166

pending completion
1166

Pull #148

Appveyor

GitHub
<a href="https://github.com/alibaba/java-dns-cache-manipulator/commit/<a class=hub.com/alibaba/java-dns-cache-manipulator/commit/<a class="double-link" href="https://git"><a class=hub.com/alibaba/java-dns-cache-manipulator/commit/<a class="double-link" href="https://git"><a class=hub.com/alibaba/java-dns-cache-manipulator/commit/<a class="double-link" href="https://git"><a class=hub.com/alibaba/java-dns-cache-manipulator/commit/<a class="double-link" href="https://git"><a class=hub.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000388c2323">56012cec5">&lt;a href=&quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/</a><a class="double-link" href="https://github.com/alibaba/java-dns-cache-manipulator/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/alibaba/java-dns-cache-manipulator/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/alibaba/java-dns-cache-manipulator/commit/&lt;a class=&quot;double-link&quot; href=&quot;https://git">&lt;a class=</a>hub.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000388c2323">56012cec5</a><a href="https://github.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000388c2323">&lt;a href=&quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000388c2323&quot;&gt;&amp;quot;&amp;gt;&amp;amp;lt;a href=&amp;amp;quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/&amp;lt;/a&amp;gt;&amp;lt;a class=&amp;quot;double-link&amp;quot; href=&amp;quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/&amp;amp;lt;a class=&amp;amp;quot;double-link&amp;amp;quot; href=&amp;amp;quot;https://git&amp;quot;&amp;gt;&amp;amp;lt;a class=&amp;lt;/a&amp;gt;hub.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000388c2323&amp;quot;&amp;gt;56012cec5&amp;lt;/a&amp;gt;&amp;lt;a href=&amp;quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000388c2323&amp;quot;&amp;gt;&amp;amp;lt;a href=&amp;amp;quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/56012cec5bb128cd65cd1858816fd000&amp;lt;/a&amp;gt;388c2323&amp;quot;&amp;gt;&amp;amp</a>;quot;&amp;gt;Merge &amp;lt;/a&amp;gt;&amp;lt;a class=&amp;quot;double-link&amp;quot; href=&amp;quot;https://github.com/alibaba/java-dns-cache-manipulator/commit/&amp;... (continued)
Pull Request #148: chore(deps): bump maven-deploy-plugin from 3.1.0 to 3.1.1

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

66.67
/library/src/main/java/com/alibaba/dcm/internal/IpParserUtil.java
1
package com.alibaba.dcm.internal;
2

3
/**
4
 * @author Jerry Lee (oldratlee at gmail dot com)
5
 */
6
final class IpParserUtil {
7
    private static final String INVALID_IP_V6_ADDRESS = ": invalid IPv6 address";
8
    private static final String INVALID_IP_ADDRESS = ": invalid IP address";
9

10
    /**
11
     * source code is dug from {@link java.net.InetAddress#getAllByName(java.lang.String, java.net.InetAddress)}
12
     */
13
    static byte[] ip2ByteArray(String ip) {
14
        boolean ipv6Expected = false;
1✔
15
        if (ip.charAt(0) == '[') {
1✔
16
            // This is supposed to be an IPv6 literal
17
            if (ip.length() > 2 && ip.charAt(ip.length() - 1) == ']') {
×
18
                ip = ip.substring(1, ip.length() - 1);
×
19
                ipv6Expected = true;
×
20
            } else {
21
                // This was supposed to be a IPv6 address, but it's not!
22
                throw new IllegalArgumentException(ip + INVALID_IP_V6_ADDRESS);
×
23
            }
24
        }
25

26
        if (Character.digit(ip.charAt(0), 16) != -1 || (ip.charAt(0) == ':')) {
1✔
27
            // see if it is IPv4 address
28
            byte[] address = IPAddressUtil.textToNumericFormatV4(ip);
1✔
29
            if (address != null) return address;
1✔
30

31
            // see if it is IPv6 address
32
            // Check if a numeric or string zone id is present
33
            address = IPAddressUtil.textToNumericFormatV6(ip);
1✔
34
            if (address != null) return address;
1✔
35

36
            if (ipv6Expected) {
1✔
37
                throw new IllegalArgumentException(ip + INVALID_IP_V6_ADDRESS);
×
38
            } else {
39
                throw new IllegalArgumentException(ip + INVALID_IP_ADDRESS);
1✔
40
            }
41
        } else {
42
            throw new IllegalArgumentException(ip + INVALID_IP_ADDRESS);
1✔
43
        }
44
    }
45

46

47
    private IpParserUtil() {
48
    }
49
}
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