Skip to content

Commit 0bc023d

Browse files
Add @PreDetroy annotation in services implementing Purgeable (#724)
1 parent 7ece6ee commit 0bc023d

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ All notable changes to this project will be documented in this file.
2222
- Update `contribution` and `contributionAndFinalize` detector tests.
2323
TEE tasks with callback are now eligible to `contributeAndFinalize` flow. (#719)
2424
- Resolve deprecations caused by `TaskDescription` in `ReplicatesService` and `ResultService`. (#723)
25+
- Add missing `@PreDestroy` annotation in services implementing `Purgeable`. (#724)
2526

2627
### Dependency Upgrades
2728

src/main/java/com/iexec/core/chain/IexecHubService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.web3j.protocol.core.methods.request.EthFilter;
3030
import org.web3j.protocol.core.methods.response.TransactionReceipt;
3131

32+
import javax.annotation.PreDestroy;
3233
import java.math.BigInteger;
3334
import java.time.Instant;
3435
import java.util.Date;
@@ -411,12 +412,15 @@ private EthFilter createEthFilter(long fromBlock, long toBlock, Event event) {
411412
// endregion
412413

413414
@Override
414-
public boolean purgeTask(String chainTaskId) {
415+
public boolean purgeTask(final String chainTaskId) {
416+
log.debug("purgeTask [chainTaskId: {}]", chainTaskId);
415417
return super.purgeTask(chainTaskId);
416418
}
417419

418420
@Override
421+
@PreDestroy
419422
public void purgeAllTasksData() {
423+
log.info("Method purgeAllTasksData() called to perform task data cleanup.");
420424
super.purgeAllTasksData();
421425
}
422426
}

src/main/java/com/iexec/core/replicate/ReplicateSupplyService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.retry.annotation.Retryable;
4242
import org.springframework.stereotype.Service;
4343

44+
import javax.annotation.PreDestroy;
4445
import java.util.*;
4546
import java.util.concurrent.locks.Lock;
4647
import java.util.concurrent.locks.ReentrantLock;
@@ -531,13 +532,16 @@ private TaskAbortCause getTaskAbortCause(Task task) {
531532

532533
// region purge locks
533534
@Override
534-
public boolean purgeTask(String chainTaskId) {
535+
public boolean purgeTask(final String chainTaskId) {
536+
log.debug("purgeTask [chainTaskId: {}]", chainTaskId);
535537
taskAccessForNewReplicateLocks.remove(chainTaskId);
536538
return !taskAccessForNewReplicateLocks.containsKey(chainTaskId);
537539
}
538540

539541
@Override
542+
@PreDestroy
540543
public void purgeAllTasksData() {
544+
log.info("Method purgeAllTasksData() called to perform task data cleanup.");
541545
taskAccessForNewReplicateLocks.clear();
542546
}
543547
// endregion

src/test/java/com/iexec/core/task/update/TaskUpdateManagerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ void shouldNotUpgrade2ReopenedSinceCurrentStatusWrong() {
164164
@Test
165165
void shouldNotUpgrade2ReopenedSinceNotAfterRevealDeadline() {
166166
final Task task = getStubTask(CONSENSUS_REACHED);
167-
task.setRevealDeadline(new Date(new Date().getTime() + 100));
167+
task.setRevealDeadline(new Date(new Date().getTime() + 500));
168168
taskRepository.save(task);
169169
when(replicatesService.getNbReplicatesWithCurrentStatus(CHAIN_TASK_ID, ReplicateStatus.REVEALED)).thenReturn(0);
170170

0 commit comments

Comments
 (0)