From 55cb434fa1a048daec5c9ede5f64215225aea247 Mon Sep 17 00:00:00 2001 From: Lubos Kosco Date: Tue, 23 Apr 2024 21:29:39 +0200 Subject: [PATCH 1/8] lucene 9.10.0 --- .../opengrok/indexer/search/SearchEngine.java | 20 +++++++-------- pom.xml | 2 +- .../suggest/SuggestResultCollector.java | 25 +++++++++++++++++++ .../opengrok/suggest/SuggesterSearcher.java | 2 +- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java index e12ad247142..3aa27c9d2c4 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/SearchEngine.java @@ -48,7 +48,7 @@ import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.TopScoreDocCollector; +import org.apache.lucene.search.TopScoreDocCollectorManager; import org.apache.lucene.util.Version; import org.opengrok.indexer.analysis.AbstractAnalyzer; import org.opengrok.indexer.analysis.CompatibleAnalyser; @@ -132,7 +132,7 @@ public class SearchEngine { int cachePages = RuntimeEnvironment.getInstance().getCachePages(); int totalHits = 0; private ScoreDoc[] hits; - private TopScoreDocCollector collector; + private TopScoreDocCollectorManager collectorManager; private IndexSearcher searcher; boolean allCollected; private final ArrayList searcherList = new ArrayList<>(); @@ -205,18 +205,17 @@ private void searchMultiDatabase(List projectList, boolean paging) thro } private void searchIndex(IndexSearcher searcher, boolean paging) throws IOException { - collector = TopScoreDocCollector.create(hitsPerPage * cachePages, Short.MAX_VALUE); + collectorManager = new TopScoreDocCollectorManager(hitsPerPage * cachePages, Short.MAX_VALUE); Statistics stat = new Statistics(); - searcher.search(query, collector); - totalHits = collector.getTotalHits(); + hits = searcher.search(query, collectorManager).scoreDocs; + totalHits = searcher.count(query); stat.report(LOGGER, Level.FINEST, "search via SearchEngine done", "search.latency", new String[]{"category", "engine", "outcome", totalHits > 0 ? "success" : "empty"}); if (!paging && totalHits > 0) { - collector = TopScoreDocCollector.create(totalHits, Short.MAX_VALUE); - searcher.search(query, collector); + collectorManager = new TopScoreDocCollectorManager(totalHits, Short.MAX_VALUE); + hits = searcher.search(query, collectorManager).scoreDocs; } - hits = collector.topDocs().scoreDocs; StoredFields storedFields = searcher.storedFields(); for (ScoreDoc hit : hits) { int docId = hit.doc; @@ -412,14 +411,13 @@ public void results(int start, int end, List ret) { // TODO check if below fits for if end=old hits.length, or it should include it if (end > hits.length && !allCollected) { //do the requery, we want more than 5 pages - collector = TopScoreDocCollector.create(totalHits, Short.MAX_VALUE); + collectorManager = new TopScoreDocCollectorManager(totalHits, Short.MAX_VALUE); try { - searcher.search(query, collector); + hits = searcher.search(query, collectorManager).scoreDocs; } catch (Exception e) { // this exception should never be hit, since search() will hit this before LOGGER.log( Level.WARNING, SEARCH_EXCEPTION_MSG, e); } - hits = collector.topDocs().scoreDocs; StoredFields storedFields = null; try { storedFields = searcher.storedFields(); diff --git a/pom.xml b/pom.xml index d80abb1457f..a5832d05650 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . - 9.9.2 + 9.10.0 3.6.0 11 UTF-8 diff --git a/suggester/src/main/java/org/opengrok/suggest/SuggestResultCollector.java b/suggester/src/main/java/org/opengrok/suggest/SuggestResultCollector.java index aefff246b3c..e93eb857d85 100644 --- a/suggester/src/main/java/org/opengrok/suggest/SuggestResultCollector.java +++ b/suggester/src/main/java/org/opengrok/suggest/SuggestResultCollector.java @@ -27,6 +27,7 @@ import org.apache.lucene.index.StoredFields; import org.apache.lucene.search.CollectionTerminatedException; import org.apache.lucene.search.Collector; +import org.apache.lucene.search.CollectorManager; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.LeafCollector; import org.apache.lucene.search.Scorable; @@ -35,6 +36,7 @@ import org.opengrok.suggest.query.data.BitIntsHolder; import java.io.IOException; +import java.util.Collection; /** * Collects Suggester query results. @@ -62,6 +64,29 @@ public LeafCollector getLeafCollector(LeafReaderContext context) throws IOExcept return new SuggesterLeafCollector(context); } + /** + * Creates a {@link CollectorManager} that can concurrently collect matching docs in a {@link + * BitIntsHolder}. + */ + public static CollectorManager createManager(LeafReaderContext leafReaderContext, ComplexQueryData data, + BitIntsHolder documentIds) { + return new CollectorManager<>() { + @Override + public SuggestResultCollector newCollector() { + return new SuggestResultCollector(leafReaderContext, data, documentIds); + } + + @Override + public BitIntsHolder reduce(Collection collectors) { + BitIntsHolder reduced = documentIds; + for (SuggestResultCollector collector : collectors) { + documentIds.or(collector.documentIds); //TODO fix as per https://github.com/apache/lucene/pull/766/files + } + return reduced; + } + }; + } + /** * Indicates what features are required from the scorer. */ diff --git a/suggester/src/main/java/org/opengrok/suggest/SuggesterSearcher.java b/suggester/src/main/java/org/opengrok/suggest/SuggesterSearcher.java index f02eefe6a9f..3ac4b3eb4ed 100644 --- a/suggester/src/main/java/org/opengrok/suggest/SuggesterSearcher.java +++ b/suggester/src/main/java/org/opengrok/suggest/SuggesterSearcher.java @@ -238,7 +238,7 @@ private ComplexQueryData getComplexQueryData(final Query query, final LeafReader BitIntsHolder documentIds = new BitIntsHolder(); try { - search(query, new SuggestResultCollector(leafReaderContext, data, documentIds)); + search(query, SuggestResultCollector.createManager(leafReaderContext, data, documentIds)); } catch (IOException e) { if (Thread.currentThread().isInterrupted()) { interrupted = true; From f34a24091f1d549e2a0d3c9ac6f69dd1548dac0e Mon Sep 17 00:00:00 2001 From: Lubos Kosco Date: Mon, 10 Jun 2024 17:32:03 +0200 Subject: [PATCH 2/8] lucene 9.11.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a5832d05650..2c1fb1dbd99 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . - 9.10.0 + 9.11.0 3.6.0 11 UTF-8 From e1c1a592561cc646346a93f2336bef51cd78192a Mon Sep 17 00:00:00 2001 From: Lubos Kosco Date: Thu, 27 Jun 2024 17:11:39 +0200 Subject: [PATCH 3/8] lucene 9.11.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2c1fb1dbd99..a7165c23ba9 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . - 9.11.0 + 9.11.1 3.6.0 11 UTF-8 From 6200b561a51859b7d6b336bb77488f952700593b Mon Sep 17 00:00:00 2001 From: Lubos Kosco Date: Tue, 1 Oct 2024 13:09:17 +0200 Subject: [PATCH 4/8] lucene 9.12.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a7165c23ba9..9406a2909d9 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . - 9.11.1 + 9.12.0 3.6.0 11 UTF-8 From 160984e2a700e6c0f8bf8f73b83df47c89ecdf59 Mon Sep 17 00:00:00 2001 From: Lubos Kosco Date: Wed, 23 Oct 2024 12:43:36 +0200 Subject: [PATCH 5/8] lucene 10.0.0 draft! (supress-es should be reviewed, scorer returns bad objects, so it should break scorer tests) --- .github/workflows/build.yml | 6 ++--- .github/workflows/codeql-analysis.yml | 4 +-- .github/workflows/javadoc.yml | 4 +-- .github/workflows/release.yml | 4 +-- .../indexer/analysis/Definitions.java | 6 +++-- .../indexer/analysis/JFlexTokenizer.java | 4 +++ .../opengrok/indexer/analysis/JFlexXref.java | 1 + .../indexer/analysis/PathTokenizer.java | 2 ++ .../plain/DefinitionsTokenStream.java | 3 +++ .../authorization/AuthorizationEntity.java | 3 +++ .../authorization/AuthorizationStack.java | 1 + .../indexer/configuration/Filter.java | 3 +++ .../configuration/OpenGrokThreadFactory.java | 2 +- .../indexer/configuration/Project.java | 26 +++++++++---------- .../configuration/SuggesterConfig.java | 2 +- .../indexer/framework/PluginFramework.java | 4 +-- .../indexer/history/AccuRevRepository.java | 1 + .../opengrok/indexer/history/Annotation.java | 2 +- .../indexer/history/AnnotationData.java | 1 + .../indexer/history/BitKeeperRepository.java | 1 + .../indexer/history/CVSRepository.java | 1 + .../org/opengrok/indexer/history/History.java | 4 +++ .../indexer/history/HistoryEntry.java | 1 + .../indexer/history/RepoRepository.java | 1 + .../opengrok/indexer/history/Repository.java | 3 +++ .../indexer/history/SSCMRepository.java | 1 + .../indexer/index/IndexAnalysisSettings.java | 1 + .../indexer/index/IndexAnalysisSettings3.java | 2 ++ .../index/IndexAnalysisSettingsAccessor.java | 2 +- .../indexer/index/IndexCheckException.java | 1 + .../opengrok/indexer/index/IndexDatabase.java | 6 ++--- .../indexer/index/IndexDocumentException.java | 2 ++ .../indexer/index/NumLinesLOCAccessor.java | 8 +++--- .../indexer/search/CustomQueryParser.java | 1 + .../opengrok/indexer/search/QueryBuilder.java | 2 +- .../opengrok/indexer/search/Summarizer.java | 2 +- .../search/context/OGKUnifiedHighlighter.java | 2 +- .../indexer/search/context/PrefixMatcher.java | 1 + .../indexer/search/context/QueryMatchers.java | 2 +- .../search/context/TokenSetMatcher.java | 1 + .../search/context/WildCardMatcher.java | 1 + .../org/opengrok/indexer/util/Executor.java | 2 +- .../org/opengrok/indexer/util/Progress.java | 2 +- .../opengrok/indexer/web/SearchHelper.java | 4 +-- .../java/org/opengrok/indexer/web/Util.java | 17 +++++------- .../java/org/opengrok/web/api/v1/RestApp.java | 1 + .../v1/controller/SuggesterController.java | 11 ++++---- .../suggester/query/SuggesterQueryParser.java | 6 ++--- .../java/opengrok/auth/entity/LdapUser.java | 1 + .../plugin/configuration/Configuration.java | 1 + .../opengrok/auth/plugin/ldap/LdapFacade.java | 1 + .../opengrok/auth/plugin/ldap/LdapServer.java | 3 +++ pom.xml | 4 +-- .../suggest/SuggestResultCollector.java | 4 +-- .../java/org/opengrok/suggest/Suggester.java | 4 +-- .../opengrok/suggest/SuggesterSearcher.java | 2 +- .../org/opengrok/suggest/SuggesterUtils.java | 4 +-- .../customized/CustomExactPhraseScorer.java | 7 ++--- .../query/customized/CustomPhraseQuery.java | 17 +++++++----- .../customized/CustomSloppyPhraseScorer.java | 7 ++--- .../org/opengrok/suggest/util/Progress.java | 1 + 61 files changed, 134 insertions(+), 90 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1fb2a647c3..aebb71979d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: jobs: build: - name: ${{ matrix.os }} with Java 17 + name: ${{ matrix.os }} with Java 21 runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -22,11 +22,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'oracle' - java-version: '17' + java-version: '21' - name: Cache Maven packages uses: actions/cache@v4 with: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 352b229168d..d4be7ea762e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -22,11 +22,11 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'oracle' - java-version: '17' + java-version: '21' - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: diff --git a/.github/workflows/javadoc.yml b/.github/workflows/javadoc.yml index 43374bbe752..52bbeebae5e 100644 --- a/.github/workflows/javadoc.yml +++ b/.github/workflows/javadoc.yml @@ -18,11 +18,11 @@ jobs: steps: - name: Checkout master branch uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'oracle' - java-version: '17' + java-version: '21' - name: Cache Maven packages uses: actions/cache@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1356dbfa0f8..44fc552bfe5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,11 +26,11 @@ jobs: steps: - name: Checkout master branch uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: distribution: 'oracle' - java-version: '17' + java-version: '21' - name: Cache Maven packages uses: actions/cache@v4 with: diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/Definitions.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/Definitions.java index 6c26ecb04a0..b2c724caa7c 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/Definitions.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/Definitions.java @@ -65,7 +65,7 @@ public class Definitions implements Serializable { public static class LineTagMap implements Serializable { private static final long serialVersionUID = 1191703801007779481L; - @SuppressWarnings("java:S116") + @SuppressWarnings({"java:S116", "serial"}) private final Map> sym_tags; //NOPMD protected LineTagMap() { @@ -73,16 +73,18 @@ protected LineTagMap() { } } // line number -> tag map - @SuppressWarnings("java:S116") + @SuppressWarnings({"java:S116", "serial"}) private final Map line_maps; /** * Map from symbol to the line numbers on which the symbol is defined. */ + @SuppressWarnings("serial") private final Map> symbols; /** * List of all the tags. */ + @SuppressWarnings("serial") private final List tags; public Definitions() { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexTokenizer.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexTokenizer.java index 0824870747f..b7ab9ece856 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexTokenizer.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexTokenizer.java @@ -49,6 +49,7 @@ public class JFlexTokenizer extends Tokenizer * will be owned by the {@link JFlexTokenizer}. * @param matcher a defined instance */ + @SuppressWarnings("this-escape") public JFlexTokenizer(ScanningSymbolMatcher matcher) { if (matcher == null) { throw new IllegalArgumentException("`matcher' is null"); @@ -83,10 +84,13 @@ public final void close() throws IOException { matcher.yyclose(); } + @SuppressWarnings("this-escape") private final CharTermAttribute termAtt = addAttribute( CharTermAttribute.class); + @SuppressWarnings("this-escape") private final OffsetAttribute offsetAtt = addAttribute( OffsetAttribute.class); + @SuppressWarnings("this-escape") private final PositionIncrementAttribute posIncrAtt = addAttribute( PositionIncrementAttribute.class); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexXref.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexXref.java index a11ff4748e9..1c4cfbec6a7 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexXref.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/JFlexXref.java @@ -99,6 +99,7 @@ public class JFlexXref implements Xrefer, SymbolMatchedListener, * will be owned by the {@link JFlexXref}. * @param matcher a defined instance */ + @SuppressWarnings("this-escape") public JFlexXref(ScanningSymbolMatcher matcher) { if (matcher == null) { throw new IllegalArgumentException("`matcher' is null"); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java index d1cd58ea06d..7c4b7527b66 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/PathTokenizer.java @@ -52,7 +52,9 @@ public class PathTokenizer extends Tokenizer { // below should be '/' since we try to convert even windows file separators // to unix ones public static final char DEFAULT_DELIMITER = '/'; + @SuppressWarnings("this-escape") private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class); + @SuppressWarnings("this-escape") private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class); private int startPosition = 0; private final char delimiter; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/plain/DefinitionsTokenStream.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/plain/DefinitionsTokenStream.java index 0b9023d511a..78f28676e98 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/plain/DefinitionsTokenStream.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/analysis/plain/DefinitionsTokenStream.java @@ -48,10 +48,13 @@ public class DefinitionsTokenStream extends TokenStream { */ private final List events = new ArrayList<>(); + @SuppressWarnings("this-escape") private final CharTermAttribute termAtt = addAttribute( CharTermAttribute.class); + @SuppressWarnings("this-escape") private final OffsetAttribute offsetAtt = addAttribute( OffsetAttribute.class); + @SuppressWarnings("this-escape") private final PositionIncrementAttribute posIncrAtt = addAttribute( PositionIncrementAttribute.class); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java index 086bb540301..27705271878 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationEntity.java @@ -119,13 +119,16 @@ public boolean test(AuthorizationEntity t) { */ protected AuthControlFlag flag; protected String name; + @SuppressWarnings("serial") protected Map setup = new TreeMap<>(); /** * Hold current setup - merged with all ancestor's stacks. */ protected transient Map currentSetup = new TreeMap<>(); + @SuppressWarnings("serial") private Set forProjects = new TreeSet<>(); + @SuppressWarnings("serial") private Set forGroups = new TreeSet<>(); protected transient boolean working = true; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationStack.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationStack.java index 3d6cc130b7c..8b4d90d1e09 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationStack.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/authorization/AuthorizationStack.java @@ -51,6 +51,7 @@ public class AuthorizationStack extends AuthorizationEntity { private static final Logger LOGGER = LoggerFactory.getLogger(AuthorizationStack.class); + @SuppressWarnings("serial") private List stack = new ArrayList<>(); public AuthorizationStack() { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Filter.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Filter.java index 235a6452c10..81f5c6fb3d7 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Filter.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Filter.java @@ -37,10 +37,13 @@ public class Filter implements Serializable { private static final long serialVersionUID = 3L; /** The list of exact filenames. */ + @SuppressWarnings("serial") private final Set filenames; /** The list of filenames with wildcards. */ + @SuppressWarnings("serial") private final List patterns; /** The list of paths. */ + @SuppressWarnings("serial") private final List paths; /** * The full list of all patterns. This list will be saved in the diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/OpenGrokThreadFactory.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/OpenGrokThreadFactory.java index c8e5f318381..83eef9175cd 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/OpenGrokThreadFactory.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/OpenGrokThreadFactory.java @@ -47,7 +47,7 @@ public OpenGrokThreadFactory(String name) { @Override public Thread newThread(@NotNull Runnable runnable) { Thread thread = Executors.defaultThreadFactory().newThread(Objects.requireNonNull(runnable, "runnable")); - thread.setName(PREFIX + threadPrefix + thread.getId()); + thread.setName(PREFIX + threadPrefix + thread.threadId()); return thread; } } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java index aefd23e661a..337f1c8fe89 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Project.java @@ -195,7 +195,7 @@ public String getId() { * @return tab size if set, 0 otherwise * @see #hasTabSizeSetting() */ - public int getTabSize() { + public final int getTabSize() { return tabSize; } @@ -233,7 +233,7 @@ public void setIndexed(boolean flag) { * * @param tabSize the size of tabs in this project */ - public void setTabSize(int tabSize) { + public final void setTabSize(int tabSize) { this.tabSize = tabSize; } @@ -262,7 +262,7 @@ public boolean isNavigateWindowEnabled() { * * @param navigateWindowEnabled new value of navigateWindowEnabled */ - public void setNavigateWindowEnabled(boolean navigateWindowEnabled) { + public final void setNavigateWindowEnabled(boolean navigateWindowEnabled) { this.navigateWindowEnabled = navigateWindowEnabled; } @@ -283,7 +283,7 @@ public boolean isMergeCommitsEnabled() { /** * @param flag true if project should handle renamed files, false otherwise. */ - public void setHandleRenamedFiles(boolean flag) { + public final void setHandleRenamedFiles(boolean flag) { this.handleRenamedFiles = flag; } @@ -297,7 +297,7 @@ public boolean isHistoryEnabled() { /** * @param flag true if project should have history cache, false otherwise. */ - public void setHistoryEnabled(boolean flag) { + public final void setHistoryEnabled(boolean flag) { this.historyEnabled = flag; } @@ -311,14 +311,14 @@ public boolean isAnnotationCacheEnabled() { /** * @param flag true if project should have annotation cache, false otherwise. */ - public void setAnnotationCacheEnabled(boolean flag) { + public final void setAnnotationCacheEnabled(boolean flag) { this.annotationCacheEnabled = flag; } /** * @param flag true if project's repositories should deal with merge commits. */ - public void setMergeCommitsEnabled(boolean flag) { + public final void setMergeCommitsEnabled(boolean flag) { this.mergeCommitsEnabled = flag; } @@ -332,7 +332,7 @@ public boolean isHistoryBasedReindex() { /** * @param flag true if project should handle renamed files, false otherwise. */ - public void setHistoryBasedReindex(boolean flag) { + public final void setHistoryBasedReindex(boolean flag) { this.historyBasedReindex = flag; } @@ -400,7 +400,7 @@ public void addGroup(Group group) { } } - public void setBugPage(String bugPage) { + public final void setBugPage(String bugPage) { this.bugPage = bugPage; } @@ -420,7 +420,7 @@ public String getBugPage() { * does not contain at least one capture group and the group does not * contain a single character */ - public void setBugPattern(String bugPattern) throws PatternSyntaxException { + public final void setBugPattern(String bugPattern) throws PatternSyntaxException { this.bugPattern = compilePattern(bugPattern); } @@ -440,7 +440,7 @@ public String getReviewPage() { } } - public void setReviewPage(String reviewPage) { + public final void setReviewPage(String reviewPage) { this.reviewPage = reviewPage; } @@ -460,7 +460,7 @@ public String getReviewPattern() { * does not contain at least one capture group and the group does not * contain a single character */ - public void setReviewPattern(String reviewPattern) throws PatternSyntaxException { + public final void setReviewPattern(String reviewPattern) throws PatternSyntaxException { this.reviewPattern = compilePattern(reviewPattern); } @@ -469,7 +469,7 @@ public void setReviewPattern(String reviewPattern) throws PatternSyntaxException * project property has a default value. */ public final void completeWithDefaults() { - Configuration defaultCfg = new Configuration(); + final Configuration defaultCfg = new Configuration(); final RuntimeEnvironment env = RuntimeEnvironment.getInstance(); /* diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/SuggesterConfig.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/SuggesterConfig.java index 359305b3bc1..51d92535141 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/SuggesterConfig.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/SuggesterConfig.java @@ -36,7 +36,7 @@ /** * The suggester specific configuration. */ -public class SuggesterConfig { +public final class SuggesterConfig { public static final boolean ENABLED_DEFAULT = true; public static final int MAX_RESULTS_DEFAULT = 10; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/framework/PluginFramework.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/framework/PluginFramework.java index 03e556d818b..8509de577e9 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/framework/PluginFramework.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/framework/PluginFramework.java @@ -97,7 +97,7 @@ public synchronized File getPluginDirectory() { * * @param pluginDirectory the directory */ - public synchronized void setPluginDirectory(File pluginDirectory) { + public final synchronized void setPluginDirectory(File pluginDirectory) { this.pluginDirectory = pluginDirectory; } @@ -106,7 +106,7 @@ public synchronized void setPluginDirectory(File pluginDirectory) { * * @param directory the directory path */ - public synchronized void setPluginDirectory(String directory) { + public final synchronized void setPluginDirectory(String directory) { setPluginDirectory(directory != null ? new File(directory) : null); } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AccuRevRepository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AccuRevRepository.java index 7f024d00e2f..0e28981c09f 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AccuRevRepository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AccuRevRepository.java @@ -96,6 +96,7 @@ public class AccuRevRepository extends Repository { */ private static final String DEPOT_ROOT = String.format("%s.%s", File.separator, File.separator); + @SuppressWarnings("this-escape") public AccuRevRepository() { type = "AccuRev"; datePatterns = new String[]{ diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Annotation.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Annotation.java index afa7e27cfe3..d28eb77919e 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Annotation.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Annotation.java @@ -47,7 +47,7 @@ * Class representing file annotation, i.e., revision and author for the last * modification of each line in the file. */ -public class Annotation { +public final class Annotation { private static final Logger LOGGER = LoggerFactory.getLogger(Annotation.class); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationData.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationData.java index e8b4c90ddb5..63d367313e6 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationData.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/AnnotationData.java @@ -52,6 +52,7 @@ public AnnotationData(String filename) { this.filename = filename; } + @SuppressWarnings("serial") private List annotationLines = new ArrayList<>(); private int widestRevision; private int widestAuthor; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/BitKeeperRepository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/BitKeeperRepository.java index e3145f9e94b..eebb1090b1d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/BitKeeperRepository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/BitKeeperRepository.java @@ -88,6 +88,7 @@ public class BitKeeperRepository extends Repository { /** * The version of the BitKeeper executable. This affects the correct dspec to use for tags. */ + @SuppressWarnings("serial") private Version version = null; /** diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/CVSRepository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/CVSRepository.java index f68f68d47a7..dd87ddaf3be 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/CVSRepository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/CVSRepository.java @@ -58,6 +58,7 @@ public class CVSRepository extends RCSRepository { */ public static final String CMD_FALLBACK = "cvs"; + @SuppressWarnings("this-escape") public CVSRepository() { /* * This variable is set in the ancestor to TRUE which has a side effect diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/History.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/History.java index dca8d97aa81..457fa509000 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/History.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/History.java @@ -46,19 +46,23 @@ public class History implements Serializable { static final String TAGS_SEPARATOR = ", "; /** Entries in the log. The first entry is the most recent one. */ + @SuppressWarnings("serial") private List entries; /** * Track renamed files, so they can be treated in special way (for some SCMs) during cache creation. * These are relative to repository root. */ + @SuppressWarnings("serial") private final Set renamedFiles; /** * Revision of the newest change. Used in history cache. */ + @SuppressWarnings("serial") private String latestRev; // revision to tag list. Individual tags are joined via TAGS_SEPARATOR. + @SuppressWarnings("serial") private Map tags = new HashMap<>(); public History() { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java index f91def5e692..f81bac58fe7 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryEntry.java @@ -57,6 +57,7 @@ public class HistoryEntry implements Serializable { private boolean active; @JsonIgnore + @SuppressWarnings("serial") private SortedSet files; /** Creates a new instance of HistoryEntry. */ diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepoRepository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepoRepository.java index 90a23f66905..d44c26125ca 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepoRepository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepoRepository.java @@ -48,6 +48,7 @@ public class RepoRepository extends Repository { */ public static final String CMD_FALLBACK = "repo"; + @SuppressWarnings("this-escape") public RepoRepository() { type = "repo"; setWorking(Boolean.TRUE); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java index f7584add142..5ad698eb94f 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/Repository.java @@ -78,14 +78,17 @@ public abstract class Repository extends RepositoryInfo { */ protected String RepoCommand; + @SuppressWarnings("serial") protected final List ignoredFiles; + @SuppressWarnings("serial") protected final List ignoredDirs; /** * List of <revision, tags> pairs for repositories which display tags * only for files changed by the tagged commit. */ + @SuppressWarnings("serial") protected NavigableSet tagList = null; abstract boolean fileHasHistory(File file); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SSCMRepository.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SSCMRepository.java index 7ef1692b5d8..e1b6b4aacfa 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SSCMRepository.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/history/SSCMRepository.java @@ -70,6 +70,7 @@ public class SSCMRepository extends Repository { private static final String BRANCH_PROPERTY = "SCMBranch"; private static final String REPOSITORY_PROPERTY = "SCMRepository"; + @SuppressWarnings("this-escape") public SSCMRepository() { setType("SSCM"); setRemote(true); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java index e180f4bae7a..4980c5be902 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings.java @@ -69,6 +69,7 @@ public final class IndexAnalysisSettings implements Serializable { * de-serialization circumvents normal construction. * @serial */ + @SuppressWarnings("serial") private Map analyzersVersions = new HashMap<>(); /** diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings3.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings3.java index be88b724362..3b2df2ac7f1 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings3.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettings3.java @@ -69,6 +69,7 @@ public final class IndexAnalysisSettings3 implements Serializable { * de-serialization circumvents normal construction. * @serial */ + @SuppressWarnings("serial") private Map analyzersVersions = new HashMap<>(); /** @@ -78,6 +79,7 @@ public final class IndexAnalysisSettings3 implements Serializable { * anything but a simple {@link HashMap} here. * @serial */ + @SuppressWarnings("serial") private Map indexedSymlinks = new HashMap<>(); /** diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettingsAccessor.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettingsAccessor.java index 047263c972c..f4e73f35328 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettingsAccessor.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexAnalysisSettingsAccessor.java @@ -89,7 +89,7 @@ public IndexAnalysisSettings3[] read(IndexReader reader, int n) throws IOExcepti } TopDocs top = searcher.search(q, n); - int nres = top.totalHits.value > n ? n : (int) top.totalHits.value; + int nres = top.totalHits.value() > n ? n : (int) top.totalHits.value(); IndexAnalysisSettings3[] res = new IndexAnalysisSettings3[nres]; IndexAnalysisSettingsUpgrader upgrader = new IndexAnalysisSettingsUpgrader(); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexCheckException.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexCheckException.java index 8955ddf4f4c..6d46d519d26 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexCheckException.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexCheckException.java @@ -33,6 +33,7 @@ public class IndexCheckException extends Exception { private static final long serialVersionUID = 5693446916108385595L; + @SuppressWarnings("serial") private final Set failedPaths = new HashSet<>(); public IndexCheckException(String message, Path path) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java index 300ecf71540..edab3af16b7 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDatabase.java @@ -2153,8 +2153,8 @@ public static Document getDocument(File file) throws ParseException, IOException TopDocs top = searcher.search(q, 1); stat.report(LOGGER, Level.FINEST, String.format("search via getDocument(%s) done", file), "search.latency", new String[]{"category", "getdocument", - "outcome", top.totalHits.value == 0 ? "empty" : "success"}); - if (top.totalHits.value == 0) { + "outcome", top.totalHits.value() == 0 ? "empty" : "success"}); + if (top.totalHits.value() == 0) { // No hits, no document... return null; } @@ -2247,7 +2247,7 @@ private CountingWriter newXrefWriter(String path, File transientXref, boolean co new FileOutputStream(transientXref)))); } - LockFactory pickLockFactory(RuntimeEnvironment env) { + private LockFactory pickLockFactory(RuntimeEnvironment env) { switch (env.getLuceneLocking()) { case ON: case SIMPLE: diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDocumentException.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDocumentException.java index a36a9dca1a6..5d3505dffc8 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDocumentException.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/IndexDocumentException.java @@ -32,7 +32,9 @@ public class IndexDocumentException extends IndexCheckException { private static final long serialVersionUID = -277429315137557112L; + @SuppressWarnings("serial") private final Map duplicatePathMap; + @SuppressWarnings("serial") private final Set missingPaths; public IndexDocumentException(String s, Path path) { diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/NumLinesLOCAccessor.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/NumLinesLOCAccessor.java index 91cf2583fec..4427708b628 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/index/NumLinesLOCAccessor.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/index/NumLinesLOCAccessor.java @@ -65,7 +65,7 @@ class NumLinesLOCAccessor { */ public boolean hasStored(IndexReader reader) throws IOException { DSearchResult searchResult = newDSearch(reader, 1); - return searchResult.hits.totalHits.value > 0; + return searchResult.hits.totalHits.value() > 0; } /** @@ -121,8 +121,8 @@ private void storeBulk(IndexWriter writer, IndexReader reader, // Index the existing document IDs by QueryBuilder.D. HashMap byDir = new HashMap<>(); - int intMaximum = Integer.MAX_VALUE < searchResult.hits.totalHits.value ? - Integer.MAX_VALUE : (int) searchResult.hits.totalHits.value; + int intMaximum = Integer.MAX_VALUE < searchResult.hits.totalHits.value() ? + Integer.MAX_VALUE : (int) searchResult.hits.totalHits.value(); StoredFields storedFields = searchResult.searcher.storedFields(); for (int i = 0; i < intMaximum; ++i) { int docID = searchResult.hits.scoreDocs[i].doc; @@ -148,7 +148,7 @@ private void storeIterative(IndexWriter writer, IndexReader reader, TopDocs hits = searcher.search(query, 1); Integer docID = null; - if (hits.totalHits.value > 0) { + if (hits.totalHits.value() > 0) { docID = hits.scoreDocs[0].doc; } updateDocumentData(writer, searcher, entry, docID, isAggregatingDeltas); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/CustomQueryParser.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/CustomQueryParser.java index 37765543b7f..25ab9312fbb 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/CustomQueryParser.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/CustomQueryParser.java @@ -40,6 +40,7 @@ public class CustomQueryParser extends QueryParser { * * @param field default field for unqualified query terms */ + @SuppressWarnings("this-escape") public CustomQueryParser(String field) { super(field, new CompatibleAnalyser()); setDefaultOperator(AND_OPERATOR); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java index 494d158694e..0a00e74829a 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/QueryBuilder.java @@ -502,7 +502,7 @@ protected Query buildQuery(String field, String queryText) */ private boolean hasClause(BooleanQuery query, Occur occur) { for (BooleanClause clause : query) { - if (clause.getOccur().equals(occur)) { + if (clause.occur().equals(occur)) { return true; } } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Summarizer.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Summarizer.java index 7abf9d496e9..2859c2ad573 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Summarizer.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/Summarizer.java @@ -330,7 +330,7 @@ private void getTerms(Query query) { private void getBooleans(BooleanQuery query) { for (BooleanClause clause : query) { if (!clause.isProhibited()) { - getTerms(clause.getQuery()); + getTerms(clause.query()); } } } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java index 92a7f897fcc..3ee37779527 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/OGKUnifiedHighlighter.java @@ -247,7 +247,7 @@ protected List loadFieldValues(String[] fields, protected OffsetSource getOptimizedOffsetSource(UHComponents components) { OffsetSource res = super.getOptimizedOffsetSource(components); - String field = components.getField(); + String field = components.field(); if (res == OffsetSource.ANALYSIS) { /* Testing showed that UnifiedHighlighter falls back to diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PrefixMatcher.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PrefixMatcher.java index 7d321994390..e05c0b344c5 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PrefixMatcher.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/PrefixMatcher.java @@ -28,6 +28,7 @@ public class PrefixMatcher extends LineMatcher { private final String prefix; + @SuppressWarnings("this-escape") public PrefixMatcher(String prefix, boolean caseInsensitive) { super(caseInsensitive); this.prefix = normalizeString(prefix); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/QueryMatchers.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/QueryMatchers.java index b8c4f15a727..b8d8ca8bc48 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/QueryMatchers.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/QueryMatchers.java @@ -105,7 +105,7 @@ private void getRegexp(RegexpQuery query) { private void getBooleans(BooleanQuery query) { for (BooleanClause clause : query) { if (!clause.isProhibited()) { - getTerms(clause.getQuery()); + getTerms(clause.query()); } } } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/TokenSetMatcher.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/TokenSetMatcher.java index 01c261dedad..99ed813ff4d 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/TokenSetMatcher.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/TokenSetMatcher.java @@ -28,6 +28,7 @@ public class TokenSetMatcher extends LineMatcher { private final Set tokenSet; + @SuppressWarnings("this-escape") public TokenSetMatcher(Set tokenSet, boolean caseInsensitive) { super(caseInsensitive); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/WildCardMatcher.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/WildCardMatcher.java index 8ce5f2d4e98..eafc8c8760f 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/WildCardMatcher.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/search/context/WildCardMatcher.java @@ -29,6 +29,7 @@ public class WildCardMatcher extends LineMatcher { final String pattern; + @SuppressWarnings("this-escape") public WildCardMatcher(String pattern, boolean caseInsensitive) { super(caseInsensitive); this.pattern = normalizeString(pattern); diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Executor.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Executor.java index 773c1ecc18d..0c30b6430c2 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Executor.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Executor.java @@ -412,7 +412,7 @@ public static void registerErrorHandler() { LOGGER.log(Level.FINE, "Installing default uncaught exception handler"); Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.log(Level.SEVERE, String.format("Uncaught exception in thread %s with ID %d: %s", - t.getName(), t.getId(), e.getMessage()), e)); + t.getName(), t.threadId(), e.getMessage()), e)); } } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Progress.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Progress.java index 63fe5713d40..a517ad54a39 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Progress.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/util/Progress.java @@ -43,7 +43,7 @@ * the higher log level ({@link Level} value) will be used. The default base level is {@code Level.INFO}. * Regardless of the base level, maximum 4 log levels will be used. */ -public class Progress implements AutoCloseable { +public final class Progress implements AutoCloseable { private final Logger logger; private final Long totalCount; private final String suffix; diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java index f8177ef2d62..be6c8d2da2e 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/SearchHelper.java @@ -476,7 +476,7 @@ public SearchHelper executeQuery() { } try { TopFieldDocs fdocs = searcher.search(query, start + maxItems, sort); - totalHits = fdocs.totalHits.value; + totalHits = fdocs.totalHits.value(); hits = fdocs.scoreDocs; /* @@ -743,7 +743,7 @@ public int searchSingle(File file) throws IOException, query = singleBuilder.setPath(path).build(); TopDocs top = searcher.search(query, 1); - if (top.totalHits.value == 0) { + if (top.totalHits.value() == 0) { return -1; } diff --git a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java index 877e62241a2..baa6e5c94b9 100644 --- a/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java +++ b/opengrok-indexer/src/main/java/org/opengrok/indexer/web/Util.java @@ -680,10 +680,7 @@ public static void encode(String s, Appendable dest) throws IOException { * @throws MalformedURLException URL malformed */ public static String encodeURL(String urlStr) throws URISyntaxException, MalformedURLException { - URL url = new URL(urlStr); - URI constructed = new URI(url.getProtocol(), url.getUserInfo(), - url.getHost(), url.getPort(), - url.getPath(), url.getQuery(), url.getRef()); + URI constructed = new URI(urlStr); return constructed.toString(); } @@ -1462,13 +1459,13 @@ private static String generatePageLink(int page, int offset, int limit, long siz * @return true if it is http URL, false otherwise */ public static boolean isHttpUri(String string) { - URL url; + URI uri; try { - url = new URL(string); - } catch (MalformedURLException ex) { + uri = new URI(string); + } catch (URISyntaxException e) { return false; } - return url.getProtocol().equals("http") || url.getProtocol().equals("https"); + return uri.getScheme().equals("http") || uri.getScheme().equals("https"); } protected static final String REDACTED_USER_INFO = "redacted_by_OpenGrok"; @@ -1481,8 +1478,8 @@ public static boolean isHttpUri(String string) { public static String redactUrl(String path) { URL url; try { - url = new URL(path); - } catch (MalformedURLException e) { + url = (new URI(path)).toURL(); + } catch (MalformedURLException | URISyntaxException e) { // not an URL return path; } diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/RestApp.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/RestApp.java index ba2a1a5aace..7d179a16cd1 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/RestApp.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/RestApp.java @@ -31,6 +31,7 @@ public class RestApp extends ResourceConfig { public static final String API_PATH = "api/v1"; + @SuppressWarnings("this-escape") public RestApp() { register(new SuggesterAppBinder()); packages("org.opengrok.web.api.constraints", "org.opengrok.web.api.error"); diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SuggesterController.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SuggesterController.java index 926be5d02b2..eef7ca8c503 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SuggesterController.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/SuggesterController.java @@ -63,7 +63,8 @@ import org.opengrok.web.api.v1.suggester.provider.service.SuggesterService; import java.net.MalformedURLException; -import java.net.URL; +import java.net.URI; +import java.net.URISyntaxException; import java.time.Duration; import java.time.Instant; import java.util.AbstractMap.SimpleEntry; @@ -197,8 +198,8 @@ public void rebuild(@PathParam("project") final String project) { public void addSearchCountsQueries(final List urls) { for (String urlStr : urls) { try { - var url = new URL(urlStr); - var params = Util.getQueryParams(url); + var uri = new URI(urlStr); + var params = Util.getQueryParams(uri.toURL()); var projects = params.get("project"); @@ -211,12 +212,10 @@ public void addSearchCountsQueries(final List urls) { } else { getQuery(field, fieldQueryText.get(0)) .ifPresent(q -> suggester.onSearch(projects, q)); - } } - } - } catch (MalformedURLException e) { + } catch (MalformedURLException | URISyntaxException e) { logger.log(Level.WARNING, e, () -> "Could not add search counts for " + urlStr); } } diff --git a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/query/SuggesterQueryParser.java b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/query/SuggesterQueryParser.java index c911393e17b..f585816e460 100644 --- a/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/query/SuggesterQueryParser.java +++ b/opengrok-web/src/main/java/org/opengrok/web/api/v1/suggester/query/SuggesterQueryParser.java @@ -134,10 +134,10 @@ protected Query getBooleanQuery(final List clauses) throws ParseE return super.getBooleanQuery(clauses); } var reducedList = clauses.stream() - .filter(booleanClause -> BooleanClause.Occur.SHOULD != booleanClause.getOccur()) + .filter(booleanClause -> BooleanClause.Occur.SHOULD != booleanClause.occur()) .collect(Collectors.toList()); inSuggesterClausesList.stream() - .filter(booleanClause -> BooleanClause.Occur.SHOULD == booleanClause.getOccur()) + .filter(booleanClause -> BooleanClause.Occur.SHOULD == booleanClause.occur()) .forEach(reducedList::add); return super.getBooleanQuery(reducedList); } @@ -145,7 +145,7 @@ protected Query getBooleanQuery(final List clauses) throws ParseE private boolean isInSuggesterClauses(BooleanClause clause) { return suggesterClauses.stream() .anyMatch(itemClause -> - clause.getQuery().equals(itemClause.getQuery()) + clause.query().equals(itemClause.query()) ); } diff --git a/plugins/src/main/java/opengrok/auth/entity/LdapUser.java b/plugins/src/main/java/opengrok/auth/entity/LdapUser.java index f67dbcf738b..37d9060c251 100644 --- a/plugins/src/main/java/opengrok/auth/entity/LdapUser.java +++ b/plugins/src/main/java/opengrok/auth/entity/LdapUser.java @@ -36,6 +36,7 @@ public class LdapUser implements Serializable { private String dn; // Distinguished Name + @SuppressWarnings("serial") private final Map> attributes; private static final long serialVersionUID = 1L; diff --git a/plugins/src/main/java/opengrok/auth/plugin/configuration/Configuration.java b/plugins/src/main/java/opengrok/auth/plugin/configuration/Configuration.java index 901fba81c3d..628b40b1cec 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/configuration/Configuration.java +++ b/plugins/src/main/java/opengrok/auth/plugin/configuration/Configuration.java @@ -46,6 +46,7 @@ public class Configuration implements Serializable { private static final long serialVersionUID = -1; + @SuppressWarnings("serial") private List servers = new ArrayList<>(); private int interval; private String searchBase; diff --git a/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java b/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java index ba6d619be8f..0f0643ea380 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java +++ b/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapFacade.java @@ -176,6 +176,7 @@ private void addAttrToMap(Map> map, Attribute attr) throws N } } + @SuppressWarnings("this-escape") public LdapFacade(Configuration cfg) { setServers(cfg.getServers(), cfg.getConnectTimeout(), cfg.getReadTimeout()); setInterval(cfg.getInterval()); diff --git a/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapServer.java b/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapServer.java index fd6ae37f740..87b7c304f73 100644 --- a/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapServer.java +++ b/plugins/src/main/java/opengrok/auth/plugin/ldap/LdapServer.java @@ -66,6 +66,7 @@ public class LdapServer implements Serializable { private int readTimeout; private int interval = 10 * 1000; + @SuppressWarnings("serial") private final Map env; private transient LdapContext ctx; private long errorTimestamp = 0; @@ -74,11 +75,13 @@ public LdapServer() { this(prepareEnv()); } + @SuppressWarnings("this-escape") public LdapServer(String server) { this(prepareEnv()); setName(server); } + @SuppressWarnings("this-escape") public LdapServer(String server, String username, String password) { this(prepareEnv()); setName(server); diff --git a/pom.xml b/pom.xml index 9406a2909d9..7dcc75181b6 100644 --- a/pom.xml +++ b/pom.xml @@ -60,9 +60,9 @@ Portions Copyright (c) 2018, 2020, Chris Fraire . - 9.12.0 + 10.0.0 3.6.0 - 11 + 21 UTF-8 3.1.3