Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix channelId overflow #4962

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class KrakenStreamingService extends JsonNettyStreamingService {
private static final String EVENT = "event";
private static final String WEBSOCKET_REQUESTS_PER_SECOND =
"Kraken_Websocket_Requests_Per_Second";
private final Map<Integer, String> channels = new ConcurrentHashMap<>();
private final Map<Long, String> channels = new ConcurrentHashMap<>();
private final ObjectMapper mapper = StreamingObjectMapperHelper.getObjectMapper();
private final boolean isPrivate;
private final Supplier<KrakenWebsocketToken> authData;
Expand Down Expand Up @@ -167,7 +167,7 @@ protected void handleMessage(JsonNode message) {
}
statusMessage.setChannelName(channelName);

Integer channelId = statusMessage.getChannelID();
Long channelId = statusMessage.getChannelID();
switch (statusMessage.getStatus()) {
case subscribed:
LOG.info("Channel name={}, id={} has been subscribed", channelName, channelId);
Expand Down Expand Up @@ -229,7 +229,7 @@ protected void handleMessage(JsonNode message) {
protected String getChannelNameFromMessage(JsonNode message) throws IOException {
String channelName = null;
if (message.has("channelID")) {
int channelId = message.get("channelID").asInt();
long channelId = message.get("channelID").asLong();
return channels.getOrDefault(channelId, String.valueOf(channelId));
}
if (message.has("channelName")) {
Expand All @@ -238,9 +238,9 @@ protected String getChannelNameFromMessage(JsonNode message) throws IOException
}

if (message.isArray()) {
if (message.get(0).isInt()) {
LOG.trace("Taking channelName from ID from first field INT).");
int channelId = message.get(0).asInt();
if (message.get(0).isLong()) {
LOG.trace("Taking channelName from ID from first field LONG).");
long channelId = message.get(0).asLong();
return channels.getOrDefault(channelId, String.valueOf(channelId));
}
if (message.get(1).isTextual()) {
Expand Down Expand Up @@ -390,4 +390,4 @@ static Integer parseOrderBookSize(Object[] args) {
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class KrakenSubscriptionStatusMessage extends KrakenEvent {

private final Integer channelID;
private final Long channelID;
private final Integer reqid;
private final KrakenSubscriptionStatus status;
private final String pair;
Expand All @@ -21,7 +21,7 @@ public class KrakenSubscriptionStatusMessage extends KrakenEvent {
@JsonCreator
public KrakenSubscriptionStatusMessage(
@JsonProperty("event") KrakenEventType event,
@JsonProperty("channelID") Integer channelID,
@JsonProperty("channelID") Long channelID,
@JsonProperty("reqid") Integer reqid,
@JsonProperty("status") KrakenSubscriptionStatus status,
@JsonProperty("pair") String pair,
Expand All @@ -36,7 +36,7 @@ public KrakenSubscriptionStatusMessage(
this.errorMessage = errorMessage;
}

public Integer getChannelID() {
public Long getChannelID() {
return channelID;
}

Expand Down Expand Up @@ -67,4 +67,4 @@ public String getChannelName() {
public void setChannelName(String channelName) {
this.channelName = channelName;
}
}
}
Loading