Skip to content

Commit a160de5

Browse files
author
Vladimir Kotal
authored
suppress Sonar warnings about auto-closeable DefinitionsTokenStream (#3784)
* suppress Sonar warnings about auto-closeable DefinitionsTokenStream * add comments
1 parent 8d26ce8 commit a160de5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/plain/PlainAnalyzer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ public void analyze(Document doc, StreamSource src, Writer xrefOut) throws IOExc
200200
}
201201
}
202202

203-
private void tryAddingDefs(Document doc, Definitions defs, StreamSource src)
204-
throws IOException {
203+
// DefinitionsTokenStream should not be used in try-with-resources
204+
@SuppressWarnings("java:S2095")
205+
private void tryAddingDefs(Document doc, Definitions defs, StreamSource src) throws IOException {
205206

206207
DefinitionsTokenStream defstream = new DefinitionsTokenStream();
207208
defstream.initialize(defs, src, this::wrapReader);

opengrok-indexer/src/test/java/org/opengrok/indexer/analysis/plain/DefinitionsTokenStreamTest.java

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

2020
/*
21+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
2122
* Copyright (c) 2018, Chris Fraire <[email protected]>.
2223
*/
2324
package org.opengrok.indexer.analysis.plain;
@@ -97,6 +98,8 @@ public void testCppDefinitionsWithRawContent2() throws IOException {
9798
null);
9899
}
99100

101+
// DefinitionsTokenStream should not be used in try-with-resources
102+
@SuppressWarnings("java:S2095")
100103
private void testDefinitionsVsContent(
101104
boolean expandTabs,
102105
String sourceResource,

0 commit comments

Comments
 (0)