Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-cloud-netflix
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
spring-cloud-netflix
Commits
e623ad10
Commit
e623ad10
authored
Dec 16, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ordering problem in tests
The Zuul filter registry has to be cleareed (including a cache in a private field in FilterLoader, yuck).
parent
311d8788
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
9 deletions
+61
-9
ZuulConfiguration.java
...springframework/cloud/netflix/zuul/ZuulConfiguration.java
+2
-2
ZuulFilterInitializer.java
...ngframework/cloud/netflix/zuul/ZuulFilterInitializer.java
+22
-6
AdhocTestSuite.java
...ava/org/springframework/cloud/netflix/AdhocTestSuite.java
+36
-0
application.yml
spring-cloud-netflix-core/src/test/resources/application.yml
+1
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/ZuulConfiguration.java
View file @
e623ad10
...
...
@@ -53,8 +53,8 @@ public class ZuulConfiguration {
private
Map
<
String
,
ZuulFilter
>
filters
;
@Bean
public
FilterInitializer
zuulFilterInitializer
()
{
return
new
FilterInitializer
(
filters
);
public
Zuul
FilterInitializer
zuulFilterInitializer
()
{
return
new
Zuul
FilterInitializer
(
filters
);
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/FilterInitializer.java
→
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/
Zuul
FilterInitializer.java
View file @
e623ad10
package
org
.
springframework
.
cloud
.
netflix
.
zuul
;
import
java.lang.reflect.Field
;
import
java.util.Map
;
import
javax.servlet.ServletContextEvent
;
...
...
@@ -7,24 +8,25 @@ import javax.servlet.ServletContextListener;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.ReflectionUtils
;
import
com.netflix.zuul.FilterLoader
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.filters.FilterRegistry
;
import
com.netflix.zuul.monitoring.MonitoringHelper
;
/**
* User: spencergibb
* Date: 4/24/14
* Time: 9:23 PM
* @author Spencer Gibb
*
* TODO: .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
*/
public
class
FilterInitializer
implements
ServletContextListener
{
public
class
Zuul
FilterInitializer
implements
ServletContextListener
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
FilterInitializer
.
class
);
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
Zuul
FilterInitializer
.
class
);
private
Map
<
String
,
ZuulFilter
>
filters
;
public
FilterInitializer
(
Map
<
String
,
ZuulFilter
>
filters
)
{
public
Zuul
FilterInitializer
(
Map
<
String
,
ZuulFilter
>
filters
)
{
this
.
filters
=
filters
;
}
...
...
@@ -46,6 +48,20 @@ public class FilterInitializer implements ServletContextListener {
@Override
public
void
contextDestroyed
(
ServletContextEvent
sce
)
{
LOGGER
.
info
(
"Stopping filter initializer context listener"
);
FilterRegistry
registry
=
FilterRegistry
.
instance
();
for
(
Map
.
Entry
<
String
,
ZuulFilter
>
entry
:
filters
.
entrySet
())
{
registry
.
remove
(
entry
.
getKey
());
}
clearLoaderCache
();
}
private
void
clearLoaderCache
()
{
FilterLoader
instance
=
FilterLoader
.
getInstance
();
Field
field
=
ReflectionUtils
.
findField
(
FilterLoader
.
class
,
"hashFiltersByType"
);
ReflectionUtils
.
makeAccessible
(
field
);
@SuppressWarnings
(
"rawtypes"
)
Map
cache
=
(
Map
)
ReflectionUtils
.
getField
(
field
,
instance
);
cache
.
clear
();
}
/*private void initGroovyFilterManager() {
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/AdhocTestSuite.java
0 → 100644
View file @
e623ad10
/*
* Copyright 2012-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
cloud
.
netflix
;
import
org.junit.Ignore
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
import
org.springframework.cloud.netflix.zuul.SampleZuulProxyApplicationTests
;
import
org.springframework.cloud.netflix.zuul.SimpleZuulServerApplicationTests
;
/**
* A test suite for probing weird ordering problems in the tests.
*
* @author Dave Syer
*/
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
SimpleZuulServerApplicationTests
.
class
,
SampleZuulProxyApplicationTests
.
class
})
@Ignore
public
class
AdhocTestSuite
{
}
spring-cloud-netflix-core/src/test/resources/application.yml
View file @
e623ad10
...
...
@@ -2,7 +2,7 @@ server:
port
:
9999
logging
:
level
:
org.springframework.web
:
DEBUG
#
org.springframework.web: DEBUG
spring
:
application
:
name
:
testclient
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment