Campoie / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

NPE when trying to log all responses by default #210

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I tried naively to set a default responseSpecification reference so that I 
could default all responses to be logged in one line of code.

This code:

   RestAssured.responseSpecification = new ResponseSpecBuilder().build().log().all(true);

results in a NullPointerException with a stacktrace like:

java.lang.NullPointerException: Cannot get property 'restAssuredConfig' on null 
object
    at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
    at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:156)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
    at com.jayway.restassured.internal.LogSpecificationImpl.getLogConfig(LogSpecificationImpl.groovy:45)
    at com.jayway.restassured.internal.LogSpecificationImpl.this$2$getLogConfig(LogSpecificationImpl.groovy)
    at com.jayway.restassured.internal.LogSpecificationImpl$this$2$getLogConfig.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:141)
    at com.jayway.restassured.internal.LogSpecificationImpl.getPrintStream(LogSpecificationImpl.groovy:29)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl.super$2$getPrintStream(ResponseLogSpecificationImpl.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1054)
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:128)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl.getPrintStream(ResponseLogSpecificationImpl.groovy:92)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl.logWith(ResponseLogSpecificationImpl.groovy:83)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl.this$3$logWith(ResponseLogSpecificationImpl.groovy)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl$this$3$logWith.callCurrent(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:46)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl.all(ResponseLogSpecificationImpl.groovy:43)
    at com.jayway.restassured.internal.ResponseLogSpecificationImpl.all(ResponseLogSpecificationImpl.groovy)

Original issue reported on code.google.com by Octavius@gmail.com on 5 Dec 2012 at 8:58

GoogleCodeExporter commented 9 years ago
Fixed in master

Original comment by johan.ha...@gmail.com on 5 Dec 2012 at 9:10