Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	gradle.properties
  • Loading branch information
eli-darkly committed Apr 6, 2020
2 parents d2dad1c + 3f431f1 commit e5e7a5d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ All notable changes to the LaunchDarkly EventSource implementation for Java will
### Removed:
- In `EventSource`: `setHttpUrl`, `setLastEventId`, `setMaxReconnectTime`, `setReconnectionTime`, `setUri` (these can only be set in the builder).

## [1.11.0] - 2020-03-30
### Added:
- New `EventSource` method `restart()` allows the caller to force a stream connection retry even if no I/O error has happened, using the same backoff behavior that would be used for errors.

## [1.10.2] - 2020-03-20
### Changed:
- Updated OkHttp version to 3.12.10 (the latest version that still supports Java 7).
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id "java-library"
id "signing"
id "maven-publish"
id "de.marcphilipp.nexus-publish" version "0.3.0"
id "de.marcphilipp.nexus-publish" version "0.4.0"
id "io.codearte.nexus-staging" version "0.21.2"
id "org.ajoberstar.git-publish" version "2.1.3"
id "idea"
Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
version=2.0.1
ossrhUsername=
ossrhPassword=

# See https://github.com/gradle/gradle/issues/11308 regarding the following property
systemProp.org.gradle.internal.publish.checksums.insecure=true
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,30 @@ public void canForceEventSourceToRestart() throws Exception {
assertEquals(LogItem.closed(), eventSink.log.take());
}
}

@Test
public void newLastEventIdIsSentOnNextConnectAttempt() throws Exception {
String initialLastId = "123";
String newLastId = "099";
String body = "id: " + newLastId + "\ndata: first\n\n";

TestHandler eventSink = new TestHandler();

StubServer.Handler streamHandler1 = stream(CONTENT_TYPE, streamProducerFromString(body, false));
StubServer.Handler streamHandler2 = stream(CONTENT_TYPE, streamProducerFromString("", true));
StubServer.Handler allRequests = forRequestsInSequence(streamHandler1, streamHandler2);

try (StubServer server = StubServer.start(allRequests)) {
try (EventSource es = new EventSource.Builder(eventSink, server.getUri())
.lastEventId(initialLastId)
.build()) {
es.start();

StubServer.RequestInfo req0 = server.awaitRequest();
StubServer.RequestInfo req1 = server.awaitRequest();
assertEquals(initialLastId, req0.getHeader("Last-Event-ID"));
assertEquals(newLastId, req1.getHeader("Last-Event-ID"));
}
}
}
}

0 comments on commit e5e7a5d

Please sign in to comment.