Lucene.Net.Index.StandardDirectoryReader.DoClose C# (CSharp) Method

DoClose() protected method

protected DoClose ( ) : void
return void
        protected internal override void DoClose()
        {
            Exception firstExc = null;
            foreach (AtomicReader r in GetSequentialSubReaders())
            {
                // try to close each reader, even if an exception is thrown
                try
                {
                    r.DecRef();
                }
                catch (Exception t)
                {
                    if (firstExc == null)
                    {
                        firstExc = t;
                    }
                }
            }

            if (Writer != null)
            {
                try
                {
                    Writer.DecRefDeleter(SegmentInfos);
                }
                catch (AlreadyClosedException ex)
                {
                    // this is OK, it just means our original writer was
                    // closed before we were, and this may leave some
                    // un-referenced files in the index, which is
                    // harmless.  The next time IW is opened on the
                    // index, it will delete them.
                }
            }

            // throw the first exception
            IOUtils.ReThrow(firstExc);
        }