private void silentlySendError(HttpServletResponse response, int error) { if (system.isCommitted(response)) { LOG.trace("Response is committed. Cannot send error response code {}", error); return; } try { system.sendError(response, error); } catch (IOException e) { LOG.trace("Failed to send error code {}: {}", error, e); } }
@Override public void startIt() { if (semaphore.tryAcquire()) { try { executorService.execute(this::doDatabaseMigration); } catch (RuntimeException e) { semaphore.release(); throw e; } } else { LOGGER.trace("{}: lock is already taken or process is already running", Thread.currentThread().getName()); } }
private static void broadcastTo(Set<ChangedIssue> changedIssues, QGChangeEvent changeEvent, QGChangeEventListener listener) { try { LOG.trace("calling onChange() on listener {} for events {}...", listener.getClass().getName(), changeEvent); listener.onIssueChanges(changeEvent, changedIssues); } catch (Exception e) { LOG.warn(format("onChange() call failed on listener %s for events %s", listener.getClass().getName(), changeEvent), e); } }
/** * Logs a TRACE message, which is only to be constructed if the logging level * is such that the message will actually be logged. * <p> * TRACE messages must * be valuable for diagnosing production problems. They must not be used for development debugging. * They can significantly slow down performances. The standard use-case is logging of * SQL and Elasticsearch requests. * @param msgSupplier A function, which when called, produces the desired log message * @since 6.3 */ default void trace(Supplier<String> msgSupplier) { if (isTraceEnabled()) { trace(msgSupplier.get()); } }
private IndexingResult doIndex(DbSession dbSession, IndexType type, Collection<EsQueueDto> typeItems) { LOGGER.trace(LOG_PREFIX + "processing {} {}", typeItems.size(), type); ResilientIndexer indexer = indexersByType.get(type); if (indexer == null) { LOGGER.error(LOG_PREFIX + "ignore {} items with unsupported type {}", typeItems.size(), type); return new IndexingResult(); } return indexer.index(dbSession, typeItems); }
private static Optional<ScmInfo> getScmInfoFromReport(Component file, ScannerReport.Changesets changesets) { LOGGER.trace("Reading SCM info from report for file '{}'", file.getDbKey()); return Optional.of(new ReportScmInfo(changesets)); }
private void cancelWornOuts() { try { LOG.trace("Cancelling any worn out task"); internalCeQueue.cancelWornOuts(); } catch (Exception e) { LOG.warn("Failed to cancel worn out tasks", e); } } }
private static boolean handleRootIdUpdateForSubNodes(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { long rootId = row.getLong(1); String rootUuid = componentUuidById.get(rootId); if (rootUuid == null) { LOG.trace("No UUID found for rootId={}", rootUuid); return false; } update.setString(1, rootUuid); update.setLong(2, rootId); return true; }
@Override public void visitFile(Component file) { List<CpdTextBlock> cpdTextBlocks; try (CloseableIterator<CpdTextBlock> blocksIt = reportReader.readCpdTextBlocks(file.getReportAttributes().getRef())) { cpdTextBlocks = newArrayList(blocksIt); LOGGER.trace("Found {} cpd blocks on file {}", cpdTextBlocks.size(), file.getDbKey()); if (cpdTextBlocks.isEmpty()) { return; } } Collection<String> hashes = from(cpdTextBlocks).transform(CpdTextBlockToHash.INSTANCE).toList(); List<DuplicationUnitDto> dtos = selectDuplicates(file, hashes); if (dtos.isEmpty()) { return; } Collection<Block> duplicatedBlocks = from(dtos).transform(DtoToBlock.INSTANCE).toList(); Collection<Block> originBlocks = from(cpdTextBlocks).transform(new CpdTextBlockToBlock(file.getDbKey())).toList(); LOGGER.trace("Found {} duplicated cpd blocks on file {}", duplicatedBlocks.size(), file.getDbKey()); integrateCrossProjectDuplications.computeCpd(file, originBlocks, duplicatedBlocks); }
private static boolean handleDeveloperUuuidUpdate(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { long id = row.getLong(1); long personId = row.getLong(2); String developerUuid = componentUuidById.get(personId); if (developerUuid == null) { LOG.trace("No UUID found for personId={}", personId); return false; } update.setString(1, developerUuid); update.setLong(2, id); return true; }
private void initNewDebtRatioCounter(Component file, Path<Counter> path) { // first analysis, no period, no differential value to compute, save processing time and return now if (!newLinesRepository.newLinesAvailable()) { return; } Optional<Set<Integer>> changedLines = newLinesRepository.getNewLines(file); if (!changedLines.isPresent()) { LOG.trace(String.format("No information about changed lines is available for file '%s'. Dev cost will be zero.", file.getKey())); return; } Optional<Measure> nclocDataMeasure = measureRepository.getRawMeasure(file, this.nclocDataMetric); if (!nclocDataMeasure.isPresent()) { return; } initNewDebtRatioCounter(path.current(), file, nclocDataMeasure.get(), changedLines.get()); }
private void resetTasksWithUnknownWorkerUUIDs() { try { LOG.trace("Resetting state of tasks with unknown worker UUIDs"); internalCeQueue.resetTasksWithUnknownWorkerUUIDs(ceDistributedInformation.getWorkerUUIDs()); } catch (Exception e) { LOG.warn("Failed to reset tasks with unknown worker UUIDs", e); } }
private static boolean handleCopyComponentUuidUpdate(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException { long id = row.getLong(1); long copyResourceId = row.getLong(2); String copyComponentUuid = componentUuidById.get(copyResourceId); if (copyComponentUuid == null) { LOG.trace("No UUID found for copyResourceId={}", copyResourceId); return false; } update.setString(1, copyComponentUuid); update.setLong(2, id); return true; }
private boolean isConnectedToDB() { try (DbSession dbSession = dbClient.openSession(false)) { return dbSession.getMapper(IsAliveMapper.class).isAlive() == IsAliveMapper.IS_ALIVE_RETURNED_VALUE; } catch (RuntimeException e) { LOGGER.trace("DB connection is down: {}", e); return false; } } }
public Optional<DbScmInfo> getScmInfo(Component file) { Optional<String> uuid = getFileUUid(file); if (!uuid.isPresent()) { return Optional.empty(); } LOGGER.trace("Reading SCM info from DB for file '{}'", uuid.get()); try (DbSession dbSession = dbClient.openSession(false)) { FileSourceDto dto = dbClient.fileSourceDao().selectByFileUuid(dbSession, uuid.get()); if (dto == null) { return Optional.empty(); } return DbScmInfo.create(dto.getSourceData().getLinesList(), dto.getSrcHash()); } }
private void registerMatches(Map<String, DbComponent> dbFilesByUuid, Map<String, Component> reportFilesByUuid, ElectedMatches electedMatches) { LOG.debug("{} files moves found", electedMatches.size()); for (Match validatedMatch : electedMatches) { movedFilesRepository.setOriginalFile( reportFilesByUuid.get(validatedMatch.getReportUuid()), toOriginalFile(dbFilesByUuid.get(validatedMatch.getDbUuid()))); LOG.trace("File move found: {}", validatedMatch); } }
@Override public void visitAny(org.sonar.ce.task.projectanalysis.component.Component component) { MeasureComputerContextImpl context = new MeasureComputerContextImpl(component, settings, measureRepository, metricRepository, componentIssuesRepository); for (MeasureComputerWrapper measureComputerWrapper : measureComputersHolder.getMeasureComputers()) { context.setDefinition(measureComputerWrapper.getDefinition()); MeasureComputer measureComputer = measureComputerWrapper.getComputer(); LOGGER.trace("Measure computer '{}' is computing component {}", measureComputer, component); measureComputer.compute(context); } } }
private Optional<ScmInfo> getScmInfoForComponent(Component component) { ScannerReport.Changesets changesets = scannerReportReader.readChangesets(component.getReportAttributes().getRef()); if (changesets == null) { LOGGER.trace("No SCM info for file '{}'", component.getDbKey()); // SCM not available. It might have been available before - copy information for unchanged lines but don't keep author and revision. return generateAndMergeDb(component, false); } // will be empty if the flag "copy from previous" is set, or if the file is empty. if (changesets.getChangesetCount() == 0) { return generateAndMergeDb(component, changesets.getCopyFromPrevious()); } return getScmInfoFromReport(component, changesets); }
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; DBSessions dbSessions = platform.getContainer().getComponentByType(DBSessions.class); ThreadLocalSettings settings = platform.getContainer().getComponentByType(ThreadLocalSettings.class); DefaultOrganizationCache defaultOrganizationCache = platform.getContainer().getComponentByType(DefaultOrganizationCache.class); UserSessionInitializer userSessionInitializer = platform.getContainer().getComponentByType(UserSessionInitializer.class); LOG.trace("{} serves {}", Thread.currentThread(), request.getRequestURI()); dbSessions.enableCaching(); try { defaultOrganizationCache.load(); try { settings.load(); try { doFilter(request, response, chain, userSessionInitializer); } finally { settings.unload(); } } finally { defaultOrganizationCache.unload(); } } finally { dbSessions.disableCaching(); } }