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 4.0.1 release #83

Merged
merged 166 commits into from
Jan 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
166 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
65e49b3
merge from public after release
LaunchDarklyCI Jan 22, 2020
7339b66
update Gradle release
eli-darkly Jan 31, 2020
8cabf86
enable Github Pages
eli-darkly Jan 31, 2020
cf995b9
Merge pull request #28 from launchdarkly/eb/ch63665/fix-release
eli-darkly Jan 31, 2020
0644277
skip tests in release
eli-darkly Jan 31, 2020
0814f3d
Merge branch 'public-master'
eli-darkly Jan 31, 2020
0f25a02
merge from public after release
LaunchDarklyCI Jan 31, 2020
9f9513a
merge from public after release
LaunchDarklyCI Jan 31, 2020
4f542e4
add ability to force a stream restart; improve tests so we can test this
eli-darkly Mar 14, 2020
7abb48b
revert whitespace change
eli-darkly Mar 14, 2020
685e03f
Merge branch '1.x' of github.com:launchdarkly/okhttp-eventsource into…
eli-darkly Mar 14, 2020
ce2509d
Merge branch '1.x' into eb/ch69336/restart-plus-tests-2.x
eli-darkly Mar 14, 2020
78fa088
Merge branch 'eb/ch69336/restart-stream-and-tests' into eb/ch69336/re…
eli-darkly Mar 14, 2020
c6d5b46
bump OkHttp version to latest Java 7-compatible version
eli-darkly Mar 20, 2020
2c2ca19
Merge pull request #30 from launchdarkly/eb/ch70366/okhttp-update
eli-darkly Mar 20, 2020
e5c3b3d
merge from public after release
LaunchDarklyCI Mar 20, 2020
bf60873
Merge branch '1.x'
eli-darkly Mar 20, 2020
a7e19ed
Merge branch '1.x' of github.com:launchdarkly/okhttp-eventsource into…
eli-darkly Mar 20, 2020
5c3c554
Merge branch '1.x'
eli-darkly Mar 20, 2020
48b0692
add ability to force a stream restart; improve tests so we can test t…
eli-darkly Mar 26, 2020
f5f6264
Merge branch '1.x' into eb/ch69336/restart-plus-tests-2.x
eli-darkly Mar 27, 2020
d2dad1c
Merge branch 'eb/ch69336/restart-plus-tests-2.x'
eli-darkly Mar 27, 2020
b96e581
merge from public after release
LaunchDarklyCI Mar 30, 2020
3f431f1
Merge branch '1.x' of github.com:launchdarkly/okhttp-eventsource into…
eli-darkly Apr 6, 2020
e5e7a5d
Merge branch '1.x'
eli-darkly Apr 6, 2020
c2a6bb5
update to okhttp 4.5.0
eli-darkly Apr 7, 2020
439b9ff
longer timeout for cleaner shutdown of test servers
eli-darkly Apr 7, 2020
3e72475
Merge pull request #31 from launchdarkly/eb/ch72725/okhttp-update
eli-darkly Apr 7, 2020
91ae82e
fix Gradle scopes
eli-darkly Apr 7, 2020
add38c0
merge from public after release
LaunchDarklyCI Apr 29, 2020
452e8bf
allow setting specific thread priority
eli-darkly May 7, 2020
24ef1ef
Merge pull request #33 from launchdarkly/eb/ch76124/thread-priority
eli-darkly May 8, 2020
42eaef1
remove misleading logging & unnecessary backoff, improve tests (#34)
eli-darkly May 8, 2020
fc45c58
known issue with onClose() - add comment, disable test assertions
eli-darkly May 8, 2020
c905979
Merge pull request #35 from launchdarkly/eb/ch76166/tests-hang-2
eli-darkly May 8, 2020
e0d4e84
merge from public after release
LaunchDarklyCI May 8, 2020
b0161a5
allow caller to specify a custom logger instead of SLF4J (#32)
eli-darkly May 8, 2020
259a866
add method for changing base name of SLF4J logger
eli-darkly May 26, 2020
9a70959
enable coverage reports in CI, improve CI to test all supported Java …
eli-darkly May 26, 2020
6ad34ee
rm inapplicable CI copy-paste
eli-darkly May 26, 2020
bbcee02
another CI fix
eli-darkly May 27, 2020
35b0dda
add checkstyle config
eli-darkly May 27, 2020
ade7f46
Merge pull request #36 from launchdarkly/eb/ch76113/logger-name
eli-darkly May 27, 2020
eb2731f
Merge pull request #37 from launchdarkly/eb/ch77594/coverage
eli-darkly May 27, 2020
ae5e25f
fix jitter calculation when upper bound is a power of 2
eli-darkly May 27, 2020
1cbcf8e
Merge pull request #38 from launchdarkly/eb/ch77825/random-jitter-calc
eli-darkly May 27, 2020
dadea3d
merge from public after release
LaunchDarklyCI May 27, 2020
30da690
Merge branch '1.x'
eli-darkly May 27, 2020
f69d180
misc coverage + test improvements, add CI enforcement of coverage (#39)
eli-darkly Jun 2, 2020
7ef1505
Merge branch 'master' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Jun 2, 2020
d4143ca
fix shutdown state logic, simplify code paths (#40)
eli-darkly Jun 18, 2020
508d49a
merge from public after release
LaunchDarklyCI Jun 18, 2020
0b4709d
Fix Java 7 compatibility.
gwhelanLD Sep 23, 2020
1d95560
Merge pull request #41 from launchdarkly/gw/ch90426/fix-java-7-compat
gwhelanLD Sep 23, 2020
34a7b83
add OpenJDK 7 build + fix test race condition + javadoc fix (#42)
eli-darkly Sep 28, 2020
ed434fc
merge from public after release
LaunchDarklyCI Sep 28, 2020
d988279
Merge branch '1.x'
eli-darkly Sep 28, 2020
1dfc823
update Gradle to 6.8.3
eli-darkly May 6, 2021
4e158f2
Merge pull request #43 from launchdarkly/eb/ch104534/update-gradle
eli-darkly May 6, 2021
77f7378
Kotlinize build script
eli-darkly May 6, 2021
54fa96f
Merge pull request #44 from launchdarkly/eb/ch107687/gradle-kotlin
eli-darkly May 7, 2021
aea06fe
fix logic for shutting down after an unrecoverable error
eli-darkly Jun 24, 2021
989d4e6
Merge pull request #45 from launchdarkly/eb/ch112576/shutdown-on-error
eli-darkly Jun 24, 2021
235c965
merge from public after release
LaunchDarklyCI Jun 24, 2021
2bc9410
use newer HTTP test helpers
eli-darkly Jun 26, 2021
2d180ba
Merge pull request #46 from launchdarkly/eb/ch112118/http-test-helpers
eli-darkly Jun 26, 2021
ab44674
use Releaser v2 config + newer CI images (#47)
eli-darkly Sep 14, 2021
524a43c
use new stream-reading implementation to support CR-only line endings
eli-darkly Dec 31, 2021
28c2dc6
make buffer size configurable
eli-darkly Dec 31, 2021
a781b56
rm usage that's not allowed in Java 8
eli-darkly Dec 31, 2021
e51be5c
add Guava test dependency
eli-darkly Dec 31, 2021
7f23d3b
add code coverage ovverride
eli-darkly Dec 31, 2021
5110814
Merge pull request #49 from launchdarkly/eb/sc-131353/cr
eli-darkly Jan 6, 2022
c8a9888
implement contract tests (#48)
eli-darkly Jan 6, 2022
9a99372
merge from public after release
Jan 6, 2022
595b134
use Gradle 7
eli-darkly Jan 8, 2022
cea3f23
Bounded queues for the EventHandler thread (#58)
thomaslee Jan 10, 2022
97029fc
Merge branch 'contrib' of github.com:launchdarkly/okhttp-eventsource …
eli-darkly Jan 10, 2022
18cf216
update @since
eli-darkly Jan 10, 2022
6f935f7
Merge pull request #50 from launchdarkly/eb/sc-122485/gradle7
eli-darkly Jan 10, 2022
a723ca0
test Java 17 in CI (#51)
eli-darkly Jan 10, 2022
5eb858d
Merge branch 'eb/sc-137152/handler-queue'
eli-darkly Jan 10, 2022
78980a6
improve tests for AsyncEventHandler and EventSource.awaitClosed (#52)
eli-darkly Jan 13, 2022
1d771d7
merge from public after release
Jan 14, 2022
260f62a
add streaming data mode for very large events (#53)
eli-darkly Jun 28, 2022
a51a3cd
add option to ensure that expected fields are always read
eli-darkly Jun 29, 2022
189d3fb
Merge pull request #54 from launchdarkly/eb/sc-157338/streaming-requi…
eli-darkly Jun 29, 2022
58b7e6c
merge from public after release
Jun 29, 2022
f4cc7ba
add Gradle option to suppress kotlin-stdlib in our pom
eli-darkly Jun 29, 2022
d3ce2fa
Merge pull request #55 from launchdarkly/eb/sc-158486/kotlin-dependency
eli-darkly Jun 29, 2022
2714c17
merge from public after release
Jun 29, 2022
c520e4a
update okhttp to 4.9.3
eli-darkly Jul 26, 2022
d0a5c6d
Merge pull request #56 from launchdarkly/eb/sc-161764/okhttp-version
eli-darkly Jul 28, 2022
ccb3a72
merge from public after release
Jul 28, 2022
a7b1851
use LaunchDarkly logging facade
eli-darkly Jul 29, 2022
896cba6
rm unused
eli-darkly Jul 29, 2022
484baa3
misc fixes
eli-darkly Jul 29, 2022
483776b
improve javadoc links
eli-darkly Jul 29, 2022
306a8cd
remove SLF4J dependency, use only com.launchdarkly.logging
eli-darkly Aug 1, 2022
5b129d7
update com.launchdarkly.logging version
eli-darkly Aug 1, 2022
9e62168
consistently use placeholders instead of concatenation in log output
eli-darkly Aug 2, 2022
7d4d793
Merge pull request #57 from launchdarkly/eb/sc-138971/ld-logging
eli-darkly Aug 2, 2022
bce3a6e
merge from public after release
Aug 2, 2022
a01d2e3
update release metadata
eli-darkly Aug 2, 2022
0f987cc
Merge pull request #58 from launchdarkly/eb/sc-138971/ld-logging-only
eli-darkly Aug 2, 2022
ff8e68c
use SecureRandom instead of Random, just to make scanners happier
eli-darkly Aug 23, 2022
40537c0
Merge pull request #60 from launchdarkly/eb/sc-164297/secure-random
eli-darkly Aug 23, 2022
d15b511
use SecureRandom instead of Random, just to make scanners happier
eli-darkly Aug 23, 2022
af63a2d
Merge branch '2.x'
eli-darkly Aug 23, 2022
15e4864
use SecureRandom instead of Random, just to make scanners happier
eli-darkly Aug 23, 2022
e269eb7
Merge branch '1.x' into 2.x
eli-darkly Aug 23, 2022
7d02caa
Merge branch '2.x'
eli-darkly Aug 23, 2022
f442c93
merge from public after release
Aug 23, 2022
4563385
Merge branch '1.x' into 2.x
eli-darkly Aug 23, 2022
344afdb
Merge branch '2.x' of github.com:launchdarkly/okhttp-eventsource into…
eli-darkly Aug 23, 2022
3479aab
Merge branch '2.x'
eli-darkly Aug 23, 2022
631b8cc
merge from public after release
Aug 23, 2022
66e3228
Merge branch '2.x'
eli-darkly Aug 23, 2022
e3626ad
fix release metadata
eli-darkly Sep 28, 2022
b977dd3
remove usage of Duration for Android compatibility
eli-darkly Sep 28, 2022
5f2c209
Merge pull request #63 from launchdarkly/eb/sc-162830/no-duration-in-3.x
eli-darkly Oct 28, 2022
92966b7
merge from public after release
Dec 2, 2022
2c85161
new synchronous EventSource implementation (#64)
eli-darkly Dec 19, 2022
c197765
add async wrapper to emulate old EventSource (#65)
eli-darkly Dec 20, 2022
08593ee
Merge branch 'main' of github.com:launchdarkly/okhttp-eventsource
eli-darkly Dec 20, 2022
3dc7bec
update doc comments regarding thread behavior in Android
eli-darkly Dec 21, 2022
948c0f0
Merge pull request #66 from launchdarkly/eb/sc-91466/android-comment
eli-darkly Dec 21, 2022
0919605
update Gradle to 7.6 + fix snapshot releases
eli-darkly Dec 31, 2022
c9b1e11
Merge pull request #67 from launchdarkly/eb/sc-107787/gradle-update
eli-darkly Jan 3, 2023
09b5e0f
in streaming data mode, throw an exception if stream is closed during…
eli-darkly Jan 10, 2023
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
Prev Previous commit
Next Next commit
implement contract tests (#48)
  • Loading branch information
eli-darkly authored Jan 6, 2022
commit c8a98885d9b74debc8a0bc5e28a5057441892c13
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ jobs:
- attach_workspace:
at: build
- run: java -version
- run: ./gradlew test
- run: make test
- when:
condition: <<parameters.with-coverage>>
steps:
@@ -76,6 +76,13 @@ jobs:
path: ~/junit
- store_artifacts:
path: ~/junit

- run: make build-contract-tests
- run:
command: make start-contract-test-service
background: true
- run: make run-contract-tests

- when:
condition: <<parameters.with-coverage>>
steps:
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -18,12 +18,12 @@ The project builds with [Gradle](https://gradle.org/) and should be built agains

To build the project without running any tests:
```
./gradlew jar
make
```

If you wish to clean your working directory between builds, you can clean it by running:
```
./gradlew clean
make clean
```

If you wish to use your generated SDK artifact by another Maven/Gradle project such as [java-server-sdk](https://github.com/launchdarkly/java-server-sdk), you will likely want to publish the artifact to your local Maven repository so that your other project can access it.
@@ -35,7 +35,12 @@ If you wish to use your generated SDK artifact by another Maven/Gradle project s

To build the project and run all unit tests:
```
./gradlew test
make test
```

To run the standardized contract tests that are run against all LaunchDarkly SSE client implementations:
```
make contract-tests
```

## Note on Java version and Android support
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

build:
./gradlew jar

clean:
./gradlew clean

test:
./gradlew test

TEMP_TEST_OUTPUT=/tmp/sse-contract-test-service.log

build-contract-tests:
@cd contract-tests && ../gradlew installDist

start-contract-test-service:
@contract-tests/service/build/install/service/bin/service

start-contract-test-service-bg:
@echo "Test service output will be captured in $(TEMP_TEST_OUTPUT)"
@make start-contract-test-service >$(TEMP_TEST_OUTPUT) 2>&1 &

run-contract-tests:
@curl -s https://raw.githubusercontent.com/launchdarkly/sse-contract-tests/v2.0.0/downloader/run.sh \
| VERSION=v2 PARAMS="-url http://localhost:8000 -debug -stop-service-at-end" sh

contract-tests: build-contract-tests start-contract-test-service-bg run-contract-tests

.PHONY: build clean test build-contract-tests start-contract-test-service run-contract-tests contract-tests
5 changes: 5 additions & 0 deletions contract-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SSE client contract test service

This directory contains an implementation of the cross-platform SSE testing protocol defined by https://github.com/launchdarkly/sse-contract-tests. See that project's `README` for details of this protocol, and the kinds of SSE client capabilities that are relevant to the contract tests. This code should not need to be updated unless the SSE client has added or removed such capabilities.

To run these tests locally, run `make contract-tests` from the project root directory. This downloads the correct version of the test harness tool automatically.
1 change: 1 addition & 0 deletions contract-tests/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gnsp.disableApplyOnlyOnRootProjectEnforcement=true
38 changes: 38 additions & 0 deletions contract-tests/service/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

plugins {
id "java"
id "application"
}

repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/groups/public/" }
}

allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

archivesBaseName = "okhttp-eventsource-test-service"

application {
mainClassName = "ssetest.TestService"
}

ext.versions = [
"gson": "2.7",
"logback": "1.1.3",
"testHelpers": "1.1.0"
]

configurations {
deps.extendsFrom(implementation)
}

dependencies {
implementation project(":eventsource")
implementation "ch.qos.logback:logback-classic:${versions.logback}"
implementation "com.google.code.gson:gson:${versions.gson}"
implementation "com.launchdarkly:test-helpers:${versions.testHelpers}"
}
Empty file.
42 changes: 42 additions & 0 deletions contract-tests/service/src/main/java/ssetest/Representations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package ssetest;

import java.util.Map;

public abstract class Representations {
public static class Status {
String[] capabilities;
}

public static class StreamOptions {
String streamUrl;
String callbackUrl;
String tag;
Map<String, String> headers;
Integer initialDelayMs;
Integer readTimeoutMs;
String lastEventId;
String method;
String body;
}

public static class Message {
String kind;
EventMessage event;
String comment;
String error;

public Message(String kind) {
this.kind = kind;
}
}

public static class EventMessage {
String type;
String data;
String id;
}

public static class CommandParams {
String command;
}
}
122 changes: 122 additions & 0 deletions contract-tests/service/src/main/java/ssetest/StreamEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package ssetest;

import com.launchdarkly.eventsource.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.URI;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;

import okhttp3.*;
import ssetest.Representations.*;

public class StreamEntity implements EventHandler {
private final TestService owner;
private final String id;
private final EventSource stream;
private final StreamOptions options;
private final AtomicInteger callbackMessageCounter = new AtomicInteger(0);
private final Logger logger;
private volatile boolean closed;

public StreamEntity(TestService owner, String id, StreamOptions options) {
this.owner = owner;
this.id = id;
this.options = options;

this.logger = LoggerFactory.getLogger(options.tag);
logger.info("Opening stream to {}", options.streamUrl);

EventSource.Builder eb = new EventSource.Builder(this, URI.create(options.streamUrl))
.loggerBaseName(options.tag + ".stream");
if (options.headers != null) {
Headers.Builder hb = new Headers.Builder();
for (String name: options.headers.keySet()) {
hb.add(name, options.headers.get(name));
}
eb.headers(hb.build());
}
if (options.initialDelayMs != null) {
eb.reconnectTime(Duration.ofMillis(options.initialDelayMs));
}
if (options.readTimeoutMs != null) {
eb.readTimeout(Duration.ofMillis(options.readTimeoutMs));
}
if (options.lastEventId != null) {
eb.lastEventId(options.lastEventId);
}
if (options.method != null) {
eb.method(options.method);
}
if (options.body != null) {
String contentType = options.headers == null ? null : options.headers.get("content-type");
eb.body(RequestBody.create(options.body,
MediaType.parse(contentType == null ? "text/plain; charset=utf-8" : contentType)));
}
this.stream = eb.build();

this.stream.start();
}

public boolean doCommand(String command) {
logger.info("Test harness sent command: {}", command);
if (command.equals("restart")) {
stream.restart();
return true;
}
return false;
}

public void close() {
closed = true;
stream.close();
owner.forgetStream(id);
logger.info("Test ended");
}

public void onOpen() {}

public void onClosed() {}

public void onMessage(String name, MessageEvent e) {
logger.info("Received event from stream ({})", name);
Message m = new Message("event");
m.event = new EventMessage();
m.event.type = name;
m.event.data = e.getData();
m.event.id = e.getLastEventId();
writeMessage(m);
}

public void onComment(String comment) {
Message m = new Message("comment");
m.comment = comment;
writeMessage(m);
}

public void onError(Throwable t) {
logger.info("Received error from stream: {}", t.toString());
Message m = new Message("error");
m.error = t.toString();
writeMessage(m);
}

private void writeMessage(Message m) {
if (closed) {
return;
}
int counter = callbackMessageCounter.incrementAndGet();
String url = options.callbackUrl + "/" + counter;
String json = owner.gson.toJson(m);
Request request = new Request.Builder().url(url)
.method("POST", RequestBody.create(json, MediaType.get("application/json"))).build();
try {
Response resp = owner.client.newCall(request).execute();
if (resp.code() >= 300) {
logger.error("Callback post to {} returned status {}", url, resp.code());
}
} catch (Exception e) {
logger.error("Callback post to {} failed: {}", url, e.getClass());
}
}
}
Loading