Skip to content

Commit

Permalink
Fixing handling of last synchronization token
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 13, 2015
1 parent f49647e commit 7a39989
Showing 1 changed file with 5 additions and 12 deletions.
Expand Up @@ -2008,20 +2008,12 @@ public <T extends ShadowType> List<Change<T>> fetchChanges(ObjectClassComplexTy
}
OperationOptions options = optionsBuilder.build();

final SyncToken[] lastReceivedTokenArray = new SyncToken[1];
SyncTokenResultsHandler syncHandler = new SyncTokenResultsHandler() {

SyncResultsHandler syncHandler = new SyncResultsHandler() {
@Override
public boolean handle(SyncDelta delta) {
LOGGER.trace("Detected sync delta: {}", delta);
return syncDeltas.add(delta);
}

@Override
public void handleResult(SyncToken token) {
LOGGER.trace("Detected result token: {}", token);
lastReceivedTokenArray[0] = token;
}
};

OperationResult icfResult = result.createSubresult(ConnectorFacade.class.getName() + ".sync");
Expand All @@ -2030,9 +2022,10 @@ public void handleResult(SyncToken token) {
icfResult.addArbitraryObjectAsParam("syncToken", syncToken);
icfResult.addArbitraryObjectAsParam("syncHandler", syncHandler);

SyncToken lastReceivedToken;
try {
InternalMonitor.recordConnectorOperation("sync");
icfConnectorFacade.sync(icfObjectClass, syncToken, syncHandler,
lastReceivedToken = icfConnectorFacade.sync(icfObjectClass, syncToken, syncHandler,
options);
icfResult.recordSuccess();
icfResult.addReturn(OperationResult.RETURN_COUNT, syncDeltas.size());
Expand Down Expand Up @@ -2064,8 +2057,8 @@ public void handleResult(SyncToken token) {
throw new SchemaException(ex.getMessage(), ex);
}

if (lastReceivedTokenArray[0] != null) {
Change<T> lastChange = new Change((ObjectDelta)null, getToken(lastReceivedTokenArray[0]));
if (lastReceivedToken != null) {
Change<T> lastChange = new Change((ObjectDelta)null, getToken(lastReceivedToken));
LOGGER.trace("Adding last change: {}", lastChange);
changeList.add(lastChange);
}
Expand Down

0 comments on commit 7a39989

Please sign in to comment.