Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare 2.0.0 release #41

Merged
merged 36 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
26dc142
add time threshold for backoff reset
eli-darkly Dec 11, 2018
881473f
Merge branch 'master' into eb/ch15975/backoff-reset
eli-darkly Dec 11, 2018
ca0865d
allow endpoint to be specified as either URI or HttpUrl
eli-darkly Dec 11, 2018
a35c7e6
add @since
eli-darkly Dec 11, 2018
8e4363b
add interface for customizing requests
eli-darkly Dec 11, 2018
54f11e0
Merge pull request #18 from launchdarkly/eb/ch15975/backoff-reset
eli-darkly Dec 13, 2018
7b104a0
Merge pull request #20 from launchdarkly/eb/ch28150/customize-request
eli-darkly Dec 13, 2018
32f80d8
Merge branch 'master' into eb/ch28144/okhttp-url
eli-darkly Dec 13, 2018
1bd8145
Merge pull request #19 from launchdarkly/eb/ch28144/okhttp-url
eli-darkly Dec 13, 2018
52d1732
javadoc fixes
eli-darkly Dec 13, 2018
e82ee5f
add changelog for past releases
eli-darkly Dec 13, 2018
5917b43
Merge branch 'master' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Dec 13, 2018
d6a189b
remove JSR305
eli-darkly Mar 19, 2019
9674ef7
Merge pull request #21 from launchdarkly/eb/ch34379/annotations
eli-darkly Mar 20, 2019
ef15c12
Merge branch 'master' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Mar 21, 2019
6d498fe
Merge branch 'master' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Aug 1, 2019
890eada
replace SSL-specific config method with general-purpose HTTP config m…
eli-darkly Aug 1, 2019
7ba89f4
make helper method static
eli-darkly Aug 1, 2019
4acfb7e
Merge pull request #22 from launchdarkly/eb/ch44325/http-custom-config
eli-darkly Aug 1, 2019
95e4c37
add end-to-end EventSource tests
eli-darkly Aug 1, 2019
c93f4f0
spacing
eli-darkly Aug 1, 2019
0460bfe
Merge pull request #23 from launchdarkly/eb/ch28292/http-tests
eli-darkly Aug 1, 2019
5cd1b37
Merge branch 'master' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Aug 1, 2019
64a67fc
Merge branch 'master' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Aug 22, 2019
9f05a9a
omit default header value if there's a custom value
eli-darkly Oct 12, 2019
2e5354b
avoid trailing period in logger name
eli-darkly Oct 12, 2019
9f83742
Merge pull request #25 from launchdarkly/eb/ch52604/logger-name
eli-darkly Oct 18, 2019
3dd72a6
Merge pull request #24 from launchdarkly/eb/ch52602/override-header
eli-darkly Oct 18, 2019
b77ea93
merge from public after release
LaunchDarklyCI Oct 18, 2019
9874518
add 1.x branch
eli-darkly Jan 18, 2020
7ada28f
update to OkHttp 4.x and Java 8
eli-darkly Jan 18, 2020
bf2f83c
javadoc fixes
eli-darkly Jan 18, 2020
09d9173
Merge branch 'master' into eb/ch62055/okhttp-4.x
eli-darkly Jan 18, 2020
0c3695e
Merge pull request #26 from launchdarkly/eb/ch62055/okhttp-4.x
eli-darkly Jan 22, 2020
8c9ca57
remove EventSource setters, + test improvements
eli-darkly Jan 22, 2020
0c59325
Merge pull request #27 from launchdarkly/eb/ch62489/remove-setters
eli-darkly Jan 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .ldrelease/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ repo:
public: okhttp-eventsource
private: okhttp-eventsource-private

releasableBranches:
- name: master
description: 2.x - for Java SDK 5.0+
- name: 1.x
description: for Java SDK <5.0

publications:
- url: https://oss.sonatype.org/content/groups/public/com/launchdarkly/okhttp-eventsource/
description: Sonatype
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Project Information
-----------

This library allows Java developers to consume Server Sent Events from a remote API. The server sent events spec is defined here: [https://html.spec.whatwg.org/multipage/server-sent-events.html](https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events)

Starting in version 2.0, this library uses OkHttp 4.x and requires Java 8+. If you need support for OkHttp 3.x or Java 7, use the latest 1.x version.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ repositories {
allprojects {
group = 'com.launchdarkly'
version = "${version}"
sourceCompatibility = 1.7
targetCompatibility = 1.7
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

dependencies {
compile "com.squareup.okhttp3:okhttp:3.8.1"
compile "com.squareup.okhttp3:okhttp:4.3.1"
compile "org.slf4j:slf4j-api:1.7.22"
testRuntime "ch.qos.logback:logback-classic:1.1.9"
testCompile "org.mockito:mockito-core:1.10.19"
testCompile "com.squareup.okhttp3:mockwebserver:3.10.0"
testCompile "com.squareup.okhttp3:mockwebserver:4.3.1"
testCompile "junit:junit:4.11"
}

Expand Down
58 changes: 24 additions & 34 deletions src/main/java/com/launchdarkly/eventsource/AsyncEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,60 +16,50 @@ class AsyncEventHandler implements EventHandler {
}

public void onOpen() {
executor.execute(new Runnable() {
public void run() {
try {
eventSourceHandler.onOpen();
} catch (Exception e) {
onError(e);
}
executor.execute(() -> {
try {
eventSourceHandler.onOpen();
} catch (Exception e) {
onError(e);
}
});
}

public void onClosed() {
executor.execute(new Runnable() {
public void run() {
try {
eventSourceHandler.onClosed();
} catch (Exception e) {
onError(e);
}
executor.execute(() -> {
try {
eventSourceHandler.onClosed();
} catch (Exception e) {
onError(e);
}
});
}

public void onComment(final String comment) {
executor.execute(new Runnable() {
public void run() {
try {
eventSourceHandler.onComment(comment);
} catch (Exception e) {
onError(e);
}
executor.execute(() -> {
try {
eventSourceHandler.onComment(comment);
} catch (Exception e) {
onError(e);
}
});
}

public void onMessage(final String event, final MessageEvent messageEvent) {
executor.execute(new Runnable() {
public void run() {
try {
eventSourceHandler.onMessage(event, messageEvent);
} catch (Exception e) {
onError(e);
}
executor.execute(() -> {
try {
eventSourceHandler.onMessage(event, messageEvent);
} catch (Exception e) {
onError(e);
}
});
}

public void onError(final Throwable error) {
executor.execute(new Runnable() {
public void run() {
try {
eventSourceHandler.onError(error);
} catch (Throwable ignored) {
}
executor.execute(() -> {
try {
eventSourceHandler.onError(error);
} catch (Throwable ignored) {
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.launchdarkly.eventsource;

import java.time.Duration;

interface ConnectionHandler {
void setReconnectionTimeMs(long reconnectionTimeMs);
void setReconnectionTime(Duration reconnectionTime);
void setLastEventId(String lastEventId);
}
3 changes: 2 additions & 1 deletion src/main/java/com/launchdarkly/eventsource/EventParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.slf4j.LoggerFactory;

import java.net.URI;
import java.time.Duration;
import java.util.regex.Pattern;

/**
Expand Down Expand Up @@ -74,7 +75,7 @@ private void processField(String field, String value) {
} else if (EVENT.equals(field)) {
eventName = value;
} else if (RETRY.equals(field) && isNumber(value)) {
connectionHandler.setReconnectionTimeMs(Long.parseLong(value));
connectionHandler.setReconnectionTime(Duration.ofMillis(Long.parseLong(value)));
}
}

Expand Down
Loading