@Test void extractContentShouldPropagateRuntimeException() throws Exception { RuntimeException runtimeException = new RuntimeException("Any"); when(wrappedTextExtractor.extractContent(any(), any())) .thenThrow(runtimeException); assertThatThrownBy(() -> textExtractor.extractContent(INPUT_STREAM.get(), CONTENT_TYPE)) .isEqualTo(runtimeException); }
@Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { byte[] bytes = IOUtils.toByteArray(inputStream); String key = Hashing.sha256().hashBytes(bytes).toString(); try { return cache.get(key, () -> retrieveAndUpdateWeight(bytes, contentType)); } catch (ExecutionException | UncheckedExecutionException e) { throw unwrap(e); } }
CachingTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { byte[] bytes = IOUtils.toByteArray(inputStream); String key = Hashing.sha256().hashBytes(bytes).toString(); try { return cache.get(key, () -> retrieveAndUpdateWeight(bytes, contentType)); } catch (ExecutionException | UncheckedExecutionException e) { throw unwrap(e); } } }
CachingTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { byte[] bytes = IOUtils.toByteArray(inputStream); String key = Hashing.sha256().hashBytes(bytes).toString(); try { return cache.get(key, () -> retrieveAndUpdateWeight(bytes, contentType)); } catch (ExecutionException | UncheckedExecutionException e) { throw unwrap(e); } } CachingTextExtractor(TextExtractor underlying, Duration cacheEvictionPeriod, Long cacheWeightInBytes,
                                MetricFactory metricFactory, GaugeRegistry gaugeRegistry); }
CachingTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { byte[] bytes = IOUtils.toByteArray(inputStream); String key = Hashing.sha256().hashBytes(bytes).toString(); try { return cache.get(key, () -> retrieveAndUpdateWeight(bytes, contentType)); } catch (ExecutionException | UncheckedExecutionException e) { throw unwrap(e); } } CachingTextExtractor(TextExtractor underlying, Duration cacheEvictionPeriod, Long cacheWeightInBytes,
                                MetricFactory metricFactory, GaugeRegistry gaugeRegistry); void recordStats(GaugeRegistry gaugeRegistry); @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType); }
CachingTextExtractor implements TextExtractor { @Override public ParsedContent extractContent(InputStream inputStream, ContentType contentType) throws Exception { byte[] bytes = IOUtils.toByteArray(inputStream); String key = Hashing.sha256().hashBytes(bytes).toString(); try { return cache.get(key, () -> retrieveAndUpdateWeight(bytes, contentType)); } catch (ExecutionException | UncheckedExecutionException e) { throw unwrap(e); } } CachingTextExtractor(TextExtractor underlying, Duration cacheEvictionPeriod, Long cacheWeightInBytes,
                                MetricFactory metricFactory, GaugeRegistry gaugeRegistry); void recordStats(GaugeRegistry gaugeRegistry); @Override ParsedContent extractContent(InputStream inputStream, ContentType contentType);  }