Skip to content

Commit

Permalink
Change clean resources task to start always (#612)
Browse files Browse the repository at this point in the history
  • Loading branch information
puzpuzpuz authored Sep 25, 2020
1 parent 9c1c2d1 commit c52a41f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/invocation/InvocationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ export class InvocationService {
if (this.backupAckToClientEnabled) {
const listenerService = this.client.getListenerService();
listenerService.registerListener(backupListenerCodec, this.backupEventHandler.bind(this));
this.cleanResourcesTask = this.scheduleCleanResourcesTask(this.cleanResourcesMillis);
}
this.cleanResourcesTask = this.scheduleCleanResourcesTask(this.cleanResourcesMillis);
}

private scheduleCleanResourcesTask(periodMillis: number): Task {
Expand All @@ -306,7 +306,9 @@ export class InvocationService {
this.notifyError(invocation, new TargetDisconnectedError(connection.getClosedReason()));
continue;
}
invocation.detectAndHandleBackupTimeout(this.operationBackupTimeoutMillis);
if (this.backupAckToClientEnabled) {
invocation.detectAndHandleBackupTimeout(this.operationBackupTimeoutMillis);
}
}
}, periodMillis, periodMillis);
}
Expand All @@ -316,7 +318,7 @@ export class InvocationService {
return;
}
this.isShutdown = true;
if (this.cleanResourcesTask != null) {
if (this.cleanResourcesTask !== undefined) {
cancelRepetitionTask(this.cleanResourcesTask);
}
for (const invocation of this.pending.values()) {
Expand Down
8 changes: 4 additions & 4 deletions test/invocation/InvocationServiceTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,27 @@ describe('InvocationServiceTest', function () {
expect(client.getListenerService().registerListener.calledOnce).to.be.true;
});

it('should not start clean resource task and register listener when client is unisocket', function () {
it('should start clean resource task without listener registration when client is unisocket', function () {
const config = new ClientConfigImpl();
config.network.smartRouting = false;
const client = mockClient(config);

service = new InvocationService(client);
service.start();

expect(service.cleanResourcesTask).to.be.undefined;
expect(service.cleanResourcesTask).to.be.not.undefined;
expect(client.getListenerService().registerListener.notCalled).to.be.true;
});

it('should not start clean resource task and register listener when acks are disabled', function () {
it('should start clean resource task without listener registration when acks are disabled', function () {
const config = new ClientConfigImpl();
config.backupAckToClientEnabled = false;
const client = mockClient(config);

service = new InvocationService(client);
service.start();

expect(service.cleanResourcesTask).to.be.undefined;
expect(service.cleanResourcesTask).to.be.not.undefined;
expect(client.getListenerService().registerListener.notCalled).to.be.true;
});

Expand Down

0 comments on commit c52a41f

Please sign in to comment.