Skip to content

Commit a110fe9

Browse files
authored
chore: Make SSE event encode method public API (akka#4484)
1 parent 80371ea commit a110fe9

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

akka-http-core/src/main/java/akka/http/javadsl/model/sse/ServerSentEvent.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@
1616

1717
package akka.http.javadsl.model.sse;
1818

19+
import akka.annotation.DoNotInherit;
20+
import akka.util.ByteString;
21+
import scala.Option;
22+
import scala.jdk.javaapi.OptionConverters;
23+
1924
import java.util.Optional;
2025
import java.util.OptionalInt;
2126

22-
import scala.jdk.javaapi.OptionConverters;
23-
import scala.Option;
24-
2527
/**
2628
* Representation of a server-sent event. According to the specification, an empty data field
2729
* designates an event which is to be ignored which is useful for heartbeats.
30+
* <p>
31+
* Not for user extension
2832
*/
33+
@DoNotInherit
2934
public abstract class ServerSentEvent {
3035

3136
private static final Option<String> stringNone = Option.empty();
@@ -116,4 +121,9 @@ public static ServerSentEvent create(String data,
116121
* Optional reconnection delay in milliseconds.
117122
*/
118123
public abstract OptionalInt getRetry();
124+
125+
/**
126+
* Encode the event to bytes for use in a response
127+
*/
128+
public abstract ByteString encode();
119129
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# internal method made public/added in Java DSL
2+
ProblemFilters.exclude[ReversedMissingMethodProblem]("akka.http.javadsl.model.sse.ServerSentEvent.encode")

akka-http-core/src/main/scala/akka/http/scaladsl/model/sse/ServerSentEvent.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ package scaladsl
77
package model
88
package sse
99

10-
import akka.annotation.InternalStableApi
11-
1210
import java.nio.charset.StandardCharsets.UTF_8
1311
import akka.http.javadsl.model
1412
import akka.util.ByteString
@@ -89,8 +87,7 @@ final case class ServerSentEvent(
8987
require(id.forall(noNewLine), "id must not contain \\n or \\r!")
9088
require(retry.forall(_ > 0), "retry must be a positive number!")
9189

92-
@InternalStableApi
93-
private[scaladsl] def encode = {
90+
override def encode(): ByteString = {
9491
def s = { // Performance fun fact: change this to val and get an ~30% performance penalty!!!
9592
// Why 8? "data:" == 5 + \n\n (1 data (at least) and 1 ending) == 2 and then we add 1 extra to allocate
9693
// a bigger memory slab than data.length since we're going to add data ("data:" + "\n") per line

project/MiMa.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ object MiMa extends AutoPlugin {
1818
override def trigger = allRequirements
1919

2020
// A fork is a branch of the project where new releases are created that are not ancestors of the current release line
21-
val forks = Seq("10.2.", "10.4.", "10.5.")
22-
val currentFork = "10.6."
21+
val forks = Seq("10.2.", "10.4.", "10.5.", "10.6.")
22+
val currentFork = "10.7."
2323

2424
// manually maintained list of previous versions to make sure all incompatibilities are found
2525
// even if so far no files have been been created in this project's mima-filters directory

0 commit comments

Comments
 (0)