[spec / cdi 2] bad impl for javax.enterprise.inject.se.SeContainerInitializer#newInstance?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[spec / cdi 2] bad impl for javax.enterprise.inject.se.SeContainerInitializer#newInstance?

Romain Manni-Bucau
Hi guys,

just saw how javax.enterprise.inject.se.SeContainerInitializer#newInstance has been implemented. I'm not sure it was based on the ref implementation but - ignoring for now the OSGi issues - I don't think it works:

long exactSize = serviceLoader.spliterator().getExactSizeIfKnown();
if(exactSize == 0)
{
throw new IllegalStateException("No valid implementation of SeContainerInitializer found via ServiceLoader");
}
else if(exactSize > 1)
{
throw new IllegalStateException("Multiple implementations ("+exactSize+") of SeContainerInitializer found via ServiceLoader");
}
return serviceLoader.iterator().next();

exactSize will be -1 since the splititerator doesnt have the size as a characteristic so we'll always be not deterministic which seems not intended.

Am I missing anything?

Do we want to use the old instance = next(); if (hasNext()) fail(); pattern?

Romain Manni-Bucau
@rmannibucau |  Blog | Old BlogGithub | LinkedIn | JavaEE Factory
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [spec / cdi 2] bad impl for javax.enterprise.inject.se.SeContainerInitializer#newInstance?

Mark Struberg
+1 for the old pattern.
Do you create a ticket for it?

LieGrue,
strub


> Am 01.07.2017 um 14:29 schrieb Romain Manni-Bucau <[hidden email]>:
>
> Hi guys,
>
> just saw how javax.enterprise.inject.se.SeContainerInitializer#newInstance has been implemented. I'm not sure it was based on the ref implementation but - ignoring for now the OSGi issues - I don't think it works:
>
> long exactSize = serviceLoader.spliterator().getExactSizeIfKnown();
> if(exactSize == 0)
> {
>     throw new IllegalStateException("No valid implementation of SeContainerInitializer found via ServiceLoader");
> }
> else if(exactSize > 1)
> {
>     throw new IllegalStateException("Multiple implementations ("+exactSize+") of SeContainerInitializer found via ServiceLoader");
> }
> return serviceLoader.iterator().next();
>
> exactSize will be -1 since the splititerator doesnt have the size as a characteristic so we'll always be not deterministic which seems not intended.
>
> Am I missing anything?
>
> Do we want to use the old instance = next(); if (hasNext()) fail(); pattern?
>
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [spec / cdi 2] bad impl for javax.enterprise.inject.se.SeContainerInitializer#newInstance?

Romain Manni-Bucau
Can tmr yes

Le 2 juil. 2017 13:29, "Mark Struberg" <[hidden email]> a écrit :
+1 for the old pattern.
Do you create a ticket for it?

LieGrue,
strub


> Am 01.07.2017 um 14:29 schrieb Romain Manni-Bucau <[hidden email]>:
>
> Hi guys,
>
> just saw how javax.enterprise.inject.se.SeContainerInitializer#newInstance has been implemented. I'm not sure it was based on the ref implementation but - ignoring for now the OSGi issues - I don't think it works:
>
> long exactSize = serviceLoader.spliterator().getExactSizeIfKnown();
> if(exactSize == 0)
> {
>     throw new IllegalStateException("No valid implementation of SeContainerInitializer found via ServiceLoader");
> }
> else if(exactSize > 1)
> {
>     throw new IllegalStateException("Multiple implementations ("+exactSize+") of SeContainerInitializer found via ServiceLoader");
> }
> return serviceLoader.iterator().next();
>
> exactSize will be -1 since the splititerator doesnt have the size as a characteristic so we'll always be not deterministic which seems not intended.
>
> Am I missing anything?
>
> Do we want to use the old instance = next(); if (hasNext()) fail(); pattern?
>
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [spec / cdi 2] bad impl for javax.enterprise.inject.se.SeContainerInitializer#newInstance?

Romain Manni-Bucau


Romain Manni-Bucau
@rmannibucau |  Blog | Old BlogGithub | LinkedIn | JavaEE Factory

2017-07-02 14:20 GMT+02:00 Romain Manni-Bucau <[hidden email]>:
Can tmr yes

Le 2 juil. 2017 13:29, "Mark Struberg" <[hidden email]> a écrit :
+1 for the old pattern.
Do you create a ticket for it?

LieGrue,
strub


> Am 01.07.2017 um 14:29 schrieb Romain Manni-Bucau <[hidden email]>:
>
> Hi guys,
>
> just saw how javax.enterprise.inject.se.SeContainerInitializer#newInstance has been implemented. I'm not sure it was based on the ref implementation but - ignoring for now the OSGi issues - I don't think it works:
>
> long exactSize = serviceLoader.spliterator().getExactSizeIfKnown();
> if(exactSize == 0)
> {
>     throw new IllegalStateException("No valid implementation of SeContainerInitializer found via ServiceLoader");
> }
> else if(exactSize > 1)
> {
>     throw new IllegalStateException("Multiple implementations ("+exactSize+") of SeContainerInitializer found via ServiceLoader");
> }
> return serviceLoader.iterator().next();
>
> exactSize will be -1 since the splititerator doesnt have the size as a characteristic so we'll always be not deterministic which seems not intended.
>
> Am I missing anything?
>
> Do we want to use the old instance = next(); if (hasNext()) fail(); pattern?
>
> Romain Manni-Bucau
> @rmannibucau |  Blog | Old Blog | Github | LinkedIn | JavaEE Factory


Loading...