Skip to content
Merged
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 @@ -17,7 +17,7 @@ public class DndEndSnoozeResponse implements SlackApiTextResponse {
private transient Map<String, List<String>> httpResponseHeaders;

private boolean dndEnabled;
private Integer nextDndStartTs;
private Integer nextDndEndTs;
private Long nextDndStartTs;
private Long nextDndEndTs;
private boolean snoozeEnabled;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class DndInfoResponse implements SlackApiTextResponse {
private transient Map<String, List<String>> httpResponseHeaders;

private boolean dndEnabled;
private Integer nextDndStartTs;
private Integer nextDndEndTs;
private Long nextDndStartTs;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (blocking): Since these getters and setters change from Integer to Long, apps compiled against 1.56.0 will hit NoSuchMethodError until they rebuild. Could we label this semver:minor and ship it in the next minor with an IMPORTANT release note, the same way #1703 did in v1.56.0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, agreed. Changing the return type changes the method descriptor, so apps compiled against 1.56.0 would hit NoSuchMethodError until they rebuild. It's also a source break for anything like int end = r.getNextDndEndTs();. I've labeled this bug + semver:minor and will hold it for the next minor (1.57.0) instead of 1.56.1. I've also updated the PR description to cover the binary break. Proposed release note, in the same style as #1703:

Important

The DND timestamp fields nextDndStartTs, nextDndEndTs, and snoozeEndtime are now Long instead of Integer (#1725). Slack sends 9999999999 when no DND end is scheduled, which is larger than Integer.MAX_VALUE, so these responses and events failed to parse. This affects DndInfoResponse, DndEndSnoozeResponse, DndSetSnoozeResponse, DndTeamInfoResponse.DndTeamMemberInfo, DndUpdatedEvent.DndStatus, and DndUpdatedUserEvent.DndStatus. Code that stores these values as Integer or int needs to use Long or long, and apps need to be recompiled against this version. snoozeRemaining is still Integer.

Does that wording work for you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That wording works for me, it names every affected class and the recompile step. Thanks for updating the description too!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwbrooks which milestone should this go under? The only open 1.x milestone right now is 1.56.1, which is a patch release, so it doesn't seem right for a semver:minor change. Should I create a 1.57.0 milestone, or is there another one you'd like to use?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! I'd put it under 1.56.1, since that milestone is a placeholder for the next release. It already has 9 semver:minor PRs (#1704, #1712, and others), so it'll ship as 1.57.0 and get renamed at release time, the same way the 1.49.1 milestone shipped as v1.50.0.

private Long nextDndEndTs;
private boolean snoozeEnabled;
private Integer snoozeEndtime;
private Long snoozeEndtime;
private Integer snoozeRemaining;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class DndSetSnoozeResponse implements SlackApiTextResponse {
private transient Map<String, List<String>> httpResponseHeaders;

private boolean snoozeEnabled;
private Integer snoozeEndtime;
private Long snoozeEndtime;
private Integer snoozeRemaining;
private boolean snoozeIsIndefinite;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class DndTeamInfoResponse implements SlackApiTextResponse {
@Data
public static class DndTeamMemberInfo {
private boolean dndEnabled;
private Integer nextDndStartTs;
private Integer nextDndEndTs;
private Long nextDndStartTs;
private Long nextDndEndTs;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package test_locally.api.methods;

import com.google.gson.Gson;
import com.slack.api.Slack;
import com.slack.api.SlackConfig;
import com.slack.api.methods.response.dnd.DndEndSnoozeResponse;
import com.slack.api.methods.response.dnd.DndInfoResponse;
import com.slack.api.methods.response.dnd.DndSetSnoozeResponse;
import com.slack.api.methods.response.dnd.DndTeamInfoResponse;
import com.slack.api.util.json.GsonFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -58,4 +64,36 @@ public void test_async() throws Exception {
.get().isOk(), is(true));
}

// https://github.com/slackapi/java-slack-sdk/issues/1719
// Slack returns 9999999999 when no DND end is scheduled, which overflows Integer
@Test
public void timestampsLargerThanIntegerMaxValue() {
Gson gson = GsonFactory.createSnakeCase();
long ts = 9999999999L;

DndInfoResponse info = gson.fromJson(
"{\"ok\":true,\"next_dnd_start_ts\":" + ts + ",\"next_dnd_end_ts\":" + ts + ",\"snooze_endtime\":" + ts + "}",
DndInfoResponse.class);
assertThat(info.getNextDndStartTs(), is(ts));
assertThat(info.getNextDndEndTs(), is(ts));
assertThat(info.getSnoozeEndtime(), is(ts));

DndEndSnoozeResponse endSnooze = gson.fromJson(
"{\"ok\":true,\"next_dnd_start_ts\":" + ts + ",\"next_dnd_end_ts\":" + ts + "}",
DndEndSnoozeResponse.class);
assertThat(endSnooze.getNextDndStartTs(), is(ts));
assertThat(endSnooze.getNextDndEndTs(), is(ts));

DndSetSnoozeResponse setSnooze = gson.fromJson(
"{\"ok\":true,\"snooze_endtime\":" + ts + "}",
DndSetSnoozeResponse.class);
assertThat(setSnooze.getSnoozeEndtime(), is(ts));

DndTeamInfoResponse teamInfo = gson.fromJson(
"{\"ok\":true,\"users\":{\"U123\":{\"dnd_enabled\":true,\"next_dnd_start_ts\":" + ts + ",\"next_dnd_end_ts\":" + ts + "}}}",
DndTeamInfoResponse.class);
assertThat(teamInfo.getUsers().get("U123").getNextDndStartTs(), is(ts));
assertThat(teamInfo.getUsers().get("U123").getNextDndEndTs(), is(ts));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class DndUpdatedEvent implements Event {
public static class DndStatus {
private boolean dndEnabled;
private Integer snoozeRemaining;
private Integer nextDndStartTs;
private Integer nextDndEndTs;
private Long nextDndStartTs;
private Long nextDndEndTs;
private boolean snoozeEnabled;
private boolean snoozeIsIndefinite;
private Integer snoozeEndtime;
private Long snoozeEndtime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DndUpdatedUserEvent implements Event {
@Data
public static class DndStatus {
private boolean dndEnabled;
private Integer nextDndStartTs;
private Integer nextDndEndTs;
private Long nextDndStartTs;
private Long nextDndEndTs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public void deserialize() {
assertThat(event.getUser(), is("U1234"));
assertThat(event.getDndStatus(), is(notNullValue()));
assertThat(event.getDndStatus().isDndEnabled(), is(true));
assertThat(event.getDndStatus().getNextDndStartTs(), is(1450387800));
assertThat(event.getDndStatus().getNextDndEndTs(), is(1450423800));
assertThat(event.getDndStatus().getNextDndStartTs(), is(1450387800L));
assertThat(event.getDndStatus().getNextDndEndTs(), is(1450423800L));
assertThat(event.getDndStatus().isSnoozeEnabled(), is(true));
assertThat(event.getDndStatus().getSnoozeEndtime(), is(1450373897));
assertThat(event.getDndStatus().getSnoozeEndtime(), is(1450373897L));
}

@Test
Expand All @@ -51,4 +51,15 @@ public void serialize() {
assertThat(generatedJson, is(expectedJson));
}

// https://github.com/slackapi/java-slack-sdk/issues/1719
@Test
public void deserialize_timestampsLargerThanIntegerMaxValue() {
String json = "{\"type\":\"dnd_updated\",\"user\":\"U1234\",\"dnd_status\":{\"dnd_enabled\":true,"
+ "\"next_dnd_start_ts\":9999999999,\"next_dnd_end_ts\":9999999999,\"snooze_endtime\":9999999999}}";
DndUpdatedEvent event = GsonFactory.createSnakeCase().fromJson(json, DndUpdatedEvent.class);
assertThat(event.getDndStatus().getNextDndStartTs(), is(9999999999L));
assertThat(event.getDndStatus().getNextDndEndTs(), is(9999999999L));
assertThat(event.getDndStatus().getSnoozeEndtime(), is(9999999999L));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public void deserialize() {
assertThat(event.getUser(), is("U1234"));
assertThat(event.getDndStatus(), is(notNullValue()));
assertThat(event.getDndStatus().isDndEnabled(), is(true));
assertThat(event.getDndStatus().getNextDndStartTs(), is(1450387800));
assertThat(event.getDndStatus().getNextDndEndTs(), is(1450423800));
assertThat(event.getDndStatus().getNextDndStartTs(), is(1450387800L));
assertThat(event.getDndStatus().getNextDndEndTs(), is(1450423800L));
}

@Test
Expand All @@ -47,4 +47,14 @@ public void serialize() {
assertThat(generatedJson, is(expectedJson));
}

// https://github.com/slackapi/java-slack-sdk/issues/1719
@Test
public void deserialize_timestampsLargerThanIntegerMaxValue() {
String json = "{\"type\":\"dnd_updated_user\",\"user\":\"U1234\",\"dnd_status\":{\"dnd_enabled\":true,"
+ "\"next_dnd_start_ts\":9999999999,\"next_dnd_end_ts\":9999999999}}";
DndUpdatedUserEvent event = GsonFactory.createSnakeCase().fromJson(json, DndUpdatedUserEvent.class);
assertThat(event.getDndStatus().getNextDndStartTs(), is(9999999999L));
assertThat(event.getDndStatus().getNextDndEndTs(), is(9999999999L));
}

}
Loading