diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2022-03-17 14:59:15 -0500 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2022-03-18 20:02:58 +0000 |
commit | 7aa77dfb2275f38de07c9d3b936e0eea43ac96af (patch) | |
tree | 0ff992bdb11f30f395243e86e1d3039847dd8231 | |
parent | eb34454afc19f4994ae587b43ff2d0c79978de23 (diff) | |
download | sonarqube-7aa77dfb2275f38de07c9d3b936e0eea43ac96af.tar.gz sonarqube-7aa77dfb2275f38de07c9d3b936e0eea43ac96af.zip |
SONAR-16097 Apply feedback
39 files changed, 104 insertions, 111 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReader.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReader.java index 2ef9211860c..f3d368c183f 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReader.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReader.java @@ -29,7 +29,7 @@ public interface BatchReportReader { ScannerReport.Metadata readMetadata(); @CheckForNull - InputStream getPluginCache(); + InputStream getAnalysisCache(); CloseableIterator<String> readScannerLogs(); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderImpl.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderImpl.java index 2e8018aaf57..98faaef0932 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderImpl.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderImpl.java @@ -64,9 +64,9 @@ public class BatchReportReaderImpl implements BatchReportReader { @CheckForNull @Override - public InputStream getPluginCache() { + public InputStream getAnalysisCache() { ensureInitialized(); - return delegate.getPluginCache(); + return delegate.getAnalysisCache(); } @Override diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistPluginCacheStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStep.java index b135a6640fb..278c8b2e027 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistPluginCacheStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStep.java @@ -28,13 +28,13 @@ import org.sonar.ce.task.projectanalysis.component.TreeRootHolder; import org.sonar.ce.task.step.ComputationStep; import org.sonar.db.DbClient; -public class PersistPluginCacheStep implements ComputationStep { - private static final Logger LOGGER = Loggers.get(PersistPluginCacheStep.class); +public class PersistScannerAnalysisCacheStep implements ComputationStep { + private static final Logger LOGGER = Loggers.get(PersistScannerAnalysisCacheStep.class); private final BatchReportReader reportReader; private final DbClient dbClient; private final TreeRootHolder treeRootHolder; - public PersistPluginCacheStep(BatchReportReader reportReader, DbClient dbClient, TreeRootHolder treeRootHolder) { + public PersistScannerAnalysisCacheStep(BatchReportReader reportReader, DbClient dbClient, TreeRootHolder treeRootHolder) { this.reportReader = reportReader; this.dbClient = dbClient; this.treeRootHolder = treeRootHolder; @@ -42,18 +42,18 @@ public class PersistPluginCacheStep implements ComputationStep { @Override public String getDescription() { - return "Persist scanner plugin cache"; + return "Persist scanner analysis cache"; } @Override public void execute(ComputationStep.Context context) { - InputStream pluginCacheStream = reportReader.getPluginCache(); - if (pluginCacheStream != null) { - try (var dataStream = pluginCacheStream; + InputStream scannerAnalysisCacheStream = reportReader.getAnalysisCache(); + if (scannerAnalysisCacheStream != null) { + try (var dataStream = scannerAnalysisCacheStream; var dbSession = dbClient.openSession(false)) { String branchUuid = treeRootHolder.getRoot().getUuid(); - dbClient.scannerCacheDao().remove(dbSession, branchUuid); - dbClient.scannerCacheDao().insert(dbSession, branchUuid, dataStream); + dbClient.scannerAnalysisCacheDao().remove(dbSession, branchUuid); + dbClient.scannerAnalysisCacheDao().insert(dbSession, branchUuid, dataStream); dbSession.commit(); } catch (IOException e) { LOGGER.error("Error in reading plugin cache", e); diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java index 87d442e5d17..1d6137f5dbd 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/step/ReportComputationSteps.java @@ -48,7 +48,7 @@ public class ReportComputationSteps extends AbstractComputationSteps { BuildComponentTreeStep.class, ValidateProjectStep.class, - PersistPluginCacheStep.class, + PersistScannerAnalysisCacheStep.class, LoadQualityProfilesStep.class, // load project related stuffs diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderRule.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderRule.java index 45caf73d932..158a58f6879 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderRule.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/batch/BatchReportReaderRule.java @@ -59,7 +59,7 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { private Map<Integer, List<ScannerReport.LineSgnificantCode>> significantCode = new HashMap<>(); private Map<Integer, ScannerReport.ChangedLines> changedLines = new HashMap<>(); private List<ScannerReport.AnalysisWarning> analysisWarnings = Collections.emptyList(); - private byte[] pluginCache; + private byte[] analysisCache; @Override public Statement apply(final Statement statement, Description description) { @@ -111,15 +111,15 @@ public class BatchReportReaderRule implements TestRule, BatchReportReader { @CheckForNull @Override - public InputStream getPluginCache() { - if (pluginCache == null) { + public InputStream getAnalysisCache() { + if (analysisCache == null) { return null; } - return new ByteArrayInputStream(pluginCache); + return new ByteArrayInputStream(analysisCache); } - public void setPluginCache(byte[] cache) { - this.pluginCache = cache; + public void setAnalysisCache(byte[] cache) { + this.analysisCache = cache; } public BatchReportReaderRule setMetadata(ScannerReport.Metadata metadata) { diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistPluginCacheStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStepTest.java index c9f79e20edd..696b79d0dbf 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistPluginCacheStepTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PersistScannerAnalysisCacheStepTest.java @@ -37,33 +37,33 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class PersistPluginCacheStepTest { +public class PersistScannerAnalysisCacheStepTest { @Rule public BatchReportReaderRule reader = new BatchReportReaderRule(); @Rule public DbTester dbTester = DbTester.create(); private final DbClient client = dbTester.getDbClient(); private final TreeRootHolderRule treeRootHolder = new TreeRootHolderRule(); - private final PersistPluginCacheStep step = new PersistPluginCacheStep(reader, dbTester.getDbClient(), treeRootHolder); + private final PersistScannerAnalysisCacheStep step = new PersistScannerAnalysisCacheStep(reader, dbTester.getDbClient(), treeRootHolder); @Test public void inserts_cache() throws IOException { - reader.setPluginCache("test".getBytes(UTF_8)); + reader.setAnalysisCache("test".getBytes(UTF_8)); Component root = mock(Component.class); when(root.getUuid()).thenReturn("branch"); treeRootHolder.setRoot(root); step.execute(mock(ComputationStep.Context.class)); - assertThat(dbTester.countRowsOfTable("scanner_cache")).isOne(); - try (DbInputStream data = client.scannerCacheDao().selectData(dbTester.getSession(), "branch")) { + assertThat(dbTester.countRowsOfTable("scanner_analysis_cache")).isOne(); + try (DbInputStream data = client.scannerAnalysisCacheDao().selectData(dbTester.getSession(), "branch")) { assertThat(IOUtils.toString(data, UTF_8)).isEqualTo("test"); } } @Test public void updates_cache() throws IOException { - client.scannerCacheDao().insert(dbTester.getSession(), "branch", new ByteArrayInputStream("test".getBytes(UTF_8))); + client.scannerAnalysisCacheDao().insert(dbTester.getSession(), "branch", new ByteArrayInputStream("test".getBytes(UTF_8))); inserts_cache(); } } diff --git a/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java b/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java index 413dc25ac6a..bbbcea0c722 100644 --- a/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java +++ b/server/sonar-db-core/src/main/java/org/sonar/db/version/SqTables.java @@ -94,7 +94,7 @@ public final class SqTables { "rules_parameters", "rules_profiles", "rule_repositories", - "scanner_cache", + "scanner_analysis_cache", "schema_migrations", "session_tokens", "snapshots", diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java index 4649066af46..514b8396379 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java @@ -77,7 +77,7 @@ import org.sonar.db.qualityprofile.QualityProfileDao; import org.sonar.db.qualityprofile.QualityProfileExportDao; import org.sonar.db.rule.RuleDao; import org.sonar.db.rule.RuleRepositoryDao; -import org.sonar.db.scannercache.ScannerCacheDao; +import org.sonar.db.scannercache.ScannerAnalysisCacheDao; import org.sonar.db.schemamigration.SchemaMigrationDao; import org.sonar.db.source.FileSourceDao; import org.sonar.db.user.GroupDao; @@ -157,7 +157,7 @@ public class DaoModule extends Module { RuleDao.class, RuleRepositoryDao.class, SamlMessageIdDao.class, - ScannerCacheDao.class, + ScannerAnalysisCacheDao.class, SnapshotDao.class, SchemaMigrationDao.class, SessionTokensDao.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java index 2268ea41b53..d4738c368d1 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DbClient.java @@ -77,7 +77,7 @@ import org.sonar.db.qualityprofile.QualityProfileDao; import org.sonar.db.qualityprofile.QualityProfileExportDao; import org.sonar.db.rule.RuleDao; import org.sonar.db.rule.RuleRepositoryDao; -import org.sonar.db.scannercache.ScannerCacheDao; +import org.sonar.db.scannercache.ScannerAnalysisCacheDao; import org.sonar.db.schemamigration.SchemaMigrationDao; import org.sonar.db.source.FileSourceDao; import org.sonar.db.user.GroupDao; @@ -169,7 +169,7 @@ public class DbClient { private final UserDismissedMessagesDao userDismissedMessagesDao; private final ApplicationProjectsDao applicationProjectsDao; private final ProjectBadgeTokenDao projectBadgeTokenDao; - private final ScannerCacheDao scannerCacheDao; + private final ScannerAnalysisCacheDao scannerAnalysisCacheDao; public DbClient(Database database, MyBatis myBatis, DBSessions dbSessions, Dao... daos) { this.database = database; @@ -250,7 +250,7 @@ public class DbClient { samlMessageIdDao = getDao(map, SamlMessageIdDao.class); userDismissedMessagesDao = getDao(map, UserDismissedMessagesDao.class); applicationProjectsDao = getDao(map, ApplicationProjectsDao.class); - scannerCacheDao = getDao(map, ScannerCacheDao.class); + scannerAnalysisCacheDao = getDao(map, ScannerAnalysisCacheDao.class); } public DbSession openSession(boolean batch) { @@ -551,7 +551,7 @@ public class DbClient { return projectBadgeTokenDao; } - public ScannerCacheDao scannerCacheDao() { - return scannerCacheDao; + public ScannerAnalysisCacheDao scannerAnalysisCacheDao() { + return scannerAnalysisCacheDao; } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java index 6792608657e..05264bc1b8f 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/MyBatis.java @@ -33,7 +33,6 @@ import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.session.TransactionIsolationLevel; -import org.sonar.api.Startable; import org.sonar.db.alm.pat.AlmPatMapper; import org.sonar.db.alm.setting.AlmSettingMapper; import org.sonar.db.alm.setting.ProjectAlmSettingMapper; @@ -136,7 +135,7 @@ import org.sonar.db.rule.RuleDto; import org.sonar.db.rule.RuleMapper; import org.sonar.db.rule.RuleParamDto; import org.sonar.db.rule.RuleRepositoryMapper; -import org.sonar.db.scannercache.ScannerCacheMapper; +import org.sonar.db.scannercache.ScannerAnalysisCacheMapper; import org.sonar.db.schemamigration.SchemaMigrationDto; import org.sonar.db.schemamigration.SchemaMigrationMapper; import org.sonar.db.source.FileSourceMapper; @@ -300,7 +299,7 @@ public class MyBatis { RuleMapper.class, RuleRepositoryMapper.class, SamlMessageIdMapper.class, - ScannerCacheMapper.class, + ScannerAnalysisCacheMapper.class, SchemaMigrationMapper.class, SessionTokenMapper.class, SnapshotMapper.class, diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java index c5d24de7b82..2b4255ef3e0 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeCommands.java @@ -486,8 +486,8 @@ class PurgeCommands { } public void deleteScannerCache(String rootUuid) { - profiler.start("deleteScannerCache (scanner_cache)"); - purgeMapper.deleteScannerCacheByBranchUuid(rootUuid); + profiler.start("deleteScannerCache (scanner_analysis_cache)"); + purgeMapper.deleteScannerAnalysisCacheByBranchUuid(rootUuid); session.commit(); profiler.stop(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java index ddbe7b627df..cd3f294fcc6 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -175,5 +175,5 @@ public interface PurgeMapper { void deleteUserDismissedMessagesByProjectUuid(@Param("projectUuid") String projectUuid); - void deleteScannerCacheByBranchUuid(@Param("branchUuid") String branchUuid); + void deleteScannerAnalysisCacheByBranchUuid(@Param("branchUuid") String branchUuid); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerCacheDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerAnalysisCacheDao.java index 717180948d9..4e95c6a946d 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerCacheDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerAnalysisCacheDao.java @@ -30,7 +30,7 @@ import org.sonar.db.DbInputStream; import org.sonar.db.DatabaseUtils; import org.sonar.db.DbSession; -public class ScannerCacheDao implements Dao { +public class ScannerAnalysisCacheDao implements Dao { public void removeAll(DbSession session) { mapper(session).removeAll(); } @@ -42,7 +42,7 @@ public class ScannerCacheDao implements Dao { public void insert(DbSession dbSession, String branchUuid, InputStream data) { Connection connection = dbSession.getConnection(); try (PreparedStatement stmt = connection.prepareStatement( - "INSERT INTO scanner_cache (branch_uuid, data) VALUES (?, ?)")) { + "INSERT INTO scanner_analysis_cache (branch_uuid, data) VALUES (?, ?)")) { stmt.setString(1, branchUuid); stmt.setBinaryStream(2, data); stmt.executeUpdate(); @@ -58,7 +58,7 @@ public class ScannerCacheDao implements Dao { ResultSet rs = null; DbInputStream result = null; try { - stmt = dbSession.getConnection().prepareStatement("SELECT data FROM scanner_cache WHERE branch_uuid=?"); + stmt = dbSession.getConnection().prepareStatement("SELECT data FROM scanner_analysis_cache WHERE branch_uuid=?"); stmt.setString(1, branchUuid); rs = stmt.executeQuery(); if (rs.next()) { @@ -76,7 +76,7 @@ public class ScannerCacheDao implements Dao { } } - private static ScannerCacheMapper mapper(DbSession session) { - return session.getMapper(ScannerCacheMapper.class); + private static ScannerAnalysisCacheMapper mapper(DbSession session) { + return session.getMapper(ScannerAnalysisCacheMapper.class); } } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerCacheMapper.java b/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerAnalysisCacheMapper.java index 200d5eb1a38..bd0800e66f8 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerCacheMapper.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/scannercache/ScannerAnalysisCacheMapper.java @@ -21,7 +21,7 @@ package org.sonar.db.scannercache; import org.apache.ibatis.annotations.Param; -public interface ScannerCacheMapper { +public interface ScannerAnalysisCacheMapper { void removeAll(); void remove(@Param("branchUuid") String branchUuid); diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml index 738bf2e737d..20df7611c2b 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/purge/PurgeMapper.xml @@ -593,8 +593,8 @@ delete from user_dismissed_messages where project_uuid = #{projectUuid,jdbcType=VARCHAR} </delete> - <delete id="deleteScannerCacheByBranchUuid"> - delete from scanner_cache where branch_uuid = #{branchUuid,jdbcType=VARCHAR} + <delete id="deleteScannerAnalysisCacheByBranchUuid"> + delete from scanner_analysis_cache where branch_uuid = #{branchUuid,jdbcType=VARCHAR} </delete> </mapper> diff --git a/server/sonar-db-dao/src/main/resources/org/sonar/db/scannercache/ScannerCacheMapper.xml b/server/sonar-db-dao/src/main/resources/org/sonar/db/scannercache/ScannerAnalysisCacheMapper.xml index 887f694c8c0..bd135d11ddb 100644 --- a/server/sonar-db-dao/src/main/resources/org/sonar/db/scannercache/ScannerCacheMapper.xml +++ b/server/sonar-db-dao/src/main/resources/org/sonar/db/scannercache/ScannerAnalysisCacheMapper.xml @@ -2,13 +2,13 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd"> -<mapper namespace="org.sonar.db.scannercache.ScannerCacheMapper"> +<mapper namespace="org.sonar.db.scannercache.ScannerAnalysisCacheMapper"> <delete id="removeAll"> - delete from scanner_cache + delete from scanner_analysis_cache </delete> <delete id="remove"> - delete from scanner_cache where branch_uuid = #{branchUuid,jdbcType=VARCHAR} + delete from scanner_analysis_cache where branch_uuid = #{branchUuid,jdbcType=VARCHAR} </delete> </mapper> diff --git a/server/sonar-db-dao/src/schema/schema-sq.ddl b/server/sonar-db-dao/src/schema/schema-sq.ddl index 1e5bdad6f2c..acb80785e6c 100644 --- a/server/sonar-db-dao/src/schema/schema-sq.ddl +++ b/server/sonar-db-dao/src/schema/schema-sq.ddl @@ -896,11 +896,11 @@ CREATE TABLE "SAML_MESSAGE_IDS"( ALTER TABLE "SAML_MESSAGE_IDS" ADD CONSTRAINT "PK_SAML_MESSAGE_IDS" PRIMARY KEY("UUID"); CREATE UNIQUE INDEX "SAML_MESSAGE_IDS_UNIQUE" ON "SAML_MESSAGE_IDS"("MESSAGE_ID" NULLS FIRST); -CREATE TABLE "SCANNER_CACHE"( +CREATE TABLE "SCANNER_ANALYSIS_CACHE"( "BRANCH_UUID" CHARACTER VARYING(40) NOT NULL, "DATA" BINARY LARGE OBJECT NOT NULL ); -ALTER TABLE "SCANNER_CACHE" ADD CONSTRAINT "PK_SCANNER_CACHE" PRIMARY KEY("BRANCH_UUID"); +ALTER TABLE "SCANNER_ANALYSIS_CACHE" ADD CONSTRAINT "PK_SCANNER_ANALYSIS_CACHE" PRIMARY KEY("BRANCH_UUID"); CREATE TABLE "SESSION_TOKENS"( "UUID" CHARACTER VARYING(40) NOT NULL, diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/scannercache/ScannerCacheDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/scannercache/ScannerAnalysisCacheDaoTest.java index c453021c042..7e0616281c2 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/scannercache/ScannerCacheDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/scannercache/ScannerAnalysisCacheDaoTest.java @@ -39,18 +39,18 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class ScannerCacheDaoTest { +public class ScannerAnalysisCacheDaoTest { @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); private final DbSession dbSession = dbTester.getSession(); - private final ScannerCacheDao underTest = dbTester.getDbClient().scannerCacheDao(); + private final ScannerAnalysisCacheDao underTest = dbTester.getDbClient().scannerAnalysisCacheDao(); @Test public void insert_should_insert_in_db() throws IOException { underTest.insert(dbSession, "branch1", stringToInputStream("test data")); dbSession.commit(); - assertThat(dbTester.countRowsOfTable("scanner_cache")).isOne(); + assertThat(dbTester.countRowsOfTable("scanner_analysis_cache")).isOne(); assertThat(dataStreamToString(underTest.selectData(dbSession, "branch1"))).isEqualTo("test data"); } @@ -65,10 +65,10 @@ public class ScannerCacheDaoTest { underTest.insert(dbSession, "branch1", stringToInputStream("test data")); underTest.insert(dbSession, "branch2", stringToInputStream("test data")); - assertThat(dbTester.countRowsOfTable("scanner_cache")).isEqualTo(2); + assertThat(dbTester.countRowsOfTable("scanner_analysis_cache")).isEqualTo(2); underTest.removeAll(dbSession); dbSession.commit(); - assertThat(dbTester.countRowsOfTable("scanner_cache")).isZero(); + assertThat(dbTester.countRowsOfTable("scanner_analysis_cache")).isZero(); } @Test diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerCacheTable.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerAnalysisCacheTable.java index 12dc8d2179b..715e4a7bed9 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerCacheTable.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerAnalysisCacheTable.java @@ -28,10 +28,10 @@ import static org.sonar.server.platform.db.migration.def.BlobColumnDef.newBlobCo import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE; import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.newVarcharColumnDefBuilder; -public class CreateScannerCacheTable extends CreateTableChange { +public class CreateScannerAnalysisCacheTable extends CreateTableChange { - public CreateScannerCacheTable(Database db) { - super(db, "scanner_cache"); + public CreateScannerAnalysisCacheTable(Database db) { + super(db, "scanner_analysis_cache"); } @Override diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java index 95cfbb8e30c..84a055a79c7 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/version/v94/DbVersion94.java @@ -29,7 +29,7 @@ public class DbVersion94 implements DbVersion { .add(6301, "Drop unused Issues Column REPORTER", DropReporterIssueColumn.class) .add(6302, "Drop unused Issues Column ACTION_PLAN_KEY", DropActionPlanKeyIssueColumn.class) .add(6303, "Drop unused Issues Column ISSUE_ATTRIBUTES", DropIssuesAttributesIssueColumn.class) - .add(6304, "Create table 'SCANNER_CACHE", CreateScannerCacheTable.class) + .add(6304, "Create table 'SCANNER_ANALYSIS_CACHE", CreateScannerAnalysisCacheTable.class) ; } } diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerCacheTableTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerAnalysisCacheTableTest.java index 393ee250bab..12aaa1228e8 100644 --- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerCacheTableTest.java +++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v94/CreateScannerAnalysisCacheTableTest.java @@ -24,13 +24,13 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.db.CoreDbTester; -public class CreateScannerCacheTableTest { - private static final String TABLE_NAME = "scanner_cache"; +public class CreateScannerAnalysisCacheTableTest { + private static final String TABLE_NAME = "scanner_analysis_cache"; @Rule public final CoreDbTester db = CoreDbTester.createEmpty(); - private final CreateScannerCacheTable underTest = new CreateScannerCacheTable(db.database()); + private final CreateScannerAnalysisCacheTable underTest = new CreateScannerAnalysisCacheTable(db.database()); @Test public void migration_should_create_table() throws SQLException { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ScannerCache.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ScannerCache.java index dc59028dffa..e38f4600b85 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ScannerCache.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ScannerCache.java @@ -24,14 +24,14 @@ import org.sonar.api.server.ServerSide; import org.sonar.db.DbClient; import org.sonar.db.DbInputStream; import org.sonar.db.DbSession; -import org.sonar.db.scannercache.ScannerCacheDao; +import org.sonar.db.scannercache.ScannerAnalysisCacheDao; @ServerSide public class ScannerCache { private final DbClient dbClient; - private final ScannerCacheDao dao; + private final ScannerAnalysisCacheDao dao; - public ScannerCache(DbClient dbClient, ScannerCacheDao dao) { + public ScannerCache(DbClient dbClient, ScannerAnalysisCacheDao dao) { this.dbClient = dbClient; this.dao = dao; } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ScannerCacheWs.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/AnalysisCacheWs.java index d69e26bfcc4..9e28490ef23 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ScannerCacheWs.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/AnalysisCacheWs.java @@ -21,22 +21,22 @@ package org.sonar.server.scannercache.ws; import org.sonar.api.server.ws.WebService; -public class ScannerCacheWs implements WebService { +public class AnalysisCacheWs implements WebService { - private final ScannerCacheWsAction[] actions; + private final AnalysisCacheWsAction[] actions; - public ScannerCacheWs(ScannerCacheWsAction... actions) { + public AnalysisCacheWs(AnalysisCacheWsAction... actions) { this.actions = actions; } @Override public void define(Context context) { NewController controller = context - .createController("api/scanner_cache") + .createController("api/analysis_cache") .setSince("9.4") - .setDescription("Access the scanner cache"); + .setDescription("Access the analysis cache"); - for (ScannerCacheWsAction action : actions) { + for (AnalysisCacheWsAction action : actions) { action.define(controller); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ScannerCacheWsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/AnalysisCacheWsAction.java index 0da2162a7c9..6976a96ebb7 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ScannerCacheWsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/AnalysisCacheWsAction.java @@ -25,6 +25,6 @@ import org.sonar.server.ws.WsAction; * Marker interface for coding rule related actions * */ -interface ScannerCacheWsAction extends WsAction { +interface AnalysisCacheWsAction extends WsAction { // Marker interface } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ScannerCacheWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/AnalysisCacheWsModule.java index f3d14e98a5a..0c7751a0085 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ScannerCacheWsModule.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/AnalysisCacheWsModule.java @@ -21,11 +21,11 @@ package org.sonar.server.scannercache.ws; import org.sonar.core.platform.Module; -public class ScannerCacheWsModule extends Module { +public class AnalysisCacheWsModule extends Module { @Override protected void configureModule() { add( - ScannerCacheWs.class, + AnalysisCacheWs.class, GetAction.class, ClearAction.class ); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ClearAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ClearAction.java index 44794a1cf7c..79fbd3bb182 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ClearAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/ClearAction.java @@ -28,7 +28,7 @@ import org.sonar.server.user.UserSession; import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException; -public class ClearAction implements ScannerCacheWsAction { +public class ClearAction implements AnalysisCacheWsAction { private final UserSession userSession; private final ScannerCache cache; diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/GetAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/GetAction.java index 5db206245a8..ba95c5e6393 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/GetAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/scannercache/ws/GetAction.java @@ -42,7 +42,7 @@ import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesEx import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; -public class GetAction implements ScannerCacheWsAction { +public class GetAction implements AnalysisCacheWsAction { private static final String PROJECT = "project"; private static final String BRANCH = "branch"; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ScannerCacheWsModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/AnalysisCacheWsModuleTest.java index f17381e8876..f1d1b58e547 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ScannerCacheWsModuleTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/AnalysisCacheWsModuleTest.java @@ -24,11 +24,11 @@ import org.sonar.core.platform.ListContainer; import static org.assertj.core.api.Assertions.assertThat; -public class ScannerCacheWsModuleTest { +public class AnalysisCacheWsModuleTest { @Test public void verify_count_of_added_components() { ListContainer container = new ListContainer(); - new ScannerCacheWsModule().configure(container); + new AnalysisCacheWsModule().configure(container); assertThat(container.getAddedObjects()).hasSize(3); } diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ScannerCacheWsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/AnalysisCacheWsTest.java index e48b4e5321a..6b2b8505d10 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ScannerCacheWsTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/AnalysisCacheWsTest.java @@ -26,23 +26,23 @@ import org.sonar.api.server.ws.WebService; import static org.assertj.core.api.Assertions.assertThat; -public class ScannerCacheWsTest { +public class AnalysisCacheWsTest { @Test public void define_ws() { - ScannerCacheWsAction action = new FakeAction(); - ScannerCacheWs underTest = new ScannerCacheWs(action); + AnalysisCacheWsAction action = new FakeAction(); + AnalysisCacheWs underTest = new AnalysisCacheWs(action); WebService.Context context = new WebService.Context(); underTest.define(context); - WebService.Controller controller = context.controller("api/scanner_cache"); + WebService.Controller controller = context.controller("api/analysis_cache"); assertThat(controller).isNotNull(); assertThat(controller.since()).isEqualTo("9.4"); assertThat(controller.description()).isNotEmpty(); assertThat(controller.actions()).hasSize(1); } - private static class FakeAction implements ScannerCacheWsAction { + private static class FakeAction implements AnalysisCacheWsAction { @Override public void define(WebService.NewController newController) { newController.createAction("fake").setHandler(this); diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ClearActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ClearActionTest.java index 5bd61e4aafe..50c9c544926 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ClearActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/ClearActionTest.java @@ -31,7 +31,7 @@ import org.sonar.db.DbInputStream; import org.sonar.db.DbTester; import org.sonar.db.permission.GlobalPermission; import org.sonar.db.project.ProjectDto; -import org.sonar.db.scannercache.ScannerCacheDao; +import org.sonar.db.scannercache.ScannerAnalysisCacheDao; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.scannercache.ScannerCache; import org.sonar.server.tester.UserSessionRule; @@ -49,7 +49,7 @@ public class ClearActionTest { @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); - private final ScannerCacheDao dao = new ScannerCacheDao(); + private final ScannerAnalysisCacheDao dao = new ScannerAnalysisCacheDao(); private final ScannerCache cache = new ScannerCache(dbTester.getDbClient(), dao); private final ClearAction ws = new ClearAction(userSession, cache); private final WsActionTester wsTester = new WsActionTester(ws); @@ -67,7 +67,7 @@ public class ClearActionTest { TestResponse response = wsTester.newRequest().execute(); response.assertNoContent(); - assertThat(dbTester.countRowsOfTable("scanner_cache")).isZero(); + assertThat(dbTester.countRowsOfTable("scanner_analysis_cache")).isZero(); } @Test diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/GetActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/GetActionTest.java index 7135bf77b67..312df15ca6b 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/GetActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/scannercache/ws/GetActionTest.java @@ -33,7 +33,7 @@ import org.sonar.api.web.UserRole; import org.sonar.db.DbTester; import org.sonar.db.component.BranchDto; import org.sonar.db.project.ProjectDto; -import org.sonar.db.scannercache.ScannerCacheDao; +import org.sonar.db.scannercache.ScannerAnalysisCacheDao; import org.sonar.server.component.ComponentFinder; import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; @@ -54,7 +54,7 @@ public class GetActionTest { @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); - private final ScannerCacheDao dao = new ScannerCacheDao(); + private final ScannerAnalysisCacheDao dao = new ScannerAnalysisCacheDao(); private final ScannerCache cache = new ScannerCache(dbTester.getDbClient(), dao); private final ComponentFinder finder = new ComponentFinder(dbTester.getDbClient(), null); private final GetAction ws = new GetAction(dbTester.getDbClient(), userSession, finder, cache); diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java index 1d678796df5..9cc89f31eee 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java @@ -222,7 +222,7 @@ import org.sonar.server.rule.ws.RuleWsSupport; import org.sonar.server.rule.ws.RulesWs; import org.sonar.server.rule.ws.TagsAction; import org.sonar.server.scannercache.ScannerCache; -import org.sonar.server.scannercache.ws.ScannerCacheWsModule; +import org.sonar.server.scannercache.ws.AnalysisCacheWsModule; import org.sonar.server.setting.ProjectConfigurationLoaderImpl; import org.sonar.server.setting.SettingsChangeNotifier; import org.sonar.server.setting.ws.SettingsWsModule; @@ -527,7 +527,7 @@ public class PlatformLevel4 extends PlatformLevel { // Scanner Cache ScannerCache.class, - new ScannerCacheWsModule(), + new AnalysisCacheWsModule(), // ALM integrations TimeoutConfigurationImpl.class, diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheLoader.java index 420a5d5f852..f582e122079 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheLoader.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheLoader.java @@ -40,7 +40,7 @@ import org.sonarqube.ws.client.WsResponse; public class AnalysisCacheLoader { static final String CONTENT_ENCODING = "Content-Encoding"; static final String ACCEPT_ENCODING = "Accept-Encoding"; - private static final String URL = "api/scanner_cache/get"; + private static final String URL = "api/analysis_cache/get"; private final DefaultScannerWsClient wsClient; private final InputProject project; diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorage.java index 420bd1711a8..56596dedeb7 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorage.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorage.java @@ -20,7 +20,6 @@ package org.sonar.scanner.cache; import java.io.InputStream; -import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.scanner.protocol.internal.ScannerInternal.AnalysisCacheMsg; @@ -34,15 +33,11 @@ public class AnalysisCacheMemoryStorage implements AnalysisCacheStorage { } @Override - @CheckForNull public InputStream get(String key) { - if (cache == null) { - return null; - } - if (cache.containsMap(key)) { - return cache.getMapOrThrow(key).newInput(); + if (!contains(key)) { + throw new IllegalArgumentException("Key not found: " + key); } - return null; + return cache.getMapOrThrow(key).newInput(); } @Override diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheStorage.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheStorage.java index 5fb7765da38..9f58f3b3ad7 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheStorage.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cache/AnalysisCacheStorage.java @@ -20,10 +20,8 @@ package org.sonar.scanner.cache; import java.io.InputStream; -import javax.annotation.CheckForNull; public interface AnalysisCacheStorage { - @CheckForNull InputStream get(String key); boolean contains(String key); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorageTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorageTest.java index fb3a994cf57..528e9d6bd10 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorageTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/cache/AnalysisCacheMemoryStorageTest.java @@ -28,6 +28,7 @@ import org.junit.Test; import org.sonar.scanner.protocol.internal.ScannerInternal.AnalysisCacheMsg; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -49,18 +50,18 @@ public class AnalysisCacheMemoryStorageTest { } @Test - public void get_returns_null_if_doesnt_contain_key() { + public void get_throws_IAE_if_doesnt_contain_key() { when(loader.load()).thenReturn(Optional.of(AnalysisCacheMsg.newBuilder().build())); storage.load(); assertThat(storage.contains("key1")).isFalse(); - assertThat(storage.get("key1")).isNull(); + assertThatThrownBy(() -> storage.get("key1")).isInstanceOf(IllegalArgumentException.class); } @Test - public void get_returns_null_if_no_cache() { + public void get_throws_IAE_if_no_cache() { when(loader.load()).thenReturn(Optional.empty()); storage.load(); assertThat(storage.contains("key1")).isFalse(); - assertThat(storage.get("key1")).isNull(); + assertThatThrownBy(() -> storage.get("key1")).isInstanceOf(IllegalArgumentException.class); } } diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java index d5bcf2a3a4d..6c33311fc5e 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/FileStructure.java @@ -67,7 +67,7 @@ public class FileStructure { } public File analysisCache() { - return new File(dir, "plugin-cache.pb"); + return new File(dir, "analysis-cache.pb"); } public File analysisLog() { diff --git a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java index 5e1376a3f1c..006bdf66760 100644 --- a/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java +++ b/sonar-scanner-protocol/src/main/java/org/sonar/scanner/protocol/output/ScannerReportReader.java @@ -80,7 +80,7 @@ public class ScannerReportReader { } @CheckForNull - public InputStream getPluginCache() { + public InputStream getAnalysisCache() { File file = fileStructure.analysisCache(); if (fileExists(file)) { try { diff --git a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java index 1269c63c540..269bacef2d4 100644 --- a/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java +++ b/sonar-scanner-protocol/src/test/java/org/sonar/scanner/protocol/output/ScannerReportReaderTest.java @@ -213,7 +213,7 @@ public class ScannerReportReaderTest { } @Test - public void read_plugin_cache() throws IOException { + public void read_analysis_cache() throws IOException { ScannerReportWriter writer = new ScannerReportWriter(dir); writer.writeAnalysisCache(ScannerInternal.AnalysisCacheMsg.newBuilder() .putMap("key", ByteString.copyFrom("data", UTF_8)) @@ -221,7 +221,7 @@ public class ScannerReportReaderTest { ScannerReportReader reader = new ScannerReportReader(dir); - AnalysisCacheMsg cache = Protobuf.read(new GZIPInputStream(reader.getPluginCache()), ScannerInternal.AnalysisCacheMsg.parser()); + AnalysisCacheMsg cache = Protobuf.read(new GZIPInputStream(reader.getAnalysisCache()), ScannerInternal.AnalysisCacheMsg.parser()); assertThat(cache.getMapMap()).containsOnly(new AbstractMap.SimpleEntry<>("key", ByteString.copyFrom("data", UTF_8))); } |