michaelandrepearce commented on a change in pull request #2727: ARTEMIS-2394
Improve scheduling sync for AMQPConnectionContext
URL: https://github.com/apache/activemq-artemis/pull/2727#discussion_r303678440
##########
File path:
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPConnectionContext.java
##########
@@ -416,12 +411,15 @@ public void onRemoteOpen(Connection connection) throws
Exception {
* */
if (connection.getRemoteProperties() == null ||
!connection.getRemoteProperties().containsKey(CONNECTION_OPEN_FAILED)) {
long nextKeepAliveTime = handler.tick(true);
- synchronized (schedulingLock) {
- if (nextKeepAliveTime != 0 && scheduledPool != null &&
!isSchedulingCancelled) {
- scheduledFuture = scheduledPool.schedule(new
ScheduleRunnable(), (nextKeepAliveTime -
TimeUnit.NANOSECONDS.toMillis(System.nanoTime())), TimeUnit.MILLISECONDS);
+
+ scheduledFutureRef.getAndUpdate(value -> {
+ if (value != null && nextKeepAliveTime != 0 && scheduledPool !=
null) {
Review comment:
```
if (scheduledPool != null && (connection.getRemoteProperties() == null
|| !connection.getRemoteProperties().containsKey(CONNECTION_OPEN_FAILED))) {
long nextKeepAliveTime = handler.tick(true);
if (nextKeepAliveTime != 0) {
scheduledFutureRef.getAndUpdate(value -> {
if (value != null) {
return scheduledPool.schedule(new ScheduleRunnable(),
(nextKeepAliveTime - TimeUnit.NANOSECONDS.toMillis(System.nanoTime())),
TimeUnit.MILLISECONDS);
}
return value;
});
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services