From 98e189c6f0c74403d49a006ec550a99a1cb2cf48 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 30 Sep 2015 17:00:33 +0200 Subject: [PATCH] Remove optimization on updated at As there's no more ES index of file sources, there's no need to modify the updated at date only when binary data are updated --- .../computation/step/PersistFileSourcesStep.java | 16 +++++++--------- .../step/PersistFileSourcesStepTest.java | 3 +-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java index 56757271ef8..824364110a6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistFileSourcesStep.java @@ -21,10 +21,6 @@ package org.sonar.server.computation.step; import com.google.common.collect.ImmutableMap; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; import org.apache.commons.codec.digest.DigestUtils; import org.apache.ibatis.session.ResultContext; import org.apache.ibatis.session.ResultHandler; @@ -52,6 +48,11 @@ import org.sonar.server.computation.source.ScmLineReader; import org.sonar.server.computation.source.SourceLinesRepository; import org.sonar.server.computation.source.SymbolsLineReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + import static org.sonar.server.computation.component.ComponentVisitor.Order.PRE_ORDER; public class PersistFileSourcesStep implements ComputationStep { @@ -156,11 +157,8 @@ public class PersistFileSourcesStep implements ComputationStep { .setBinaryData(data) .setDataHash(dataHash) .setSrcHash(srcHash) - .setLineHashes(lineHashes); - // Optimization only change updated at when updating binary data to avoid unnecessary indexation by E/S - if (binaryDataUpdated) { - previousDto.setUpdatedAt(system2.now()); - } + .setLineHashes(lineHashes) + .setUpdatedAt(system2.now()); dbClient.fileSourceDao().update(previousDto); session.commit(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java index cd1bd5ee884..86195aa39be 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PersistFileSourcesStepTest.java @@ -389,8 +389,7 @@ public class PersistFileSourcesStepTest extends BaseStepTest { assertThat(dbTester.countRowsOfTable("file_sources")).isEqualTo(1); FileSourceDto fileSourceDto = dbClient.fileSourceDao().selectSourceByFileUuid(session, FILE_UUID); assertThat(fileSourceDto.getCreatedAt()).isEqualTo(past); - // Updated at is not updated to not reindex the file source in E/S as the src hash is not indexed - assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(past); + assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(now); assertThat(fileSourceDto.getSrcHash()).isEqualTo("137f72c3708c6bd0de00a0e5a69c699b"); } -- 2.39.5