Skip to content

Commit

Permalink
Make special key platform-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
freimair committed May 26, 2020
1 parent 198bc6a commit f5d02d1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -234,7 +236,7 @@ private byte[] getSpecialKey() {
*/
private String findSpecialKey(Set<P2PDataStorage.ByteArray> 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);
Expand Down

0 comments on commit f5d02d1

Please sign in to comment.