コード例 #1
0
 private void EnsureOpen()
 {
     if (_closed)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this SearcherLifetimeManager instance is disposed.");
     }
 }
コード例 #2
0
 private void EnsureOpen()
 {
     if (closed)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexWriter is disposed.");
     }
 }
コード例 #3
0
 // LUCENENET specific - rather than using all of this exception catching nonsense
 // for control flow, we check whether we are disposed first.
 private void EnsureOpen()
 {
     if (buffers is null)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "Already disposed: " + this);
     }
 }
コード例 #4
0
 /// <summary>
 /// Throws <see cref="ObjectDisposedException"/> if this <see cref="Index.IndexReader"/> is disposed
 /// </summary>
 protected void EnsureOpen()
 {
     if (RefCount <= 0)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this TaxonomyReader is disposed.");
     }
 }
コード例 #5
0
ファイル: CompoundFileWriter.cs プロジェクト: YAFNET/YAFNET
 private void EnsureOpen()
 {
     if (closed)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "CFS Directory is already disposed.");
     }
 }
コード例 #6
0
 public override object Clone()
 {
     if (_input is null)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this TermVectorsReader is disposed.");
     }
     return(new SimpleTextTermVectorsReader(_offsets, (IndexInput)_input.Clone()));
 }
コード例 #7
0
 /// <summary>
 /// Sets the stored value.
 /// </summary>
 /// <param name="analyzer"> Analyzer </param>
 /// <param name="storedValue"> Value to store </param>
 /// <exception cref="ObjectDisposedException"> if the <see cref="Analyzer"/> is closed. </exception>
 protected internal static void SetStoredValue(Analyzer analyzer, object storedValue) // LUCENENET: CA1822: Mark members as static
 {
     if (analyzer.storedValue is null)
     {
         throw AlreadyClosedException.Create(analyzer.GetType().FullName, "this Analyzer is disposed.");
     }
     analyzer.storedValue.Value = storedValue;
 }
コード例 #8
0
 public override object Clone()
 {
     if (_input == null)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this FieldsReader is disposed.");
     }
     return(new SimpleTextStoredFieldsReader(_offsets, (IndexInput)_input.Clone(), _fieldInfos));
 }
コード例 #9
0
ファイル: ReplicationClient.cs プロジェクト: ywscr/lucenenet
        /// <summary>Throws <see cref="ObjectDisposedException"/> if the client has already been disposed.</summary>
        protected void EnsureOpen()
        {
            if (!disposed)
            {
                return;
            }

            throw AlreadyClosedException.Create(this.GetType().FullName, "this update client has already been disposed.");
        }
コード例 #10
0
            public override void Flush()
            {
                // LUCENENET specific: Guard to ensure we aren't disposed.
                if (!isOpen)
                {
                    throw AlreadyClosedException.Create(this.GetType().FullName, "This FSIndexOutput is disposed.");
                }

                file.Flush();
            }
コード例 #11
0
            public override void Seek(long pos)
            {
                // LUCENENET specific: Guard to ensure we aren't disposed.
                if (!isOpen)
                {
                    throw AlreadyClosedException.Create(this.GetType().FullName, "This FSIndexOutput is disposed.");
                }

                file.Seek(pos, SeekOrigin.Begin);
            }
コード例 #12
0
            /// <inheritdoc/>
            protected internal override void FlushBuffer(byte[] b, int offset, int size)
            {
                // LUCENENET specific: Guard to ensure we aren't disposed.
                if (!isOpen)
                {
                    throw AlreadyClosedException.Create(this.GetType().FullName, "This FSIndexOutput is disposed.");
                }

                crc.Update(b, offset, size);
                file.Write(b, offset, size);
            }
コード例 #13
0
            /// <inheritdoc/>
            public override void WriteBytes(byte[] b, int offset, int length)
            {
                // LUCENENET specific: Guard to ensure we aren't disposed.
                if (!isOpen)
                {
                    throw AlreadyClosedException.Create(this.GetType().FullName, "This FSIndexOutput is disposed.");
                }

                crc.Update(b, offset, length);
                file.Write(b, offset, length);
            }
コード例 #14
0
ファイル: IndexFileDeleter.cs プロジェクト: ywscr/lucenenet
 private void EnsureOpen()
 {
     if (writer == null)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexWriter is disposed.");
     }
     else
     {
         writer.EnsureOpen(false);
     }
 }
コード例 #15
0
        /// <summary>
        /// Ensure that replicator is still open, or throw <see cref="ObjectDisposedException"/> otherwise.
        /// </summary>
        /// <exception cref="ObjectDisposedException">This replicator has already been disposed.</exception>
        protected void EnsureOpen()
        {
            lock (padlock)
            {
                if (!disposed)
                {
                    return;
                }

                throw AlreadyClosedException.Create(this.GetType().FullName, "This replicator has already been disposed.");
            }
        }
コード例 #16
0
 protected internal void EnsureOpen()
 {
     if (refCount <= 0)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexReader is disposed.");
     }
     // the happens before rule on reading the refCount, which must be after the fake write,
     // ensures that we see the value:
     if (closedByChild)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexReader cannot be used anymore as one of its child readers was disposed.");
     }
 }
コード例 #17
0
        internal void IncRef()
        {
            int count;

            while ((count = @ref) > 0)
            {
                if (@ref.CompareAndSet(count, count + 1))
                {
                    return;
                }
            }
            throw AlreadyClosedException.Create(this.GetType().FullName, "SegmentCoreReaders is already disposed.");
        }
コード例 #18
0
        /// <summary>
        /// Ensure that replicator is still open, or throw <see cref="ObjectDisposedException"/> otherwise.
        /// </summary>
        /// <exception cref="ObjectDisposedException">This replicator has already been disposed.</exception>
        protected void EnsureOpen()
        {
            UninterruptableMonitor.Enter(syncLock);
            try
            {
                if (!disposed)
                {
                    return;
                }

                throw AlreadyClosedException.Create(this.GetType().FullName, "This replicator has already been disposed.");
            }
            finally
            {
                UninterruptableMonitor.Exit(syncLock);
            }
        }
コード例 #19
0
        /// <summary>
        /// Expert: decreases the <see cref="RefCount"/> of this <see cref="IndexReader"/>
        /// instance.  If the <see cref="RefCount"/> drops to 0, then this
        /// reader is disposed.  If an exception is hit, the <see cref="RefCount"/>
        /// is unchanged.
        /// </summary>
        /// <exception cref="IOException"> in case an <see cref="IOException"/> occurs in <see cref="DoClose()"/>
        /// </exception>
        /// <seealso cref="IncRef"/>
        public void DecRef()
        {
            // only check refcount here (don't call ensureOpen()), so we can
            // still close the reader if it was made invalid by a child:
            if (refCount <= 0)
            {
                throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexReader is disposed.");
            }

            int rc = refCount.DecrementAndGet();

            if (rc == 0)
            {
                closed = true;
                Exception throwable = null;
                try
                {
                    DoClose();
                }
                catch (Exception th) when(th.IsThrowable())
                {
                    throwable = th;
                }
                finally
                {
                    try
                    {
                        ReportCloseToParentReaders();
                    }
                    finally
                    {
                        NotifyReaderClosedListeners(throwable);
                    }
                }
            }
            else if (rc < 0)
            {
                throw IllegalStateException.Create("too many decRef calls: refCount is " + rc + " after decrement");
            }
        }