Skip to content

Commit

Permalink
use RequestContextHolder.resetRequestAttributes() to clear request th…
Browse files Browse the repository at this point in the history
…readlocal variables
  • Loading branch information
lhotari committed Jan 3, 2015
1 parent bbf8a36 commit 80a1333
Show file tree
Hide file tree
Showing 28 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class URLCodecTests extends GroovyTestCase {
}

protected void tearDown() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}

void testEncode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ class ControllerActionTransformerClosureActionOverridingSpec extends Specificati
}

def cleanupSpec() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class ControllerActionTransformerSpec extends Specification {
*/

def cleanup() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
System.properties[BuildSettings.CONVERT_CLOSURES_KEY] = 'false'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class ControllerTestPlugin implements TestPlugin {

@CompileStatic(TypeCheckingMode.SKIP)
protected void clearGrailsWebRequest(TestRuntime runtime) {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
runtime.getValue("groovyPages")?.clear()
GrailsWebRequest webRequest = runtime.getValueIfExists("webRequest")
def ctx = webRequest?.applicationContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ abstract class AbstractGrailsControllerTests extends GroovyTestCase {

protected void tearDown() {
ga.mainContext.close()
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
ExpandoMetaClass.disableGlobally()

Holders.config = null
Expand All @@ -167,7 +167,7 @@ abstract class AbstractGrailsControllerTests extends GroovyTestCase {
callable()
}
finally {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ abstract class AbstractGrailsTagTests extends GroovyTestCase {
callable()
}
finally {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
Holders.config = null
}
}
Expand Down Expand Up @@ -316,7 +316,7 @@ abstract class AbstractGrailsTagTests extends GroovyTestCase {
// static and likely to cause tests to interfere with each other.
appCtx.groovyPagesTemplateEngine.clearPageCache()

RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
GroovySystem.metaClassRegistry.setMetaClassCreationHandle(originalHandler)

onDestroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class GrailsExceptionResolverTests extends GroovyTestCase {

@Override
protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import org.springframework.web.servlet.i18n.SessionLocaleResolver
class ParamsAwareLocaleChangeInterceptorTests extends GroovyTestCase {

protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
}

void testSwitchLocaleWithStringArrayParamsObject() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WithFormMethodTests extends GroovyTestCase {

@Override
protected void tearDown() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}

void testMissingToken() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ class GSPSitemeshPageTests extends AbstractGrailsTagTests {
}

void tearDown() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,6 @@ public void testDecoratedByLayoutPropertyInController() throws Exception {

@Override
protected void tearDown() {
RequestContextHolder.setRequestAttributes(null);
RequestContextHolder.resetRequestAttributes();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void testCodecAndNoCodecGRAILS8405() throws IOException {
codecOut.flush();

// clear thread local
RequestContextHolder.setRequestAttributes(null);
RequestContextHolder.resetRequestAttributes();

assertEquals("-> hola <-123added-> too <-4-> A <--> B <-5-> C <-", target.getValue());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class WebUtilsTests extends GroovyTestCase {

def config
protected void setUp() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
config = new ConfigSlurper().parse("""
grails.mime.file.extensions=false
grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
Expand All @@ -39,7 +39,7 @@ grails.mime.types = [ html: ['text/html','application/xhtml+xml'],
}

protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
}

void testAreFileExtensionsEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class GroovyPagesPageContextTests extends GroovyTestCase {
}

protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
}

void testPageContextState() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class IterativeJspTagTests extends GroovyTestCase {
}

protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
GroovySystem.metaClassRegistry.removeMetaClass TagLibraryResolverImpl
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SimpleJspTagTests extends GroovyTestCase {
}

protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
}

void testSimpleTagUsage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SimpleTagTests extends GroovyTestCase {
}

protected void tearDown() {
RequestContextHolder.setRequestAttributes null
RequestContextHolder.resetRequestAttributes()
}

void testSimpleTagWithBodyUsage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class GroovyPageServletSpec extends Specification{
private SimpleMapResourceLoader resourceLoader

void setup() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
void cleanup() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}

void "Test create response writer method"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public void testParseWithUTF8() throws Exception {
output = parseCode("myTest4", src);
}
finally {
RequestContextHolder.setRequestAttributes(null);
RequestContextHolder.resetRequestAttributes();
}
String expected = makeImports() +
"\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ class GroovyPageViewTests extends GroovyTestCase {
}

void tearDown() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GrailsTestRequestEnvironmentInterceptor {
* Removes the mock request environment
*/
void destroy() {
RequestContextHolder.requestAttributes = null
RequestContextHolder.resetRequestAttributes()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GrailsParameterMapTests extends GroovyTestCase {
def cal = new GregorianCalendar(1971,6,16)
assert val == cal.time
} finally {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
}
void testDateMethodMultipleFormats() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class GrailsConventionGroovyPageLocatorSpec extends Specification {
source == null

cleanup:
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}

void "Test find view with controller instance and view name from plugin"() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TagLibraryLookupSpec extends Specification {


cleanup:"cleanup request context"
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class DefaultUrlCreatorTests extends GroovyTestCase {
}

void tearDown() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class LinkGeneratorSpec extends Specification {


void cleanup() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}

protected getGenerator(boolean cache=false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UrlMappingsHandlerMappingSpec extends AbstractUrlMappingsSpec{
}

void cleanup() {
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ServletContextHolderSpec extends Specification {

void cleanup() {
ServletContextHolder.setServletContext(null)
RequestContextHolder.setRequestAttributes(null)
RequestContextHolder.resetRequestAttributes()
}

def "Test get set servlet context"() {
Expand Down

0 comments on commit 80a1333

Please sign in to comment.