You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2021/05/15 01:48:59 UTC
[cxf] branch 3.4.x-fixes updated (8798b83 -> 847df19)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a change to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.
from 8798b83 Update Micrometer to 1.5.14
new cc52365 Fixing SseEventSource isOpen() semantics (addressing JAX-RS TCK failures) (#796)
new 847df19 Recording .gitmergeinfo Changes
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.gitmergeinfo | 2 ++
.../cxf/jaxrs/sse/client/SseEventSourceImpl.java | 38 ++++++++++++++++++----
2 files changed, 33 insertions(+), 7 deletions(-)
[cxf] 02/02: Recording .gitmergeinfo Changes
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 847df194f6590e1cc1287f2ee16afe1f0e49d227
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri May 14 21:39:03 2021 -0400
Recording .gitmergeinfo Changes
---
.gitmergeinfo | 2 ++
1 file changed, 2 insertions(+)
diff --git a/.gitmergeinfo b/.gitmergeinfo
index eef2868..5e4a048 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -130,8 +130,10 @@ M d4c2a7e561db2871c41008ffe617f200a9c7e2b4
M d6a299217dd943a3872da9b0afb7f966ab289cc0
M d88202133e39bebdb966b6ccfed57e1ff9d73638
M e0dbc85b5b3383c48fecb97ac11608d7b8c82cc5
+M e31815b50c433a91bac93871bec801c34df2ff57
M e775237e6dcb16b647d102bcbb3908d3e9fce1de
M eb4bab9983a287bf9dc0574d22077cc783bc88ac
M ee1994710cedf7c860e82cd6f34cac63042d8fde
M efc5d35498f582335821cc6a2b750df935295f14
M fb7821164ec6d7fb98dc3f8caea67465db230a14
+M fcafcae2809e728c46164119af2e9976889a65d2
[cxf] 01/02: Fixing SseEventSource isOpen() semantics (addressing
JAX-RS TCK failures) (#796)
Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.4.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit cc5236518131d394a5b00135c3d200427d39f41a
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Fri May 14 21:37:51 2021 -0400
Fixing SseEventSource isOpen() semantics (addressing JAX-RS TCK failures) (#796)
(cherry picked from commit 9b92cf15a13c2cc90f50d8fb9be76fabe533b94a)
---
.../cxf/jaxrs/sse/client/SseEventSourceImpl.java | 38 ++++++++++++++++++----
1 file changed, 31 insertions(+), 7 deletions(-)
diff --git a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/client/SseEventSourceImpl.java b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/client/SseEventSourceImpl.java
index 4e8ede2..c823e3c 100644
--- a/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/client/SseEventSourceImpl.java
+++ b/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/client/SseEventSourceImpl.java
@@ -59,6 +59,7 @@ public class SseEventSourceImpl implements SseEventSource {
private volatile InboundSseEventProcessor processor;
private volatile TimeUnit unit;
private volatile long delay;
+ private volatile boolean open;
private class InboundSseEventListenerDelegate implements InboundSseEventListener {
private String lastEventId;
@@ -163,7 +164,7 @@ public class SseEventSourceImpl implements SseEventSource {
@Override
public void open() {
- if (!state.compareAndSet(SseSourceState.CLOSED, SseSourceState.CONNECTING)) {
+ if (!tryChangeState(SseSourceState.CLOSED, SseSourceState.CONNECTING)) {
throw new IllegalStateException("The SseEventSource is already in " + state.get() + " state");
}
@@ -199,7 +200,7 @@ public class SseEventSourceImpl implements SseEventSource {
final int status = response.getStatus();
if (status == 204) {
LOG.fine("SSE endpoint " + target.getUri() + " returns no data, disconnecting");
- state.set(SseSourceState.CLOSED);
+ changeState(SseSourceState.CLOSED);
response.close();
return;
}
@@ -229,7 +230,7 @@ public class SseEventSourceImpl implements SseEventSource {
processor.run(response);
LOG.fine("SSE event processor has been started ...");
- if (!state.compareAndSet(SseSourceState.CONNECTING, SseSourceState.OPEN)) {
+ if (!tryChangeState(SseSourceState.CONNECTING, SseSourceState.OPEN)) {
throw new IllegalStateException("The SseEventSource is already in " + state.get() + " state");
}
@@ -252,7 +253,7 @@ public class SseEventSourceImpl implements SseEventSource {
@Override
public boolean isOpen() {
- return state.get() == SseSourceState.OPEN;
+ return open;
}
@Override
@@ -261,9 +262,9 @@ public class SseEventSourceImpl implements SseEventSource {
return true;
}
- if (state.compareAndSet(SseSourceState.CONNECTING, SseSourceState.CLOSED)) {
+ if (tryChangeState(SseSourceState.CONNECTING, SseSourceState.CLOSED)) {
LOG.fine("The SseEventSource was not connected, closing anyway");
- } else if (!state.compareAndSet(SseSourceState.OPEN, SseSourceState.CLOSED)) {
+ } else if (!tryChangeState(SseSourceState.OPEN, SseSourceState.CLOSED)) {
throw new IllegalStateException("The SseEventSource is not opened, but in " + state.get() + " state");
}
@@ -299,7 +300,7 @@ public class SseEventSourceImpl implements SseEventSource {
// If the connection was still on connecting state, just try to reconnect
if (state.get() != SseSourceState.CONNECTING) {
LOG.fine("The SseEventSource is still opened, moving it to connecting state");
- if (!state.compareAndSet(SseSourceState.OPEN, SseSourceState.CONNECTING)) {
+ if (!tryChangeState(SseSourceState.OPEN, SseSourceState.CONNECTING)) {
throw new IllegalStateException("The SseEventSource is not opened, but in " + state.get()
+ " state, unable to reconnect");
}
@@ -316,4 +317,27 @@ public class SseEventSourceImpl implements SseEventSource {
LOG.fine("The reconnection attempt to " + target.getUri() + " is scheduled in "
+ tunit.toMillis(tdelay) + "ms");
}
+
+ private void changeState(SseSourceState updated) {
+ state.set(updated);
+ onStateChanged(updated);
+ }
+
+ private boolean tryChangeState(SseSourceState expected, SseSourceState updated) {
+ final boolean result = state.compareAndSet(expected, updated);
+
+ if (result) {
+ onStateChanged(updated);
+ }
+
+ return result;
+ }
+
+ private void onStateChanged(SseSourceState updated) {
+ if (state.get() == SseSourceState.OPEN) {
+ open = true;
+ } else if (state.get() == SseSourceState.CLOSED) {
+ open = false;
+ }
+ }
}