예제 #1
0
 private void EnsureOpen()
 {
     if (closed)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexWriter is disposed.");
     }
 }
예제 #2
0
 private void EnsureOpen()
 {
     if (_closed)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this SearcherLifetimeManager instance 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
 private void EnsureOpen()
 {
     if (closed)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "CFS Directory is already disposed.");
     }
 }
예제 #6
0
        public void SessionIsTreatedAsBrokenAfterSendFailureWithAlreadyClosedExceptionTest()
        {
            using (var transport = new RabbitMqTransport(_logFactory, HOST, "guest", "guest"))
            {
                var onFailureCalled = new AutoResetEvent(false);
                IMessagingSession messagingSession = transport.CreateSession(() =>
                {
                    onFailureCalled.Set();
                    Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
                });

                messagingSession.Send(TEST_EXCHANGE, new BinaryMessage {
                    Bytes = new byte[] { 0x0, 0x1, 0x2 }, Type = "messageType"
                }, 0);
                FieldInfo field      = typeof(RabbitMqSession).GetField("m_Connection", BindingFlags.NonPublic | BindingFlags.Instance);
                var       connection = field.GetValue(messagingSession) as IConnection;
                connection.Abort(1, "All your base are belong to us");
                AlreadyClosedException ex = null;
                try
                {
                    messagingSession.Send(TEST_EXCHANGE, new BinaryMessage {
                        Bytes = new byte[] { 0x0, 0x1, 0x2 }, Type = "messageType"
                    }, 0);
                }
                catch (AlreadyClosedException e)
                {
                    ex = e;
                }

                Assert.That(ex, Is.Not.Null, "Exception was not thrown on send fail");
                Assert.That(ex, Is.InstanceOf <AlreadyClosedException>(), "Wrong exception type was thrown on send fail");
                Assert.That(transport.SessionsCount, Is.EqualTo(0), "session was not removed after send failed AlreadyClosedException ");
                Assert.That(onFailureCalled.WaitOne(500), Is.True, "Subsciptionwas not notefied on failure");
            }
        }
예제 #7
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()));
 }
예제 #8
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;
 }
 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));
 }
예제 #10
0
        /// <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.");
        }
예제 #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
            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();
            }
예제 #13
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);
            }
예제 #14
0
 private void EnsureOpen()
 {
     if (writer == null)
     {
         throw AlreadyClosedException.Create(this.GetType().FullName, "this IndexWriter is disposed.");
     }
     else
     {
         writer.EnsureOpen(false);
     }
 }
예제 #15
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);
            }
예제 #16
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.");
            }
        }
예제 #17
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.");
     }
 }
예제 #18
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.");
        }
예제 #19
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);
            }
        }
예제 #20
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");
            }
        }