Releases: launchdarkly/okhttp-eventsource
4.1.1
4.1.0
4.0.1
[4.0.1] - 2023-01-09
Added:
StreamClosedWithIncompleteMessageException
(see below).
Fixed:
- When using streaming data mode (see
EventSource.Builder.streamEventData
), if the stream connection was lost before theMessageEvent
was fully read-- that is, before encountering a blank line-- theReader
returned byMessageEvent.getDataReader()
was treating this as a regular EOF condition. That was incorrect; the SSE specification says that in such a case, the incomplete message is invalid and its contents should not be used. Therefore, in this case reading from theReader
will throw aStreamClosedWithIncompleteMessageException
. The caller should handle this by simply throwing away theMessageEvent
.
4.0.0
[4.0.0] - 2022-12-19
This release revises the implementation of EventSource
so that it does not create its own worker threads. The methods for starting and reading a stream now perform synchronous I/O, and the caller is responsible for choosing what thread to start the stream and read the stream on. This makes the core implementation simpler and more efficient, and reduces possibilities for deadlock. If you want to continue using the old asynchronous push model, see the com.launchdarkly.eventsource.background
package.
The configuration API has also been revised to separate out the HTTP functionality and the backoff/retry logic into subcomponents which can be customized or replaced.
Added:
EventSource
methodsreadMessage()
,readAnyEvents()
,messages()
, andanyEvents()
for synchronously reading events.EventSource.Builder(ConnectStrategy)
constructor and theConnectStrategy
andHttpConnectStrategy
classes, for customizing connection parameters.EventSource.Builder(URI)
,(URL)
, and(HttpUrl)
constructors, as shortcuts for minimal HTTP configuration.EventSource.Builder.errorStrategy
and theErrorStrategy
class, for customizing error recovery behavior.EventSource.Builder.retryDelayStrategy
and theRetryDelayStrategy
andDefaultRetryDelayStrategy
classes, for customizing or replacing backoff/jitter behavior.StreamEvent
,CommentEvent
,StartedEvent
, andFaultEvent
classes, representing types of information other thanMessageEvent
that you can read synchronously from the stream.- The
com.launchdarkly.eventsource.background
package, containing theBackgroundEventSource
wrapper for emulating the old push model.
Changed:
EventSource.Builder.restart
is renamed tointerrupt
, to clarify that the restarting of the stream is not done immediately but only happens if you continue trying to read events afterinterrupt()
.EventSource.Builder.backoffResetThreshold
is renamed toretryDelayResetThreshold
, to clarify that it applies to whatever kind ofRetryDelayStrategy
is being used even if that is not the default backoff strategy.EventSource.Builder.reconnectTime
is renamed toretryDelay
, to clarify that it is describing a duration rather than a moment in time.UnsuccessfulResponseException
is renamed toStreamHttpErrorException
, to clarify that it is specifically referring to an HTTP response with an error status.- The implementation of
streamEventData
mode is now simpler and no longer usesPipedInputStream
andPipedOutputStream
internally.
Removed:
ConnectionHandler
andEventSource.Builder.connectionHandler()
: replaced byErrorStrategy
.EventHandler
and theEventSource.Builder(URI, EventHandler)
constructor: replaced byBackgroundEventHandler
if you are usingBackgroundEventSource
.EventSource.Builder
methodsconnectTimeout
,readTimeout
,writeTimeout
,method
,body
,headers
,proxy
,proxyAuthenticator
, andrequestTransformer
: replaced by methods inHttpConnectStrategy
.EventSource.Builder.maxReconnect
: replaced byDefaultRetryDelayStrategy.maxDelay
.EventSource.Builder.maxEventTasksInFlight
: replaced by an equivalent option inBackgroundEventSource
.
3.0.0
[3.0.0] - 2022-12-02
This release expands compatibility of the library with Android by removing Java 8 API usages that are not always available in Android. In effect, it restores the broader compatibility of the 1.x version while preserving the other API/functionality improvements that were added in 2.x. It also removes the previous dependency on SLF4J.
Changed:
- Every
EventSource
andEventSource
method that previously took ajava.time.Duration
parameter now takes(long, TimeUnit)
parameters instead. This is to allow the library to be used from Android code on older platform versions that do not support thejava.time
types. It undoes an API change that was made in the 2.0.0 release. - SLF4J is no longer a dependency. Logging is done entirely through the com.launchdarkly.logging facade; see
EventSource.Builder.logger
. - Previously, if no logging destination was specified, the default behavior was to send log output to SLF4J. Now, the default behavior is to do no logging. If you still want to use SLF4J, do this (for "log.name", substitute whatever you want the logger name to be in SLF4J):
// import com.launchdarkly.logging.*;
// EventSource.Builder builder =
// new EventSource.Builder(myHandler, streamUri);
builder.logger(
LDLogger.withAdapter(LDSLF4J.adapter(), "log.name")
);
Removed:
Logger
interface,EventSource.Builder.logger(Logger)
, andEventSource.Builder.loggerBaseName
. See note above on logging.
2.7.1
[2.7.1] - 2022-08-23
Changed:
- Changed jitter logic that used
java.util.Random
to usejava.security.SecureRandom
. Even though in this case it is not being used for any cryptographic purpose, but only to produce a pseudo-random delay, static analysis tools may still report every use ofjava.util.Random
as a security risk by default. The purpose of this change is simply to avoid such warnings; it has no practical effect on the behavior of the library.
1.11.3
[1.11.3] - 2022-08-22
Changed:
- Changed jitter logic that used
java.util.Random
to usejava.security.SecureRandom
. Even though in this case it is not being used for any cryptographic purpose, but only to produce a pseudo-random delay, static analysis tools may still report every use ofjava.util.Random
as a security risk by default. The purpose of this change is simply to avoid such warnings; it has no practical effect on the behavior of the library.
2.7.0
[2.7.0] - 2022-08-02
The main purpose of this release is to introduce a new logging facade, com.launchdarkly.logging
, to streamline how logging works in LaunchDarkly Java and Android code. Previously, okhttp-eventsource
used SLF4J for logging by default, but could be made to send output to a Logger
interface of its own; the LaunchDarkly Java SDK used only SLF4J, so developers needed to provide an SLF4J configuration externally; and the LaunchDarkly Android SDK used Timber, but still brought in SLF4J as a transitive dependency of okhttp-eventsource
. In this release, the default behavior is still to use SLF4J, but the logging facade can also be configured programmatically to do simple console logging without SLF4J, or to forward output to another framework such as java.util.logging
, or other destinations. In a future major version release, the default behavior will be changed so that okhttp-eventsource
does not require SLF4J as a dependency.
Added:
- An overload of
EventSource.Builder.logger()
that takes acom.launchdarkly.logging.LDLogger
instead of acom.launchdarkly.eventsource.Logger
.
Deprecated:
- The overload of
EventSource.Builder.logger()
that takes acom.launchdarkly.eventsource.Logger
. EventSource.Builder.loggerBaseName()
: this method was only relevant to the default behavior of using SLF4J, providing a way to customize what the logger name would be for SLF4J. But when using the new framework, the logger name is built into theLDLogger
instance. For example (having imported thecom.launchdarkly.logging
package):builder.logger(LDLogger.withAdapter(LDSLF4J.adapter(), "my.desired.logger.name"))
2.6.2
[2.6.2] - 2022-07-27
Changed:
- Updated OkHttp dependency to v4.9.3 to get recent fixes, including a security fix.
2.6.1
[2.6.1] - 2022-06-29
Fixed:
- The 2.5.0 and 2.6.0 releases mistakenly showed
kotlin-stdlib
as a compile-time dependency inpom.xml
. While this library does use the Kotlin runtime (because the underlying OkHttp client uses Kotlin), that is a transitive dependency and is not needed at compile time.