You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2022/05/06 06:36:57 UTC
[GitHub] [jackrabbit-oak] thomasmueller commented on a diff in pull request #561: OAK-9758 error out if tika dependencies are missing and improve loggi…
thomasmueller commented on code in PR #561:
URL: https://github.com/apache/jackrabbit-oak/pull/561#discussion_r866526453
##########
oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractor.java:
##########
@@ -270,22 +272,22 @@ public InputStream get() {
// not being present. This is equivalent to disabling
// selected media types in configuration, so we can simply
// ignore these errors.
- log.debug("Failed to extract text from a binary property: {}."
+ String format = "Failed to extract text from a binary property: {}."
+ " This often happens when some media types are disabled by configuration."
- + " The stack trace is included to flag some 'unintended' failures",
- path, e);
+ + " The stack trace is included to flag some 'unintended' failures";
+ log.warn(format, linkageErrorFound ? path : new Object[]{path, e});
parserErrorCount.incrementAndGet();
return ERROR_TEXT;
} catch (Throwable t) {
// Capture and report any other full text extraction problems.
// The special STOP exception is used for normal termination.
if (!handler.isWriteLimitReached(t)) {
parserErrorCount.incrementAndGet();
- parserError.debug("Failed to extract text from a binary property: "
- + path
+ String format = "Failed to extract text from a binary property: {}"
+ " This is a fairly common case, and nothing to"
+ " worry about. The stack trace is included to"
- + " help improve the text extraction feature.", t);
+ + " help improve the text extraction feature.";
+ parserError.warn(format, throwableErrorFound ? path : new Object[]{path, t});
Review Comment:
According to the message, this doesn't mean the jar is missing, but that extraction failed (e.g. due to corruption in the file itself). If true (do we have a test case for this?) then we could log with "info" level here, instead of warning.
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/run/cli/CommonOptions.java:
##########
@@ -55,6 +57,8 @@ public boolean isHelpRequested(){
return options.has(help);
}
+ public boolean isContinueMissingDep() { return options.has(continueMissingDep); }
Review Comment:
Please use newlines between { and }
##########
oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractor.java:
##########
@@ -270,22 +272,22 @@ public InputStream get() {
// not being present. This is equivalent to disabling
// selected media types in configuration, so we can simply
// ignore these errors.
- log.debug("Failed to extract text from a binary property: {}."
+ String format = "Failed to extract text from a binary property: {}."
+ " This often happens when some media types are disabled by configuration."
- + " The stack trace is included to flag some 'unintended' failures",
- path, e);
+ + " The stack trace is included to flag some 'unintended' failures";
+ log.warn(format, linkageErrorFound ? path : new Object[]{path, e});
parserErrorCount.incrementAndGet();
Review Comment:
Forgot to set linkageErrorFound = true
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/binary/FulltextBinaryTextExtractor.java:
##########
@@ -193,13 +196,14 @@ public Void call() throws Exception {
// Capture and report any other full text extraction problems.
// The special STOP exception is used for normal termination.
if (!handler.isWriteLimitReached(t)) {
- log.debug(
- "[{}] Failed to extract text from a binary property: {}."
+ String format = "[{}] Failed to extract text from a binary property: {}."
+ " This is a fairly common case, and nothing to"
+ " worry about. The stack trace is included to"
- + " help improve the text extraction feature.",
- getIndexName(), path, t);
+ + " help improve the text extraction feature.";
Review Comment:
Same as above
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/binary/FulltextBinaryTextExtractor.java:
##########
@@ -74,6 +74,8 @@ public class FulltextBinaryTextExtractor {
private final boolean reindex;
private Parser parser;
private TikaConfigHolder tikaConfig;
+ private boolean linkageErrorFound = false;
Review Comment:
No need to set to false.
##########
oak-run-commons/src/main/java/org/apache/jackrabbit/oak/run/cli/Options.java:
##########
@@ -80,6 +80,15 @@ public OptionSet parseAndConfigure(OptionParser parser, String[] args, boolean c
if (checkNonOptions) {
checkNonOptions();
}
+ CommonOptions commonOpts = getCommonOpts();
+ if (!commonOpts.isHelpRequested() && !commonOpts.isContinueMissingDep()) {
Review Comment:
I think it's strange (unexpected) to do the check in parseAndConfigure. I wouldn't expect this method to throw an exception.
##########
oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractor.java:
##########
@@ -79,6 +79,8 @@ class TextExtractor implements Closeable {
private boolean initialized;
private BinaryStats stats;
private boolean closed;
+ private boolean linkageErrorFound = false;
Review Comment:
There is no need to set them to false: they are false by default.
##########
oak-run/src/main/java/org/apache/jackrabbit/oak/plugins/tika/TextExtractor.java:
##########
@@ -270,22 +272,22 @@ public InputStream get() {
// not being present. This is equivalent to disabling
// selected media types in configuration, so we can simply
// ignore these errors.
- log.debug("Failed to extract text from a binary property: {}."
+ String format = "Failed to extract text from a binary property: {}."
+ " This often happens when some media types are disabled by configuration."
- + " The stack trace is included to flag some 'unintended' failures",
- path, e);
+ + " The stack trace is included to flag some 'unintended' failures";
+ log.warn(format, linkageErrorFound ? path : new Object[]{path, e});
parserErrorCount.incrementAndGet();
return ERROR_TEXT;
} catch (Throwable t) {
// Capture and report any other full text extraction problems.
// The special STOP exception is used for normal termination.
if (!handler.isWriteLimitReached(t)) {
parserErrorCount.incrementAndGet();
- parserError.debug("Failed to extract text from a binary property: "
- + path
+ String format = "Failed to extract text from a binary property: {}"
+ " This is a fairly common case, and nothing to"
+ " worry about. The stack trace is included to"
- + " help improve the text extraction feature.", t);
+ + " help improve the text extraction feature.";
+ parserError.warn(format, throwableErrorFound ? path : new Object[]{path, t});
return ERROR_TEXT;
Review Comment:
Forgot to set throwableErrorFound = true
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org