Unverified Commit ff5a7631 authored by Magnus Leßmann's avatar Magnus Leßmann 👔

WorkAround TS3 sending invalid icon IDs

parent 2cd1dc7c
......@@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
*
* Deployed work-arounds:
* * enterview uses "ctid" instead of "cid"
* * TS3 query sending invalid icon IDs. More info: https://twitter.com/MarkL4YG/status/965174407701385216
*/
public class DataCache implements IDataCache {
......@@ -293,7 +294,7 @@ public class DataCache implements IDataCache {
final Object tempLock = new Object();
final Map<Integer, TS3Channel> newMap = new HashMap<>(messages.size(), 1.1f);
synchronized (lock) {
messages.parallelStream().forEach(o -> {
messages.stream().forEach(o -> {
try {
Integer cid = Integer.parseInt(o.getProperty(PropertyKeys.Channel.ID).orElse("-1"));
if (cid == -1) {
......@@ -328,6 +329,14 @@ public class DataCache implements IDataCache {
c.copyFrom(o);
}
}
// Dirtiest work-around I've ever committed...
if (c.getProperty("channel_icon_id").isPresent()) {
Integer idFromTS = Integer.valueOf(c.getProperty("channel_icon_id").get());
if (idFromTS < 0) {
Long realID = Integer.toUnsignedLong(idFromTS);
c.setProperty("channel_icon_id", realID.toString());
}
}
synchronized (tempLock) {
newMap.put(cid, c);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment