protected static long getTaskTimeout(ParseContext parseContext) {

        TikaTaskTimeout tikaTaskTimeout = parseContext.get(TikaTaskTimeout.class);
        long timeoutMillis = TIKA_SERVER_CONFIG.getTaskTimeoutMillis();

        if (tikaTaskTimeout != null) {
            if (tikaTaskTimeout.getTimeoutMillis() > TIKA_SERVER_CONFIG.getTaskTimeoutMillis()) {
                throw new IllegalArgumentException(
                        "Can't request a timeout ( " + tikaTaskTimeout.getTimeoutMillis() + "ms) greater than the taskTimeoutMillis set in the server config (" +
                                TIKA_SERVER_CONFIG.getTaskTimeoutMillis() + "ms)");
            }
            timeoutMillis = tikaTaskTimeout.getTimeoutMillis();
            if (timeoutMillis < TIKA_SERVER_CONFIG.getMinimumTimeoutMillis()) {
                throw new WebApplicationException(new IllegalArgumentException(
                        "taskTimeoutMillis must be > " + "minimumTimeoutMillis, currently set to (" + TIKA_SERVER_CONFIG.getMinimumTimeoutMillis() + "ms)"),
                        Response.Status.BAD_REQUEST);
            }
        }
        return timeoutMillis;
    }
Use this to call a parser and unify exception handling.
NOTE: This call to parse closes the InputStream. DO NOT surround
the call in an auto-close block.

@param parser       parser to use
@param logger       logger to use
@param path         file path
@param inputStream  inputStream (which is closed by this call!)
@param handler      handler to use
@param metadata     metadata
@param parseContext parse context
@throws IOException wrapper for all exceptions
tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/resource/TikaResource.java