Skip to content

Commit c33579d

Browse files
authored
fix(fcm): Increase the multicast request count limit to 500. (#321)
* Increase the multicast request count limit to 500. * Update integration test
1 parent d79485d commit c33579d

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

src/main/java/com/google/firebase/messaging/FirebaseMessaging.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected String execute() throws FirebaseMessagingException {
149149
* <p>The responses list obtained by calling {@link BatchResponse#getResponses()} on the return
150150
* value corresponds to the order of input messages.
151151
*
152-
* @param messages A non-null, non-empty list containing up to 100 messages.
152+
* @param messages A non-null, non-empty list containing up to 500 messages.
153153
* @return A {@link BatchResponse} indicating the result of the operation.
154154
* @throws FirebaseMessagingException If an error occurs while handing the messages off to FCM for
155155
* delivery. An exception here indicates a total failure -- i.e. none of the messages in the
@@ -171,7 +171,7 @@ public BatchResponse sendAll(
171171
* <p>The responses list obtained by calling {@link BatchResponse#getResponses()} on the return
172172
* value corresponds to the order of input messages.
173173
*
174-
* @param messages A non-null, non-empty list containing up to 100 messages.
174+
* @param messages A non-null, non-empty list containing up to 500 messages.
175175
* @param dryRun A boolean indicating whether to perform a dry run (validation only) of the send.
176176
* @return A {@link BatchResponse} indicating the result of the operation.
177177
* @throws FirebaseMessagingException If an error occurs while handing the messages off to FCM for
@@ -186,7 +186,7 @@ public BatchResponse sendAll(
186186
/**
187187
* Similar to {@link #sendAll(List)} but performs the operation asynchronously.
188188
*
189-
* @param messages A non-null, non-empty list containing up to 100 messages.
189+
* @param messages A non-null, non-empty list containing up to 500 messages.
190190
* @return @return An {@code ApiFuture} that will complete with a {@link BatchResponse} when
191191
* the messages have been sent.
192192
*/
@@ -197,7 +197,7 @@ public ApiFuture<BatchResponse> sendAllAsync(@NonNull List<Message> messages) {
197197
/**
198198
* Similar to {@link #sendAll(List, boolean)} but performs the operation asynchronously.
199199
*
200-
* @param messages A non-null, non-empty list containing up to 100 messages.
200+
* @param messages A non-null, non-empty list containing up to 500 messages.
201201
* @param dryRun A boolean indicating whether to perform a dry run (validation only) of the send.
202202
* @return @return An {@code ApiFuture} that will complete with a {@link BatchResponse} when
203203
* the messages have been sent, or when the emulation has finished.
@@ -284,8 +284,8 @@ private CallableOperation<BatchResponse, FirebaseMessagingException> sendAllOp(
284284

285285
final List<Message> immutableMessages = ImmutableList.copyOf(messages);
286286
checkArgument(!immutableMessages.isEmpty(), "messages list must not be empty");
287-
checkArgument(immutableMessages.size() <= 100,
288-
"messages list must not contain more than 100 elements");
287+
checkArgument(immutableMessages.size() <= 500,
288+
"messages list must not contain more than 500 elements");
289289
final FirebaseMessagingClient messagingClient = getMessagingClient();
290290
return new CallableOperation<BatchResponse,FirebaseMessagingException>() {
291291
@Override

src/main/java/com/google/firebase/messaging/MulticastMessage.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* Represents a message that can be sent to multiple devices via Firebase Cloud Messaging (FCM).
3333
* Contains payload information as well as the list of device registration tokens to which the
34-
* message should be sent. A single {@code MulticastMessage} may contain up to 100 registration
34+
* message should be sent. A single {@code MulticastMessage} may contain up to 500 registration
3535
* tokens.
3636
*
3737
* <p>Instances of this class are thread-safe and immutable. Use {@link MulticastMessage.Builder}
@@ -55,7 +55,7 @@ public class MulticastMessage {
5555
private MulticastMessage(Builder builder) {
5656
this.tokens = builder.tokens.build();
5757
checkArgument(!this.tokens.isEmpty(), "at least one token must be specified");
58-
checkArgument(this.tokens.size() <= 100, "no more than 100 tokens can be specified");
58+
checkArgument(this.tokens.size() <= 500, "no more than 500 tokens can be specified");
5959
for (String token : this.tokens) {
6060
checkArgument(!Strings.isNullOrEmpty(token), "none of the tokens can be null or empty");
6161
}
@@ -103,7 +103,7 @@ public static class Builder {
103103
private Builder() {}
104104

105105
/**
106-
* Adds a token to which the message should be sent. Up to 100 tokens can be specified on
106+
* Adds a token to which the message should be sent. Up to 500 tokens can be specified on
107107
* a single instance of {@link MulticastMessage}.
108108
*
109109
* @param token A non-null, non-empty Firebase device registration token.
@@ -115,7 +115,7 @@ public Builder addToken(@NonNull String token) {
115115
}
116116

117117
/**
118-
* Adds a collection of tokens to which the message should be sent. Up to 100 tokens can be
118+
* Adds a collection of tokens to which the message should be sent. Up to 500 tokens can be
119119
* specified on a single instance of {@link MulticastMessage}.
120120
*
121121
* @param tokens Collection of Firebase device registration tokens.

src/test/java/com/google/firebase/messaging/FirebaseMessagingIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,16 @@ public void testSendAll() throws Exception {
114114
}
115115

116116
@Test
117-
public void testSendHundred() throws Exception {
117+
public void testSendFiveHundred() throws Exception {
118118
List<Message> messages = new ArrayList<>();
119-
for (int i = 0; i < 100; i++) {
119+
for (int i = 0; i < 500; i++) {
120120
messages.add(Message.builder().setTopic("foo-bar-" + (i % 10)).build());
121121
}
122122

123123
BatchResponse response = FirebaseMessaging.getInstance().sendAll(messages, true);
124124

125-
assertEquals(100, response.getResponses().size());
126-
assertEquals(100, response.getSuccessCount());
125+
assertEquals(500, response.getResponses().size());
126+
assertEquals(500, response.getSuccessCount());
127127
assertEquals(0, response.getFailureCount());
128128
for (SendResponse sendResponse : response.getResponses()) {
129129
if (!sendResponse.isSuccessful()) {

src/test/java/com/google/firebase/messaging/FirebaseMessagingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public void testSendAllWithTooManyMessages() throws FirebaseMessagingException {
296296
MockFirebaseMessagingClient client = MockFirebaseMessagingClient.fromMessageId(null);
297297
FirebaseMessaging messaging = getMessagingForSend(Suppliers.ofInstance(client));
298298
ImmutableList.Builder<Message> listBuilder = ImmutableList.builder();
299-
for (int i = 0; i < 101; i++) {
299+
for (int i = 0; i < 501; i++) {
300300
listBuilder.add(Message.builder().setTopic("topic").build());
301301
}
302302

src/test/java/com/google/firebase/messaging/MulticastMessageTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public void testNoTokens() {
7070
@Test
7171
public void testTooManyTokens() {
7272
MulticastMessage.Builder builder = MulticastMessage.builder();
73-
for (int i = 0; i < 101; i++) {
73+
for (int i = 0; i < 501; i++) {
7474
builder.addToken("token" + i);
7575
}
7676
try {
7777
builder.build();
78-
fail("No error thrown for more than 100 tokens");
78+
fail("No error thrown for more than 500 tokens");
7979
} catch (IllegalArgumentException expected) {
8080
// expected
8181
}

src/test/java/com/google/firebase/snippets/FirebaseMessagingSnippets.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public void sendAll() throws FirebaseMessagingException {
122122
String registrationToken = "YOUR_REGISTRATION_TOKEN";
123123

124124
// [START send_all]
125-
// Create a list containing up to 100 messages.
125+
// Create a list containing up to 500 messages.
126126
List<Message> messages = Arrays.asList(
127127
Message.builder()
128128
.setNotification(new Notification("Price drop", "5% off all electronics"))

0 commit comments

Comments
 (0)