@Override public void handleAll(char c) { if (!alreadyLoggedInvalidCharacter && c == '\ufffd') { LOG.warn("Invalid character encountered in file {} at line {} for encoding {}. Please fix file content or configure the encoding to be used using property '{}'.", filePath, lines, encoding, CoreProperties.ENCODING_PROPERTY); alreadyLoggedInvalidCharacter = true; } }
private static void logWarningIf(boolean condition, String message) { if (condition) { LOGGER.warn(message); } }
@Override public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { if (exc instanceof FileSystemLoopException) { LOG.warn("Not indexing due to symlink loop: {}", file.toFile()); return FileVisitResult.CONTINUE; } throw exc; }
private void logOnce(String metricKey, String msg, Object... params) { if (alreadyLogged.add(metricKey)) { LOG.warn(msg, params); } }
private void warnOnceUnsupportedIssueExclusions(String msg) { if (!warnExclusionsAlreadyLogged) { LOG.warn(msg); analysisWarnings.addUnique(msg); warnExclusionsAlreadyLogged = true; } }
private void warnOnceDeprecatedIssuePattern(String msg) { if (!warnDeprecatedIssuePatternAlreadyLogged) { LOG.warn(msg); analysisWarnings.addUnique(msg); warnDeprecatedIssuePatternAlreadyLogged = true; } }
private void warnOnceDeprecatedIssuePattern(String msg) { if (!warnDeprecatedIssuePatternAlreadyLogged) { LOG.warn(msg); analysisWarnings.addUnique(msg); warnDeprecatedIssuePatternAlreadyLogged = true; } }
@Override public void start() { configuration.get(PROPERTY_SONAR_CE_WORKER_COUNT) .ifPresent(workerCount -> LOG.warn("Property {} is not supported anymore and will be ignored." + " Remove it from sonar.properties to remove this warning.", PROPERTY_SONAR_CE_WORKER_COUNT)); }
private void warnOnce(String propKey, String filePath, BooleanSupplier alreadyLoggedGetter, Runnable markAsLogged) { if (!alreadyLoggedGetter.getAsBoolean()) { String msg = "Specifying module-relative paths at project level in the property '" + propKey + "' is deprecated. " + "To continue matching files like '" + filePath + "', update this property so that patterns refer to project-relative paths."; LOG.warn(msg); analysisWarnings.addUnique(msg); markAsLogged.run(); } }
public static void closeQuietly(@Nullable ResultSet rs) { if (rs != null) { try { rs.close(); } catch (SQLException e) { Loggers.get(DatabaseUtils.class).warn("Fail to close result set", e); // ignore } } }
private String format(boolean logIfMissing, String key, Object... args) { try { String message = getString(key); return String.format(locale, message, args); } catch (MissingResourceException e) { if (logIfMissing) { LOG.warn("Missing translation: key==" + key + ",locale=" + locale); } return key; } }
private EmailMessage format(Notification notification) { for (EmailTemplate template : templates) { EmailMessage email = template.format(notification); if (email != null) { return email; } } LOG.warn("Email template not found for notification: {}", notification); return null; }
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); } }
private static Path initWorkingDir(ProjectDefinition module) { File workingDirAsFile = module.getWorkDir(); Path workingDir = workingDirAsFile.getAbsoluteFile().toPath().normalize(); if (SystemUtils.IS_OS_WINDOWS) { try { Files.setAttribute(workingDir, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS); } catch (IOException e) { LOGGER.warn("Failed to set working directory hidden: {}", e.getMessage()); } } return workingDir; }
@Override public boolean apply(@Nonnull ClonePart input) { if (counter == MAX_CLONE_PART_PER_GROUP) { LOGGER.warn("Too many duplication references on file {} for block at line {}. Keeping only the first {} references.", file.getDbKey(), originPart.getStartLine(), MAX_CLONE_PART_PER_GROUP); } boolean res = counter <= MAX_CLONE_GROUP_PER_FILE; counter++; return res; } }
private static Rule create(String repositoryKey, Class annotatedClass) { org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClass, org.sonar.check.Rule.class); if (ruleAnnotation != null) { return toRule(repositoryKey, annotatedClass, ruleAnnotation); } LOG.warn("The class " + annotatedClass.getCanonicalName() + " should be annotated with " + Rule.class); return null; }
@Override public void init(DatabaseMetaData metaData) throws SQLException { checkState(!initialized, "onInit() must be called once"); Version version = checkDbVersion(metaData, MIN_SUPPORTED_VERSION); supportsUpsert = version.compareTo(MIN_UPSERT_VERSION) >= 0; if (!supportsUpsert) { Loggers.get(getClass()).warn("Upgrading PostgreSQL to {} or greater is recommended for better performances", MIN_UPSERT_VERSION); } initialized = true; } }
@Override public ProtobufSystemInfo.Section toProtobuf() { ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder(); protobuf.setName("Search Indexes"); try { completeIndexAttributes(protobuf); } catch (Exception es) { Loggers.get(EsIndexesSection.class).warn("Failed to retrieve ES attributes. There will be only a single \"Error\" attribute.", es); setAttribute(protobuf, "Error", es.getCause() instanceof ElasticsearchException ? es.getCause().getMessage() : es.getMessage()); } return protobuf.build(); }
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); } }
@Test public void should_log_warning_if_toString_is_not_overridden() { Logger log = mock(Logger.class); keys.of(new Object(), log); verifyZeroInteractions(log); // only on non-first runs, to avoid false-positives on singletons keys.of(new Object(), log); verify(log).warn(startsWith("Bad component key")); }