Hi Alex, Good catch! I've applied a slightly modified version of your patch to SVN trunk and 1.0.
Best regards, Jerome > -----Message d'origine----- > De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la > part de Alex Milowski > Envoyé : mercredi 15 août 2007 22:56 > À : discuss@restlet.tigris.org > Objet : Null pointer exception with anonymous restlets > > If you have the following code to create a Restlet instance: > > new Restlet() { > public void handle(Request request,Response response) > { > getContext().getLogger().info("Handling test..."); > response.setStatus(Status.SUCCESS_OK,"OK!"); > } > }; > > you'll get a null pointer exception because > getClass().getCanonicalName() > returns null. > > I've tracked it down to line 75 of Restlet.java in the > getContext() method: > > public Context getContext() { > if (this.context == null) > this.context = new Context(getClass().getCanonicalName()); > return this.context; > } > > > There needs to be a default log name: > > public Context getContext() { > if (this.context == null) { > String logName = getClass().getCanonicalName(); > if (logName==null) { > logName = "org.restlet.anonymous"; > } > this.context = new Context(logName); > } > return this.context; > } > > > --Alex Milowski