Begin checking the payload type from the first element in the splitted array, not the second and don't match the first empty string.
This fixes a lot of test cases that failed in Java 8, but worked in Java 7.
There was a change in Java 8 that would omit the empty string at the beginning (see http://stackoverflow.com/a/27477312) and by explicitly not matching the first empty string at the beginning we can be compatible to booth Java 7 and Java 8
diff --git a/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java b/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
index e4eb624..5303876 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
@@ -390,7 +390,7 @@
bb.rewind();
// Split payload at type marker boundaries
- String[] pls = payloadStr.split("(?=<)|(?<=>)");
+ String[] pls = payloadStr.split("((?=<)|(?<=>))(?!\\A)");
l = 0; // Bytearray length
@@ -404,21 +404,21 @@
bb.position(l);
};
- switch (pls[i]) {
+ switch (pls[i-1]) {
case "<b>": // byte
- bb.put(Byte.parseByte(pls[i + 1]));
+ bb.put(Byte.parseByte(pls[i]));
l++;
break;
case "<s>": // short
- bb.putShort(Short.parseShort(pls[i + 1]));
+ bb.putShort(Short.parseShort(pls[i]));
l += 2;
break;
case "<i>": // integer
- bb.putInt(Integer.parseInt(pls[i + 1]));
+ bb.putInt(Integer.parseInt(pls[i]));
l += 4;
break;
case "<l>": // long
- bb.putLong(Long.parseLong(pls[i + 1]));
+ bb.putLong(Long.parseLong(pls[i]));
l += 8;
break;
};