Source:
private Mono<CosmosDBAccount> doDatabaseUpdateCreate() { final CosmosDBAccountImpl self = this; final List<Integer> data = new ArrayList<Integer>(); data.add(0); Mono<DatabaseAccountGetResultsInner> request = null; HasLocations locationParameters = null; if (isInCreateMode()) { final DatabaseAccountCreateUpdateParameters createUpdateParametersInner = this.createUpdateParametersInner(this.inner()); request = this .manager() .inner() .databaseAccounts() .createOrUpdateAsync(resourceGroupName(), name(), createUpdateParametersInner); locationParameters = new CreateUpdateLocationParameters(createUpdateParametersInner); } else { final DatabaseAccountUpdateParameters updateParametersInner = this.updateParametersInner(this.inner()); request = this .manager() .inner() .databaseAccounts() .updateAsync(resourceGroupName(), name(), updateParametersInner); locationParameters = new UpdateLocationParameters(updateParametersInner); } final HasLocations finalLocationParameters = locationParameters; return request .flatMap( new Function<DatabaseAccountGetResultsInner, Mono<? extends CosmosDBAccount>>() { @Override public Mono<? extends CosmosDBAccount> apply(DatabaseAccountGetResultsInner databaseAccountInner) { self.failoverPolicies.clear(); self.hasFailoverPolicyChanges = false; return manager() .databaseAccounts() .getByResourceGroupAsync(resourceGroupName(), name()) .flatMap( databaseAccount -> { if (MAX_DELAY_DUE_TO_MISSING_FAILOVERS > data.get(0) && (databaseAccount.id() == null || databaseAccount.id().length() == 0 || finalLocationParameters.locations().size() > databaseAccount.inner().failoverPolicies().size())) { return Mono.empty(); } if (isAFinalProvisioningState(databaseAccount.inner().provisioningState())) { for (Location location : databaseAccount.readableReplications()) { if (!isAFinalProvisioningState(location.provisioningState())) { return Mono.empty(); } } } else { return Mono.empty(); } self.setInner(databaseAccount.inner()); return Mono.just(databaseAccount); }) .repeatWhenEmpty( longFlux -> longFlux .flatMap( index -> { data.set(0, data.get(0) + 30); return Mono.delay(SdkContext.getLroRetryDuration()); })); } }); }

Target:
private Mono<CosmosDBAccount> doDatabaseUpdateCreate() { final CosmosDBAccountImpl self = this; final List<Integer> data = new ArrayList<Integer>(); data.add(0); Mono<DatabaseAccountGetResultsInner> request = null; HasLocations locationParameters = null; if (isInCreateMode()) { final DatabaseAccountCreateUpdateParameters createUpdateParametersInner = this.createUpdateParametersInner(this.inner()); request = this .manager() .inner() .databaseAccounts() .createOrUpdateAsync(resourceGroupName(), name(), createUpdateParametersInner); locationParameters = new CreateUpdateLocationParameters(createUpdateParametersInner); } else { final DatabaseAccountUpdateParameters updateParametersInner = this.updateParametersInner(this.inner()); request = this .manager() .inner() .databaseAccounts() .updateAsync(resourceGroupName(), name(), updateParametersInner); locationParameters = new UpdateLocationParameters(updateParametersInner); } final HasLocations finalLocationParameters = locationParameters; return request .flatMap( new Function<DatabaseAccountGetResultsInner, Mono<? extends CosmosDBAccount>>() { @Override public Mono<? extends CosmosDBAccount> apply(DatabaseAccountGetResultsInner databaseAccountInner) { self.failoverPolicies.clear(); self.hasFailoverPolicyChanges = false; return manager() .databaseAccounts() .getByResourceGroupAsync(resourceGroupName(), name()) .flatMap( databaseAccount -> { if (MAX_DELAY_DUE_TO_MISSING_FAILOVERS > data.get(0) && (databaseAccount.id() == null || databaseAccount.id().length() == 0 || finalLocationParameters.locations().size() > databaseAccount.inner().failoverPolicies().size())) { return Mono.empty(); } if (isAFinalProvisioningState(databaseAccount.inner().provisioningState())) { for (Location location : databaseAccount.readableReplications()) { if (!isAFinalProvisioningState(location.provisioningState())) { return Mono.empty(); } } } else { return Mono.empty(); } self.setInner(databaseAccount.inner()); return Mono.just(databaseAccount); }) .repeatWhenEmpty( longFlux -> longFlux .flatMap( index -> { data.set(0, data.get(0) + 30); return Mono.delay(SdkContext.getDelayDuration(Duration.ofSeconds(30))); })); } }); }