Skip to content

Commit 174f246

Browse files
committed
Do not throw if source file unavailable for Context
1 parent 62b82a8 commit 174f246

File tree

1 file changed

+7
-4
lines changed
  • opengrok-indexer/src/main/java/org/opengrok/indexer/search

1 file changed

+7
-4
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/search/Results.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/*
2121
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright 2011 Jens Elkner.
23-
* Portions Copyright (c) 2017-2018, Chris Fraire <[email protected]>.
23+
* Portions Copyright (c) 2017-2019, Chris Fraire <[email protected]>.
2424
*/
2525

2626
package org.opengrok.indexer.search;
@@ -276,7 +276,7 @@ private static void printPlain(PrintPlainFinalArgs fargs, Document doc,
276276
fargs.morePrefix, true, fargs.tabSize);
277277

278278
if (!didPresentNew) {
279-
/**
279+
/*
280280
* Fall back to the old view, which re-analyzes text using
281281
* PlainLinetokenizer. E.g., when source code is updated (thus
282282
* affecting timestamps) but re-indexing is not yet complete.
@@ -295,12 +295,15 @@ private static void printPlain(PrintPlainFinalArgs fargs, Document doc,
295295
}
296296
boolean isDefSearch = fargs.shelp.builder.isDefSearch();
297297
// SRCROOT is read with UTF-8 as a default.
298+
File sourceFile = new File(fargs.shelp.sourceRoot, rpath);
298299
try (Reader r = IOUtils.createBOMStrippedReader(new FileInputStream(
299-
new File(fargs.shelp.sourceRoot, rpath)),
300-
StandardCharsets.UTF_8.name())) {
300+
sourceFile), StandardCharsets.UTF_8.name())) {
301301
fargs.shelp.sourceContext.getContext(r, fargs.out,
302302
fargs.xrefPrefix, fargs.morePrefix, rpath, tags, true,
303303
isDefSearch, null, scopes);
304+
} catch (IOException ex) {
305+
LOGGER.log(Level.WARNING, String.format("No context for %s",
306+
sourceFile, ex));
304307
}
305308
}
306309
}

0 commit comments

Comments
 (0)