Skip to content

Commit 1c62d76

Browse files
author
Vladimir Kotal
committed
handle exceptions from EftarFileReader#getNode() in extraListTo()
fixes #3316
1 parent 3fa5ed4 commit 1c62d76

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

opengrok-web/src/main/java/org/opengrok/web/DirectoryListing.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@
3434
import java.util.List;
3535
import java.util.Locale;
3636
import java.util.Map;
37+
import java.util.logging.Level;
38+
import java.util.logging.Logger;
3739
import java.util.stream.Collectors;
3840
import org.opengrok.indexer.configuration.PathAccepter;
3941
import org.opengrok.indexer.configuration.RuntimeEnvironment;
4042
import org.opengrok.indexer.history.HistoryException;
4143
import org.opengrok.indexer.history.HistoryGuru;
44+
import org.opengrok.indexer.logger.LoggerFactory;
4245
import org.opengrok.indexer.search.DirectoryEntry;
4346
import org.opengrok.indexer.search.FileExtra;
4447
import org.opengrok.indexer.web.EftarFileReader;
@@ -49,6 +52,8 @@
4952
*/
5053
public class DirectoryListing {
5154

55+
private static final Logger LOGGER = LoggerFactory.getLogger(DirectoryListing.class);
56+
5257
protected static final String DIRECTORY_SIZE_PLACEHOLDER = "-";
5358
private final EftarFileReader desc;
5459
private final long now;
@@ -135,14 +140,12 @@ private static String getSimplifiedPath(File dir) {
135140
* @throws HistoryException history exception
136141
* @throws IOException I/O exception
137142
*/
138-
public List<String> listTo(String contextPath, File dir, Writer out,
139-
String path, List<String> files)
140-
throws HistoryException, IOException {
143+
public List<String> listTo(String contextPath, File dir, Writer out, String path, List<String> files)
144+
throws IOException, HistoryException {
141145
List<DirectoryEntry> filesExtra = null;
142146
if (files != null) {
143147
filesExtra = files.stream().map(f ->
144-
new DirectoryEntry(new File(dir, f), null)).collect(
145-
Collectors.toList());
148+
new DirectoryEntry(new File(dir, f), null)).collect(Collectors.toList());
146149
}
147150
return extraListTo(contextPath, dir, out, path, filesExtra);
148151
}
@@ -159,22 +162,21 @@ public List<String> listTo(String contextPath, File dir, Writer out,
159162
* but filtered by {@link PathAccepter}.
160163
* @return a possible empty list of README files included in the written
161164
* listing.
162-
* @throws org.opengrok.indexer.history.HistoryException when we cannot
163-
* get result from SCM
164-
*
165-
* @throws java.io.IOException when any I/O problem
166-
* @throws NullPointerException if a parameter except <var>files</var>
167-
* is {@code null}
165+
* @throws IOException when cannot write to the {@code out} parameter
166+
* @throws HistoryException when failed to get last modified time for files in directory
168167
*/
169168
public List<String> extraListTo(String contextPath, File dir, Writer out,
170-
String path, List<DirectoryEntry> entries)
171-
throws HistoryException, IOException {
169+
String path, List<DirectoryEntry> entries) throws IOException, HistoryException {
172170
// TODO this belongs to a jsp, not here
173171
ArrayList<String> readMes = new ArrayList<>();
174172
int offset = -1;
175173
EftarFileReader.FNode parentFNode = null;
176174
if (desc != null) {
177-
parentFNode = desc.getNode(path);
175+
try {
176+
parentFNode = desc.getNode(path);
177+
} catch (IOException e) {
178+
LOGGER.log(Level.WARNING, String.format("cannot get Eftar node for path ''%s''", path), e);
179+
}
178180
if (parentFNode != null) {
179181
offset = parentFNode.getChildOffset();
180182
}

0 commit comments

Comments
 (0)