This is an automated email from the ASF dual-hosted git repository. orpiske pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new 1b0f4d5 (chores) camel-lucene: code cleanups 1b0f4d5 is described below commit 1b0f4d5071a3f5049cde031e5cc5891192d60934 Author: Otavio Rodolfo Piske <opi...@redhat.com> AuthorDate: Tue Jan 11 16:24:17 2022 +0100 (chores) camel-lucene: code cleanups - removed unused exceptions - do not use hard-coded path separators - decreased scope of member variable - removed unused totalHitsThreshold parameter in the query processor constructor --- .../org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java | 3 +-- .../java/org/apache/camel/component/lucene/LuceneConfiguration.java | 4 ++-- .../main/java/org/apache/camel/component/lucene/LuceneIndexer.java | 3 +-- .../java/org/apache/camel/processor/lucene/LuceneQueryProcessor.java | 3 +-- .../org/apache/camel/processor/lucene/LuceneQueryProcessorIT.java | 4 ++-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/catalog/camel-catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java b/catalog/camel-catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java index 06911ad..284ed21b 100644 --- a/catalog/camel-catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java +++ b/catalog/camel-catalog-lucene/src/main/java/org/apache/camel/catalog/lucene/LuceneSuggestionStrategy.java @@ -34,7 +34,6 @@ import org.apache.lucene.store.ByteBuffersDirectory; public class LuceneSuggestionStrategy implements SuggestionStrategy { private int maxSuggestions = 3; - private SpellChecker checker; @Override public String[] suggestEndpointOptions(Set<String> names, String unknownOption) { @@ -51,7 +50,7 @@ public class LuceneSuggestionStrategy implements SuggestionStrategy { // use in-memory lucene spell checker to make the suggestions try (ByteBuffersDirectory dir = new ByteBuffersDirectory()) { - checker = new SpellChecker(dir); + SpellChecker checker = new SpellChecker(dir); checker.indexDictionary(words, new IndexWriterConfig(new KeywordAnalyzer()), false); return checker.suggestSimilar(unknownOption, maxSuggestions); diff --git a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneConfiguration.java b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneConfiguration.java index 2ac55fa..74aec33 100644 --- a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneConfiguration.java +++ b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneConfiguration.java @@ -87,7 +87,7 @@ public class LuceneConfiguration { setMaxHits(component.getAndRemoveParameter(parameters, "maxHits", Integer.class, 10)); } - private boolean isValidAuthority() throws URISyntaxException { + private boolean isValidAuthority() { if (!authority.contains(":") || authority.split(":")[0] == null || insertOrQueryCheck()) { return false; } @@ -100,7 +100,7 @@ public class LuceneConfiguration { && !authority.split(":")[1].equalsIgnoreCase("query"); } - private String retrieveTokenFromAuthority(String token) throws URISyntaxException { + private String retrieveTokenFromAuthority(String token) { String retval; if (token.equalsIgnoreCase("hostname")) { diff --git a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java index 9e5e14d..3d41fb6 100644 --- a/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java +++ b/components/camel-lucene/src/main/java/org/apache/camel/component/lucene/LuceneIndexer.java @@ -127,7 +127,7 @@ public class LuceneIndexer { if (files != null) { for (String child : files) { - add(new File(file.getAbsolutePath() + "/" + child)); + add(new File(file.getAbsolutePath(), child)); } } } else { @@ -167,7 +167,6 @@ public class LuceneIndexer { private static FieldType createFieldType(boolean tokenized) { FieldType answer = new FieldType(); - //answer.setIndexed(true); answer.setStored(true); answer.setTokenized(tokenized); diff --git a/components/camel-lucene/src/main/java/org/apache/camel/processor/lucene/LuceneQueryProcessor.java b/components/camel-lucene/src/main/java/org/apache/camel/processor/lucene/LuceneQueryProcessor.java index c6b709c..8caae9f 100644 --- a/components/camel-lucene/src/main/java/org/apache/camel/processor/lucene/LuceneQueryProcessor.java +++ b/components/camel-lucene/src/main/java/org/apache/camel/processor/lucene/LuceneQueryProcessor.java @@ -34,8 +34,7 @@ public class LuceneQueryProcessor implements Processor { private int maxNumberOfHits; private int totalHitsThreshold; - public LuceneQueryProcessor(String indexDirectoryPath, Analyzer analyzer, String defaultSearchPhrase, int maxNumberOfHits, - int totalHitsThreshold) { + public LuceneQueryProcessor(String indexDirectoryPath, Analyzer analyzer, String defaultSearchPhrase, int maxNumberOfHits) { this.setAnalyzer(analyzer); this.setIndexDirectory(new File(indexDirectoryPath)); this.setSearchPhrase(defaultSearchPhrase); diff --git a/components/camel-lucene/src/test/java/org/apache/camel/processor/lucene/LuceneQueryProcessorIT.java b/components/camel-lucene/src/test/java/org/apache/camel/processor/lucene/LuceneQueryProcessorIT.java index dc7c209..34e897d 100644 --- a/components/camel-lucene/src/test/java/org/apache/camel/processor/lucene/LuceneQueryProcessorIT.java +++ b/components/camel-lucene/src/test/java/org/apache/camel/processor/lucene/LuceneQueryProcessorIT.java @@ -60,7 +60,7 @@ public class LuceneQueryProcessorIT extends CamelTestSupport { try { from("direct:start").setHeader("QUERY", constant("Rodney Dangerfield")) - .process(new LuceneQueryProcessor("target/stdindexDir", analyzer, null, 20, 20)).to("direct:next"); + .process(new LuceneQueryProcessor("target/stdindexDir", analyzer, null, 20)).to("direct:next"); } catch (Exception e) { LOG.warn("Unhandled exception: {}", e.getMessage(), e); } @@ -102,7 +102,7 @@ public class LuceneQueryProcessorIT extends CamelTestSupport { try { from("direct:start").setHeader("QUERY", constant("Carl*")) - .process(new LuceneQueryProcessor("target/simpleindexDir", analyzer, null, 20, 20)) + .process(new LuceneQueryProcessor("target/simpleindexDir", analyzer, null, 20)) .to("direct:next"); } catch (Exception e) { LOG.warn("Unhandled exception: {}", e.getMessage(), e);