users@jersey.java.net

[Jersey] Re: UriInfo.getBaseUri() or injection bug?

From: Martynas Jusevičius <martynas_at_graphity.org>
Date: Mon, 6 Aug 2012 14:56:57 +0300

I tried some investigative downgrading, and it seems that this change
was introduced in 1.10.
Debugging 1.9 also confirms that -- no double constructor calls
there, so I'll stick to this version.

Could this have to do with the jersey-servlet artifact? It was
introduced at the same time, starting with 1.10.
Martynas

On Mon, Aug 6, 2012 at 12:29 PM, Martynas Jusevičius
<martynas_at_graphity.org> wrote:
> Hey list,
>
> I just upgraded from Jersey 1.5 to 1.13 and noticed a weird and
> unexpected change.
>
> My application is deployed at http://localhost:8080 base URI and uses
> @Context UriInfo injected into resource constructor, which is then
> passed to super class using super(uriInfo).
>
> Previously getBaseUri() always returned http://localhost:8080 as
> expected. After the update, it seems that getBaseUri() equals
> getAbsolutePath() -- for example, if I visit
> http://localhost:8080/classes, both return
> http://localhost:8080/classes.
>
> It gets even weirder -- when debugging, I see the resource constructor
> being called a *second* time, with getBaseUri() having the expected
> http://localhost:8080/ value, but the response has been already sent.
>
> The main resource class:
> https://github.com/Graphity/graphity-browser/blob/master/src/main/java/org/graphity/browser/Resource.java
> Abstract superclass:
> https://github.com/Graphity/graphity-browser/blob/master/src/main/java/org/graphity/ldp/model/impl/ResourceBase.java
>
> There's definitely a change in behavior between 1.5 and 1.13 but I
> cannot see how this could be intended -- so probably a bug?
>
> Martynas
> graphity.org