ExtractedTextCache { public void process(String name, Callable<Void> callable) throws Throwable { Callable<Void> callable2 = new Callable<Void>() { @Override public Void call() throws Exception { Thread t = Thread.currentThread(); String oldThreadName = t.getName(); t.setName(oldThreadName + ": " + name); try { return callable.call(); } finally { Thread.currentThread().setName(oldThreadName); } } }; try { if (EXTRACT_IN_CALLER_THREAD) { callable2.call(); } else { Future<Void> future = getExecutor().submit(callable2); future.get(extractionTimeoutMillis, TimeUnit.MILLISECONDS); } } catch (TimeoutException e) { timeoutCount++; throw e; } catch (ExecutionException e) { throw e.getCause(); } } ExtractedTextCache(long maxWeight, long expiryTimeInSecs);  ExtractedTextCache(long maxWeight, long expiryTimeInSecs, boolean alwaysUsePreExtractedCache,
                              File indexDir);  ExtractedTextCache(long maxWeight, long expiryTimeInSecs, boolean alwaysUsePreExtractedCache,
                              File indexDir, StatisticsProvider statisticsProvider); @Nullable String get(String nodePath, String propertyName, Blob blob, boolean reindexMode); void put(@NotNull Blob blob, @NotNull ExtractedText extractedText); void putTimeout(@NotNull Blob blob, @NotNull ExtractedText extractedText); void addStats(int count, long timeInMillis, long bytesRead, long textLength); StatisticsProvider getStatisticsProvider(); TextExtractionStatsMBean getStatsMBean(); @Nullable CacheStats getCacheStats(); void setExtractedTextProvider(PreExtractedTextProvider extractedTextProvider); PreExtractedTextProvider getExtractedTextProvider(); void resetCache(); boolean isAlwaysUsePreExtractedCache(); void close(); void process(String name, Callable<Void> callable); void setExtractionTimeoutMillis(int extractionTimeoutMillis);  }
@Test public void process() throws Throwable { ExtractedTextCache cache = new ExtractedTextCache(0, 0, false, null); try { cache.process("test", new Callable<Void>() { @Override public Void call() throws Exception { throw new OutOfMemoryError(); } }); fail(); } catch (OutOfMemoryError e) { } assertEquals(0, cache.getStatsMBean().getTimeoutCount()); cache.setExtractionTimeoutMillis(10); long time = System.currentTimeMillis(); try { cache.process("test", new Callable<Void>() { @Override public Void call() throws Exception { Thread.sleep(10000); return null; } }); fail(); } catch (TimeoutException e) { } time = System.currentTimeMillis() - time; assertTrue("" + time, time < 5000); assertEquals(1, cache.getStatsMBean().getTimeoutCount()); }