Skip to content

Commit 3fef2a2

Browse files
committed
fix the bug of getInt2 reported by #287
1 parent a4b39f5 commit 3fef2a2

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

binding/java/pom.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>org.lionsoul</groupId>
66
<artifactId>ip2region</artifactId>
7-
<version>2.6.6</version>
7+
<version>2.7.0</version>
88
<packaging>jar</packaging>
99

1010
<name>ip2region</name>
@@ -41,6 +41,8 @@
4141
<properties>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4343
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
44+
<maven.compiler.source>1.6</maven.compiler.source>
45+
<maven.compiler.target>1.6</maven.compiler.target>
4446
</properties>
4547

4648
<dependencies>

binding/java/src/main/java/org/lionsoul/ip2region/xdb/Searcher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ public static int getInt(byte[] b, int offset) {
235235

236236
public static int getInt2(byte[] b, int offset) {
237237
return (
238-
(b[offset++] & 0x000000FF) |
239-
(b[offset ] & 0x0000FF00)
238+
((b[offset++] & 0x000000FF)) |
239+
((b[offset ] << 8) & 0x0000FF00)
240240
);
241241
}
242242

maker/java/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<properties>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4343
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
44+
<maven.compiler.source>1.6</maven.compiler.source>
45+
<maven.compiler.target>1.6</maven.compiler.target>
4446
</properties>
4547

4648
<dependencies>

maker/java/src/main/java/org/lionsoul/ip2region/xdb/Util.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public static long getIntLong(byte[] b, int offset) {
3636

3737
public static int getInt2(byte[] b, int offset) {
3838
return (
39-
(b[offset++] & 0x000000FF) |
40-
(b[offset ] & 0x0000FF00)
39+
((b[offset++]) & 0x000000FF) |
40+
((b[offset ] << 8) & 0x0000FF00)
4141
);
4242
}
4343

0 commit comments

Comments
 (0)