[FIX] Забытая обработка исключений base64 в CommonHelper.

This commit is contained in:
Zaxar163 2019-06-11 11:58:21 +03:00
parent af421c3e96
commit 408da409df

View file

@ -154,7 +154,7 @@ public static void removeExc(byte[] exclusion) {
private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> { private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter(); private static final ByteArrayToBase64TypeAdapter INSTANCE = new ByteArrayToBase64TypeAdapter();
private static final Map<byte[], JsonArray> exclusions = new ConcurrentHashMap<>(); private static final Map<byte[], JsonElement> exclusions = new ConcurrentHashMap<>();
private final Base64.Decoder decoder = Base64.getUrlDecoder(); private final Base64.Decoder decoder = Base64.getUrlDecoder();
private final Base64.Encoder encoder = Base64.getUrlEncoder(); private final Base64.Encoder encoder = Base64.getUrlEncoder();
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
@ -170,7 +170,7 @@ public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationCon
} }
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
return new JsonPrimitive(encoder.encodeToString(src)); return exclusions.getOrDefault(src, new JsonPrimitive(encoder.encodeToString(src)));
} }
} }
} }