Skip to content

Commit b2db0b7

Browse files
committed
Do log all handled ForbiddenSymlinkException at same FINER level
Also, restore accidentally removed block comment.
1 parent d370c17 commit b2db0b7

File tree

11 files changed

+42
-16
lines changed

11 files changed

+42
-16
lines changed

src/org/opensolaris/opengrok/configuration/Project.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import java.util.Locale;
3030
import java.util.Set;
3131
import java.util.TreeSet;
32+
import java.util.logging.Level;
33+
import java.util.logging.Logger;
34+
import org.opensolaris.opengrok.logger.LoggerFactory;
3235
import org.opensolaris.opengrok.util.ClassUtil;
3336
import org.opensolaris.opengrok.util.ForbiddenSymlinkException;
3437

@@ -39,6 +42,8 @@ public class Project implements Comparable<Project>, Nameable, Serializable {
3942

4043
private static final long serialVersionUID = 1L;
4144

45+
private static final Logger LOGGER = LoggerFactory.getLogger(Project.class);
46+
4247
static {
4348
ClassUtil.remarkTransientFields(Project.class);
4449
}
@@ -317,7 +322,10 @@ public static Project getProject(File file) {
317322
ret = getProject(RuntimeEnvironment.getInstance().getPathRelativeToSourceRoot(file));
318323
} catch (FileNotFoundException e) { // NOPMD
319324
// ignore if not under source root
320-
} catch (IOException|ForbiddenSymlinkException e) { // NOPMD
325+
} catch (ForbiddenSymlinkException e) {
326+
LOGGER.log(Level.FINER, e.getMessage());
327+
// ignore
328+
} catch (IOException e) { // NOPMD
321329
// problem has already been logged, just return null
322330
}
323331
return ret;

src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ private void generateProjectRepositoriesMap() throws IOException {
13351335
repoPath = getPathRelativeToSourceRoot(
13361336
new File(r.getDirectoryName()), 0);
13371337
} catch (ForbiddenSymlinkException e) {
1338+
LOGGER.log(Level.FINER, e.getMessage());
13381339
continue;
13391340
}
13401341

src/org/opensolaris/opengrok/configuration/messages/ProjectMessage.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,12 @@ protected byte[] applyMessage(RuntimeEnvironment env) throws Exception {
201201
return env.getPathRelativeToSourceRoot(
202202
new File((x).getDirectoryName())
203203
);
204-
} catch (IOException|ForbiddenSymlinkException e) {
204+
} catch (ForbiddenSymlinkException e) {
205+
LOGGER.log(Level.FINER, e.getMessage());
206+
return "";
207+
} catch (IOException e) {
205208
LOGGER.log(Level.INFO,
206-
"cannot remove files for repository " +
209+
"cannot remove files for repository {0}",
207210
x.getDirectoryName());
208211
// Empty output should not cause any harm
209212
// since {@code getReposFromString()} inside

src/org/opensolaris/opengrok/history/BazaarHistoryParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ public void processStream(InputStream input) throws IOException {
173173
String name = env.getPathRelativeToSourceRoot(f);
174174
entry.addFile(name.intern());
175175
} catch (ForbiddenSymlinkException e) {
176-
// ignored (and already logged by PathUtils)
176+
LOGGER.log(Level.FINER, e.getMessage());
177+
// ignored
177178
}
178179
}
179180
break;

src/org/opensolaris/opengrok/history/FileHistoryCache.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private boolean isRenamedFile(String filename,
152152
repodir = env.getPathRelativeToSourceRoot(
153153
new File(repository.getDirectoryName()));
154154
} catch (ForbiddenSymlinkException e) {
155-
// already logged by PathUtils
155+
LOGGER.log(Level.FINER, e.getMessage());
156156
return false;
157157
}
158158
String shortestfile = filename.substring(repodir.length() + 1);
@@ -380,6 +380,9 @@ private void storeFile(History histNew, File file, Repository repo)
380380
private void finishStore(Repository repository, String latestRev) {
381381
String histDir = getRepositoryHistDataDirname(repository);
382382
if (histDir == null || !(new File(histDir)).isDirectory()) {
383+
// If the history was not created for some reason (e.g. temporary
384+
// failure), do not create the CachedRevision file as this would
385+
// create confusion (once it starts working again).
383386
LOGGER.log(Level.WARNING,
384387
"Could not store history for repo {0}",
385388
repository.getDirectoryName());
@@ -644,7 +647,10 @@ public boolean hasCacheForDirectory(File directory, Repository repository)
644647
try {
645648
dir = new File(dir, env.getPathRelativeToSourceRoot(
646649
new File(repos.getDirectoryName())));
647-
} catch (IOException|ForbiddenSymlinkException e) {
650+
} catch (ForbiddenSymlinkException e) {
651+
LOGGER.log(Level.FINER, e.getMessage());
652+
return false;
653+
} catch (IOException e) {
648654
throw new HistoryException("Could not resolve " +
649655
repos.getDirectoryName()+" relative to source root", e);
650656
}
@@ -673,7 +679,7 @@ public String getRepositoryHistDataDirname(Repository repository) {
673679
repository.getDirectoryName()+" relative to source root", ex);
674680
return null;
675681
} catch (ForbiddenSymlinkException ex) {
676-
LOGGER.log(Level.FINE, "forbidden symbolic link", ex);
682+
LOGGER.log(Level.FINER, ex.getMessage());
677683
return null;
678684
}
679685

src/org/opensolaris/opengrok/history/GitHistoryParser.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.text.ParseException;
3535
import java.util.ArrayList;
3636
import java.util.List;
37+
import java.util.logging.Level;
3738
import java.util.logging.Logger;
3839
import java.util.regex.Pattern;
3940
import org.opensolaris.opengrok.configuration.RuntimeEnvironment;
@@ -132,8 +133,10 @@ private void process(BufferedReader in) throws IOException {
132133
File f = new File(myDir, s);
133134
String path = env.getPathRelativeToSourceRoot(f);
134135
entry.addFile(path.intern());
135-
} catch (FileNotFoundException|
136-
ForbiddenSymlinkException e) { //NOPMD
136+
} catch (ForbiddenSymlinkException e) {
137+
LOGGER.log(Level.FINER, e.getMessage());
138+
// ignore
139+
} catch (FileNotFoundException e) { //NOPMD
137140
// If the file is not located under the source root,
138141
// ignore it (bug #11664).
139142
}

src/org/opensolaris/opengrok/history/MercurialHistoryParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ public void processStream(InputStream input) throws IOException {
144144
try {
145145
String path = env.getPathRelativeToSourceRoot(f);
146146
entry.addFile(path.intern());
147-
} catch (FileNotFoundException|
148-
ForbiddenSymlinkException e) { // NOPMD
147+
} catch (ForbiddenSymlinkException e) {
148+
LOGGER.log(Level.FINER, e.getMessage());
149+
// ignore
150+
} catch (FileNotFoundException e) { // NOPMD
149151
// If the file is not located under the source root,
150152
// ignore it (bug #11664).
151153
}

src/org/opensolaris/opengrok/history/MonotoneHistoryParser.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ public void processStream(InputStream input) throws IOException {
169169
String path = env.getPathRelativeToSourceRoot(
170170
file);
171171
entry.addFile(path.intern());
172-
} catch (FileNotFoundException|
173-
ForbiddenSymlinkException e) { // NOPMD
172+
} catch (ForbiddenSymlinkException e) {
173+
LOGGER.log(Level.FINER, e.getMessage());
174+
// ignore
175+
} catch (FileNotFoundException e) { // NOPMD
174176
// If the file is not located under the source root, ignore it
175177
}
176178
}

src/org/opensolaris/opengrok/index/IndexDatabase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ public static Definitions getDefinitions(File file)
13301330
try {
13311331
path = env.getPathRelativeToSourceRoot(file);
13321332
} catch (ForbiddenSymlinkException e) {
1333-
// (already logged by PathUtils)
1333+
LOGGER.log(Level.FINER, e.getMessage());
13341334
return null;
13351335
}
13361336
//sanitize windows path delimiters

src/org/opensolaris/opengrok/util/ForbiddenSymlinkException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* CDDL HEADER END
1818
*/
1919

20-
/*
20+
/*
2121
* Copyright (c) 2017, Chris Fraire <[email protected]>.
2222
*/
2323

0 commit comments

Comments
 (0)