Skip to content

Commit 28599fd

Browse files
authored
launder logged file paths (#4543)
1 parent 9a60c0c commit 28599fd

File tree

5 files changed

+97
-77
lines changed

5 files changed

+97
-77
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/PathAccepter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626
import org.opengrok.indexer.logger.LoggerFactory;
2727

2828
import java.io.File;
29-
import java.util.logging.Level;
3029
import java.util.logging.Logger;
3130

31+
import static org.opengrok.indexer.web.Laundromat.launderLog;
32+
3233
/**
3334
* Represents a gatekeeper that decides whether a particular file or directory
3435
* is acceptable for history or code analysis with respect to configuration of
@@ -59,12 +60,13 @@ public boolean accept(File file) {
5960
if (!includedNames.isEmpty()
6061
&& // the filter should not affect directory names
6162
(!(file.isDirectory() || includedNames.match(file)))) {
62-
LOGGER.log(Level.FINER, "not including ''{0}''", file.getAbsolutePath());
63+
64+
LOGGER.finer(() -> String.format("not including '%s'", launderLog(file.getAbsolutePath())));
6365
return false;
6466
}
6567

6668
if (ignoredNames.ignore(file)) {
67-
LOGGER.log(Level.FINER, "ignoring ''{0}''", file.getAbsolutePath());
69+
LOGGER.finer(() -> String.format("ignoring '%s'", launderLog(file.getAbsolutePath())));
6870
return false;
6971
}
7072

opengrok-indexer/src/main/java/org/opengrok/indexer/history/FileAnnotationCache.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
2222
*/
2323
package org.opengrok.indexer.history;
2424

@@ -40,6 +40,8 @@
4040
import java.util.logging.Level;
4141
import java.util.logging.Logger;
4242

43+
import static org.opengrok.indexer.web.Laundromat.launderLog;
44+
4345
public class FileAnnotationCache extends AbstractCache implements AnnotationCache {
4446

4547
private static final Logger LOGGER = LoggerFactory.getLogger(FileAnnotationCache.class);
@@ -169,11 +171,11 @@ public Annotation get(File file, @Nullable String rev) throws CacheException {
169171
* should be present to catch weird cases of someone not using the store() or general badness.
170172
*/
171173
if (storedRevision == null) {
172-
LOGGER.log(Level.FINER, "no stored revision in annotation cache for ''{0}''", file);
174+
LOGGER.finer(() -> String.format("no stored revision in annotation cache for '%s'",
175+
launderLog(file.toString())));
173176
} else if (!storedRevision.equals(latestRevision)) {
174-
LOGGER.log(Level.FINER,
175-
"stored revision {0} for ''{1}'' does not match latest revision {2}",
176-
new Object[]{storedRevision, file, rev});
177+
LOGGER.finer(() -> String.format("stored revision %s for '%s' does not match latest revision %s",
178+
storedRevision, launderLog(file.toString()), rev));
177179
} else {
178180
// read from the cache
179181
annotation = readAnnotation(file);
@@ -188,8 +190,8 @@ public Annotation get(File file, @Nullable String rev) throws CacheException {
188190
if (fileAnnotationCacheMisses != null) {
189191
fileAnnotationCacheMisses.increment();
190192
}
191-
LOGGER.log(Level.FINEST, "annotation cache miss for ''{0}'' in revision {1}",
192-
new Object[]{file, rev});
193+
LOGGER.finest(() -> String.format("annotation cache miss for '%s' in revision %s",
194+
launderLog(file.toString()), rev));
193195
return null;
194196
}
195197

0 commit comments

Comments
 (0)