From f5d02d13005fa5928229069846d5b7ef52409997 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Tue, 26 May 2020 12:38:12 +0200 Subject: [PATCH] Make special key platform-independent --- .../main/java/bisq/network/p2p/storage/P2PDataStorage.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java b/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java index 89fb5cba694..4c07518b524 100644 --- a/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java +++ b/p2p/src/main/java/bisq/network/p2p/storage/P2PDataStorage.java @@ -82,6 +82,8 @@ import java.time.Clock; +import java.nio.charset.StandardCharsets; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -222,7 +224,7 @@ public GetUpdatedDataRequest buildGetUpdatedDataRequest(NodeAddress senderNodeAd private byte[] getSpecialKey() { byte[] result = new byte[20]; Arrays.fill(result, (byte) 0); - System.arraycopy(Version.VERSION.getBytes(), 0, result, 0, Version.VERSION.length()); + System.arraycopy(Version.VERSION.getBytes(StandardCharsets.UTF_8), 0, result, 0, Version.VERSION.length()); return result; } @@ -234,7 +236,7 @@ private byte[] getSpecialKey() { */ private String findSpecialKey(Set knownPayloadHashes) { return knownPayloadHashes.stream() - .map(byteArray -> new String(byteArray.bytes).trim()) + .map(byteArray -> new String(byteArray.bytes, StandardCharsets.UTF_8).trim()) .filter(s -> s.matches("^[0-9]\\.[0-9]\\.[0-9]$")) .findFirst() .orElse(null);