From aff354480289175a4a7481421a8dbbae53e460f7 Mon Sep 17 00:00:00 2001 From: anhefti Date: Mon, 30 Oct 2023 10:47:04 +0100 Subject: [PATCH] SEBSERV-474 fix --- .../dao/impl/ClientConnectionDAOImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java index f7eee0f9..b52089ec 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/ClientConnectionDAOImpl.java @@ -422,13 +422,16 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { public Result saveSecurityCheckStatus(final Long connectionId, final Boolean checkStatus) { return Result.tryCatch(() -> { - // TODO fix update time update (SEBSERV-474) - + // NOTE: we use nanoseconds here to get a better precision to better avoid + // same value of real concurrent calls on distributed systems + final long nanosecondsNow = System.nanoTime(); UpdateDSL.updateWithMapper( this.clientConnectionRecordMapper::update, ClientConnectionRecordDynamicSqlSupport.clientConnectionRecord) .set(ClientConnectionRecordDynamicSqlSupport.securityCheckGranted) .equalTo(Utils.toByte(checkStatus)) + .set(ClientConnectionRecordDynamicSqlSupport.updateTime) + .equalTo(nanosecondsNow) .where(ClientConnectionRecordDynamicSqlSupport.id, isEqualTo(connectionId)) .build() .execute(); @@ -442,13 +445,16 @@ public class ClientConnectionDAOImpl implements ClientConnectionDAO { public Result saveSEBClientVersionCheckStatus(final Long connectionId, final Boolean checkStatus) { return Result.tryCatch(() -> { - // TODO fix update time update (SEBSERV-474) - + // NOTE: we use nanoseconds here to get a better precision to better avoid + // same value of real concurrent calls on distributed systems + final long nanosecondsNow = System.nanoTime(); UpdateDSL.updateWithMapper( this.clientConnectionRecordMapper::update, ClientConnectionRecordDynamicSqlSupport.clientConnectionRecord) .set(ClientConnectionRecordDynamicSqlSupport.clientVersionGranted) .equalTo(Utils.toByte(checkStatus)) + .set(ClientConnectionRecordDynamicSqlSupport.updateTime) + .equalTo(nanosecondsNow) .where(ClientConnectionRecordDynamicSqlSupport.id, isEqualTo(connectionId)) .build() .execute();