Skip to content

Commit 266ec18

Browse files
committed
Decode byte array properly.
1 parent 654235c commit 266ec18

File tree

1 file changed

+3
-3
lines changed
  • firebase-firestore/src/main/java/com/google/firebase/firestore/bundle

1 file changed

+3
-3
lines changed

firebase-firestore/src/main/java/com/google/firebase/firestore/bundle/BundleReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private BundleElement readNextElement() throws IOException, JSONException {
134134

135135
byte[] c = new byte[nextOpenBracket];
136136
buffer.get(c);
137-
return new String(c);
137+
return charset.decode(ByteBuffer.wrap(c)).toString();
138138
}
139139

140140
/** Returns the index of the first open bracket, or -1 if none is found. */
@@ -152,7 +152,7 @@ private int indexOfOpenBracket() {
152152
}
153153
}
154154

155-
private class ReadJsonResult {
155+
private static final class ReadJsonResult {
156156
private String json;
157157
private int byteCount;
158158

@@ -189,7 +189,7 @@ private ReadJsonResult readJson(int length) throws IOException {
189189
int read = Math.min(remaining, buffer.remaining());
190190
byte[] bytes = new byte[read];
191191
buffer.get(bytes);
192-
json.append(new String(bytes, charset));
192+
json.append(charset.decode(ByteBuffer.wrap(bytes)));
193193

194194
bytesRead += read;
195195
remaining -= read;

0 commit comments

Comments
 (0)