Package org.apache.axiom.util.stax.debug

# Class UnclosedReaderDetector

java.lang.Object
javax.xml.stream.XMLInputFactory
org.apache.axiom.util.stax.wrapper.XMLInputFactoryWrapper
org.apache.axiom.util.stax.wrapper.WrappingXMLInputFactory
org.apache.axiom.util.stax.debug.UnclosedReaderDetector

public class UnclosedReaderDetector extends WrappingXMLInputFactory
`XMLInputFactory` wrapper that enabled detection of unclosed stream readers. An unclosed reader will be detected when the `XMLStreamReader` instance is finalized by the virtual machine. When this happens, a warning message will be logged. The log message contains the stack trace of the instruction that created the reader.

Note that for this to work, the detector must compute the stack trace every time a reader is created. Since this may have a significant performance impact, the wrapper should only used during testing and debugging.

- ## Field Summary

  ### Fields inherited from class javax.xml.stream.XMLInputFactory

  `ALLOCATOR, IS_COALESCING, IS_NAMESPACE_AWARE, IS_REPLACING_ENTITY_REFERENCES, IS_SUPPORTING_EXTERNAL_ENTITIES, IS_VALIDATING, REPORTER, RESOLVER, SUPPORT_DTD`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `UnclosedReaderDetector(XMLInputFactory parent)`
  Constructor.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected XMLStreamReader`
  `wrap(XMLStreamReader reader)`
  Wrap a reader created from this factory.

  ### Methods inherited from class org.apache.axiom.util.stax.wrapper.WrappingXMLInputFactory

  `createFilteredReader, createFilteredReader, createXMLEventReader, createXMLEventReader, createXMLEventReader, createXMLEventReader, createXMLEventReader, createXMLEventReader, createXMLEventReader, createXMLStreamReader, createXMLStreamReader, createXMLStreamReader, createXMLStreamReader, createXMLStreamReader, createXMLStreamReader, wrap`

  ### Methods inherited from class org.apache.axiom.util.stax.wrapper.XMLInputFactoryWrapper

  `getEventAllocator, getProperty, getXMLReporter, getXMLResolver, isPropertySupported, setEventAllocator, setProperty, setXMLReporter, setXMLResolver`

  ### Methods inherited from class javax.xml.stream.XMLInputFactory

  `newDefaultFactory, newFactory, newFactory, newInstance, newInstance`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### UnclosedReaderDetector

    public UnclosedReaderDetector(XMLInputFactory parent)
    Constructor.
    Parameters:
      `parent` - the parent factory

- ## Method Details

  - ### wrap

    protected XMLStreamReader wrap(XMLStreamReader reader)
    Description copied from class: `WrappingXMLInputFactory`
    Wrap a reader created from this factory. Implementations should override this method if they which to wrap `XMLStreamReader` instances created from the factory. The default implementation simply returns the unwrapped reader.
    Overrides:
      `wrap` in class `WrappingXMLInputFactory`
    Parameters:
      `reader` - the reader to wrap
    Returns:
      the wrapped reader