PROTON-2599 Fix additional race causing an intermittent test failures
diff --git a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientTrackable.java b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientTrackable.java
index 6161585..f993271 100644
--- a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientTrackable.java
+++ b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientTrackable.java
@@ -212,14 +212,14 @@
 
     private void processDeliveryUpdated(OutgoingDelivery delivery) {
         if (delivery.isRemotelySettled()) {
-            REMOTELY_SETTLED_UPDATER.lazySet(this, 1);
-            REMOTEL_DELIVERY_STATE_UPDATER.lazySet(this, ClientDeliveryState.fromProtonType(delivery.getRemoteState()));
-
             if (sender.options.autoSettle()) {
                 delivery.settle();
             }
 
             synchronized (this) {
+                REMOTELY_SETTLED_UPDATER.lazySet(this, 1);
+                REMOTEL_DELIVERY_STATE_UPDATER.lazySet(this, ClientDeliveryState.fromProtonType(delivery.getRemoteState()));
+
                 if (remoteSettlementFuture != null) {
                     remoteSettlementFuture.complete(self());
                 }