@Override public void close() { if (source != null) { source.close(); } }
@Override public void close() { if (source != null) { source.close(); } }
@Override public void close() { iterator.close(); } };
@Override public void close() { iterator.close(); } };
@Override public void close() { its.close(); }
@Override public void close() { iterator.close(); }
@Override public void close() { source.close(); }
@Override public void close() { iterator.close(); }
@Override public void close() { source.close(); }
@Override public void close() { source.close(); }
@Override public void close() { source.close(); }
@Override public void close() { source.close(); }
private Set<IndexTreeMapping> toSet(AutoCloseableIterator<IndexTreeMapping> mappings) { try { return Sets.newHashSet(mappings); } finally { mappings.close(); } }
public @Test void testDiffTreeIteratorIsClosedOnPrematureFeatureIteratorClose() throws IOException { AutoCloseableIterator<DiffEntry> mockIt = mock(AutoCloseableIterator.class); when(mockIt.hasNext()).thenReturn(true); when(mockIt.next()).thenReturn(mock(DiffEntry.class)); doReturn(mockIt).when(difftree).call(); FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = builder.build(); // close the feature reader before being fully consumed featureReader.close(); Mockito.verify(mockIt, times(0)).hasNext(); Mockito.verify(mockIt, times(0)).next(); Mockito.verify(mockIt, times(1)).close(); }
public @Test void testDiffTreeIteratorIsClosedOnPrematureFeatureIteratorClose() throws IOException { AutoCloseableIterator<DiffEntry> mockIt = mock(AutoCloseableIterator.class); when(mockIt.hasNext()).thenReturn(true); when(mockIt.next()).thenReturn(mock(DiffEntry.class)); doReturn(mockIt).when(difftree).call(); FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = builder.build(); // close the feature reader before being fully consumed featureReader.close(); Mockito.verify(mockIt, times(0)).hasNext(); Mockito.verify(mockIt, times(0)).next(); Mockito.verify(mockIt, times(1)).close(); }