Hi Clément, You should raise a bug about the JavaDoc/implementation inconsistency in the OSGi bugzilla. The StackOverflow question is now answered, hopefully to your satisfaction.
Best Regards, Tim > On 9 Dec 2018, at 21:35, Clément Delgrange via osgi-dev > <osgi-dev@mail.osgi.org> wrote: > > Hi all, > > I have two questions related to the OSGi PushStream implementation. The first > one is on Stackoverflow.com > <https://stackoverflow.com/questions/53692861/osgi-pushstream-is-slow>; the > second is the publish method of the SimplePushEventSource says that it throws > a IllegalStateException if the source is closed: > > /** > * Asynchronously publish an event to this stream and all connected > * {@link PushEventConsumer} instances. When this method returns there is no > * guarantee that all consumers have been notified. Events published by a > * single thread will maintain their relative ordering, however they may be > * interleaved with events from other threads. > * > * @param t > * @throws IllegalStateException if the source is closed > */ > void publish(T t); > > But in the implementation it only returns: > @Override > public void publish(T t) { > enqueueEvent(PushEvent.data(t)); > } > > private void enqueueEvent(PushEvent<T> event) { > synchronized (lock) { > if (closed || connected.isEmpty()) { > return; > } > } > > try { > queuePolicy.doOffer(queue, event); > boolean start; > synchronized (lock) { > start = !waitForFinishes && semaphore.tryAcquire(); > } > if (start) { > startWorker(); > } > } catch (Exception e) { > close(PushEvent.error(e)); > throw new IllegalStateException("The queue policy threw an exception", > e); > } > } > > When the exception is thrown? I have tested with the following code: > > source.close(); > source.publish( 1 ); > > and effectively it only returns. > > Thanks > -- > Clément Delgrange <cl.delgra...@protonmail.com > <mailto:cl.delgra...@protonmail.com>> > > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev