Skip to content

Commit a9cdbdc

Browse files
authored
Ensure consistent encoding in CacheJournal (#184)
* Use consistent encoding for CacheJournal
1 parent ad9e134 commit a9cdbdc

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/cache/CacheJournal.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ private static boolean checkId(@NotNull RandomAccessFile io, int first, @NotNull
5151
private static String trimArrayToNullTerminator(byte[] bytes) {
5252
for (int i = 0; i < bytes.length; i++)
5353
if (bytes[i] == 0)
54-
return new String(bytes, 0, i);
54+
return new String(bytes, 0, i, StandardCharsets.US_ASCII);
5555

56-
return new String(bytes);
56+
return new String(bytes, StandardCharsets.US_ASCII);
5757
}
5858

5959
boolean hasChunk(@NotNull String streamId, int index) throws IOException {
@@ -276,7 +276,7 @@ void setHeader(byte id, @NotNull String value) throws IOException {
276276

277277
io.seek(offset + MAX_ID_LENGTH + MAX_CHUNKS_SIZE + index * (MAX_HEADER_LENGTH + 1));
278278
io.write(id);
279-
io.write(value.getBytes());
279+
io.write(value.getBytes(StandardCharsets.US_ASCII));
280280
}
281281

282282
@NotNull

0 commit comments

Comments
 (0)