Package org.apache.iceberg.io
Class CloseableGroup
java.lang.Object
org.apache.iceberg.io.CloseableGroup
- All Implemented Interfaces:
- Closeable,- AutoCloseable
- Direct Known Subclasses:
- ArrowReader,- AvroIterable,- CloseableIterable.ConcatCloseableIterable,- ManifestReader,- ParallelIterable,- ParquetIterable,- ParquetReader,- SortedMerge,- VectorizedParquetReader,- VectorizedTableScanIterable
This class acts as a helper for handling the closure of multiple resource. It can be used for
 either inheritance or composition. To use it, register resources to be closed via the add()
 calls, and call the corresponding close method when needed.
 
It can take both closeable and autocloseable objects, and handle closeable as autocloseable and guarantee close idempotency by ensuring that each resource will be closed once even with concurrent close calls. It will also wrap checked non-IO exceptions into runtime exceptions.
Users can choose to suppress close failure with this class. By default such failures are not suppressed.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddCloseable(Closeable closeable) Register a closeable to be managed by this class.voidaddCloseable(AutoCloseable autoCloseable) Register an autocloseables to be managed by this class.voidclose()Close all the registered resources.voidsetSuppressCloseFailure(boolean shouldSuppress) Whether to suppress failure when any of the closeable this class tracks throws exception during closing.
- 
Constructor Details- 
CloseableGrouppublic CloseableGroup()
 
- 
- 
Method Details- 
addCloseableRegister a closeable to be managed by this class.
- 
addCloseableRegister an autocloseables to be managed by this class. It will be handled as a closeable object.
- 
setSuppressCloseFailurepublic void setSuppressCloseFailure(boolean shouldSuppress) Whether to suppress failure when any of the closeable this class tracks throws exception during closing. This could be helpful to ensure the close method of all resources to be called.- Parameters:
- shouldSuppress- true if user wants to suppress close failures
 
- 
closeClose all the registered resources. Close method of each resource will only be called once. Checked exception from AutoCloseable will be wrapped to runtime exception.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Throws:
- IOException
 
 
-