Hi Ralf,

Thanks for the detailed report. The fix is now in SVN trunk!

Best regards,
Jerome


-----Message d'origine-----
De : Ralf Bommersbach [mailto:[EMAIL PROTECTED] 
Envoyé : jeudi 17 juillet 2008 17:52
À : discuss@restlet.tigris.org
Objet : Bugfix for possible Nullpointer in Template.java

Okay I think I found a little bug in the Template.java (in the 1.1snapshot):

It occurrs when the UserAgentTunnel in the Application is set enabled 
(setUserAgentTunnel(true) and your application gets a request where the 
user-agent is omitted.
The Template then tries to parse the user-agent string and gets a 
Nullpointer.

Here is the relevant part of the stackTrace:
java.lang.NullPointerException
        at java.util.regex.Matcher.getTextLength(Unknown Source)
        at java.util.regex.Matcher.reset(Unknown Source)
        at java.util.regex.Matcher.<init>(Unknown Source)
        at java.util.regex.Pattern.matcher(Unknown Source)
        at org.restlet.util.Template.parse(Template.java:756)
        at
org.restlet.data.ClientInfo.getAgentAttributes(ClientInfo.java:336)
        at 
com.noelios.restlet.application.TunnelFilter.processUserAgent(TunnelFilter.j
ava:316)
        at 
com.noelios.restlet.application.TunnelFilter.beforeHandle(TunnelFilter.java:
74)


and here a code snippet of the relevant part of Template.java at line 
752 (with the fix):
public int parse(String formattedString, Map<String, Object> variables) {
         int result = -1;
        // fix
        if (formattedString == null)
                return result;
...}


Apparently Google Maps does this (i.e. no user-agent), as I pasted an 
URL which points to an KML-Representation of a Resource in the Google 
Maps Query Box and got the Nullpointer. (I can also see in the Server 
log that there is no user-agent)
When I disable the UserAgentTunnel it works (google maps neatly displays 
the kml then)

Okay thats it I think.

Greetings
Ralf Bommersbach

P.S. The fixed file is attached




Reply via email to