users@jersey.java.net

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

From: Martynas Jusevi?ius <martynas_at_graphity.org>
Date: Mon, 6 Aug 2012 12:29:59 +0300

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