File tree 2 files changed +22
-3
lines changed
main/java/org/springframework/web/servlet/function
test/java/org/springframework/web/servlet/function
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -173,7 +173,6 @@ public SseBuilder retry(Duration duration) {
173
173
174
174
@ Override
175
175
public SseBuilder comment (String comment ) {
176
- Assert .hasLength (comment , "Comment must not be empty" );
177
176
String [] lines = comment .split ("\n " );
178
177
for (String line : lines ) {
179
178
field ("" , line );
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2024 the original author or authors.
2
+ * Copyright 2002-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -173,6 +173,26 @@ void sendWithoutData() throws Exception {
173
173
assertThat (this .mockResponse .getContentAsString ()).isEqualTo (expected );
174
174
}
175
175
176
+ @ Test // gh-34608
177
+ void sendHeartbeat () throws Exception {
178
+ ServerResponse response = ServerResponse .sse (sse -> {
179
+ try {
180
+ sse .comment ("" ).send ();
181
+ }
182
+ catch (IOException ex ) {
183
+ throw new UncheckedIOException (ex );
184
+ }
185
+ });
186
+
187
+ ServerResponse .Context context = Collections ::emptyList ;
188
+
189
+ ModelAndView mav = response .writeTo (this .mockRequest , this .mockResponse , context );
190
+ assertThat (mav ).isNull ();
191
+
192
+ String expected = ":\n \n " ;
193
+ assertThat (this .mockResponse .getContentAsString ()).isEqualTo (expected );
194
+ }
195
+
176
196
177
197
private static final class Person {
178
198
You can’t perform that action at this time.
0 commit comments