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
63e6c813
Commit
63e6c813
authored
Jan 30, 2015
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove guava usages (fixes gh-154)
parent
29bee28d
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
99 additions
and
134 deletions
+99
-134
EurekaDiscoveryClient.java
...framework/cloud/netflix/eureka/EurekaDiscoveryClient.java
+23
-45
FeignRibbonClient.java
...amework/cloud/netflix/feign/ribbon/FeignRibbonClient.java
+3
-2
SpringEncoder.java
...gframework/cloud/netflix/feign/support/SpringEncoder.java
+4
-5
RibbonLoadBalancerClient.java
...mework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
+3
-3
SendErrorFilter.java
...work/cloud/netflix/zuul/filters/post/SendErrorFilter.java
+3
-2
SendResponseFilter.java
...k/cloud/netflix/zuul/filters/post/SendResponseFilter.java
+3
-2
FormBodyWrapperFilter.java
...cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
+4
-9
Servlet30WrapperFilter.java
...loud/netflix/zuul/filters/pre/Servlet30WrapperFilter.java
+3
-9
ArchaiusAutoConfigurationTests.java
...loud/netflix/archaius/ArchaiusAutoConfigurationTests.java
+18
-13
HystrixOnlyTests.java
...ringframework/cloud/netflix/hystrix/HystrixOnlyTests.java
+4
-4
RibbonInterceptorTests.java
...ramework/cloud/netflix/ribbon/RibbonInterceptorTests.java
+2
-2
DomainExtractingServerListTests.java
...etflix/ribbon/eureka/DomainExtractingServerListTests.java
+4
-5
ProxyRouteLocatorTests.java
...rk/cloud/netflix/zuul/filters/ProxyRouteLocatorTests.java
+8
-9
EurekaServerConfiguration.java
...loud/netflix/eureka/server/EurekaServerConfiguration.java
+4
-3
LeaseManagerMessageBroker.java
...etflix/eureka/server/event/LeaseManagerMessageBroker.java
+13
-21
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/eureka/EurekaDiscoveryClient.java
View file @
63e6c813
...
@@ -16,26 +16,18 @@
...
@@ -16,26 +16,18 @@
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
package
org
.
springframework
.
cloud
.
netflix
.
eureka
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.Nullable
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
com.google.common.base.Function
;
import
com.google.common.base.Predicates
;
import
com.google.common.collect.Lists
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.discovery.shared.Application
;
import
com.netflix.discovery.shared.Application
;
import
com.netflix.discovery.shared.Applications
;
import
com.netflix.discovery.shared.Applications
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
concat
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
filter
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
transform
;
/**
/**
* @author Spencer Gibb
* @author Spencer Gibb
*/
*/
...
@@ -78,15 +70,11 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
...
@@ -78,15 +70,11 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
public
List
<
ServiceInstance
>
getInstances
(
String
serviceId
)
{
public
List
<
ServiceInstance
>
getInstances
(
String
serviceId
)
{
List
<
InstanceInfo
>
infos
=
this
.
discovery
.
getInstancesByVipAddress
(
serviceId
,
List
<
InstanceInfo
>
infos
=
this
.
discovery
.
getInstancesByVipAddress
(
serviceId
,
false
);
false
);
Iterable
<
ServiceInstance
>
instances
=
transform
(
infos
,
List
<
ServiceInstance
>
instances
=
new
ArrayList
<
ServiceInstance
>();
new
Function
<
InstanceInfo
,
ServiceInstance
>()
{
for
(
InstanceInfo
info
:
infos
)
{
@Nullable
instances
.
add
(
new
EurekaServiceInstance
(
info
));
@Override
}
public
ServiceInstance
apply
(
@Nullable
InstanceInfo
info
)
{
return
instances
;
return
new
EurekaServiceInstance
(
info
);
}
});
return
Lists
.
newArrayList
(
instances
);
}
}
static
class
EurekaServiceInstance
implements
ServiceInstance
{
static
class
EurekaServiceInstance
implements
ServiceInstance
{
...
@@ -118,18 +106,16 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
...
@@ -118,18 +106,16 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
if
(
applications
==
null
)
{
if
(
applications
==
null
)
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
return
Lists
.
newArrayList
(
filter
(
List
<
Application
>
registered
=
applications
.
getRegisteredApplications
();
transform
(
applications
.
getRegisteredApplications
(),
List
<
String
>
names
=
new
ArrayList
<
String
>();
new
Function
<
Application
,
String
>()
{
for
(
Application
app
:
registered
)
{
@Nullable
if
(
app
.
getInstances
().
isEmpty
())
{
@Override
continue
;
public
String
apply
(
@Nullable
Application
app
)
{
}
if
(
app
.
getInstances
().
isEmpty
())
{
names
.
add
(
app
.
getName
().
toLowerCase
());
return
null
;
}
}
return
app
.
getName
().
toLowerCase
();
return
names
;
}
}),
Predicates
.
notNull
()));
}
}
@Override
@Override
...
@@ -138,21 +124,13 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
...
@@ -138,21 +124,13 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
if
(
applications
==
null
)
{
if
(
applications
==
null
)
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
Iterable
<
ServiceInstance
>
instances
=
transform
(
List
<
ServiceInstance
>
instances
=
new
ArrayList
<
ServiceInstance
>();
concat
(
transform
(
applications
.
getRegisteredApplications
(),
for
(
Application
app
:
applications
.
getRegisteredApplications
())
{
new
Function
<
Application
,
List
<
InstanceInfo
>>()
{
for
(
InstanceInfo
info
:
app
.
getInstances
())
{
@Override
instances
.
add
(
new
EurekaServiceInstance
(
info
));
public
List
<
InstanceInfo
>
apply
(
@Nullable
Application
app
)
{
}
return
app
.
getInstances
();
}
}
return
instances
;
})),
new
Function
<
InstanceInfo
,
ServiceInstance
>()
{
@Nullable
@Override
public
ServiceInstance
apply
(
@Nullable
InstanceInfo
info
)
{
return
new
EurekaServiceInstance
(
info
);
}
});
return
Lists
.
newArrayList
(
instances
);
}
}
}
}
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/ribbon/FeignRibbonClient.java
View file @
63e6c813
...
@@ -24,8 +24,8 @@ import javax.net.ssl.HttpsURLConnection;
...
@@ -24,8 +24,8 @@ import javax.net.ssl.HttpsURLConnection;
import
javax.net.ssl.SSLSocketFactory
;
import
javax.net.ssl.SSLSocketFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.cloud.netflix.ribbon.SpringClientFactory
;
import
org.springframework.util.ReflectionUtils
;
import
com.google.common.base.Throwables
;
import
com.netflix.client.ClientException
;
import
com.netflix.client.ClientException
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.client.config.IClientConfig
;
import
com.netflix.loadbalancer.ILoadBalancer
;
import
com.netflix.loadbalancer.ILoadBalancer
;
...
@@ -66,7 +66,8 @@ public class FeignRibbonClient implements Client {
...
@@ -66,7 +66,8 @@ public class FeignRibbonClient implements Client {
if
(
ex
.
getCause
()
instanceof
IOException
)
{
if
(
ex
.
getCause
()
instanceof
IOException
)
{
throw
IOException
.
class
.
cast
(
ex
.
getCause
());
throw
IOException
.
class
.
cast
(
ex
.
getCause
());
}
}
throw
Throwables
.
propagate
(
ex
);
ReflectionUtils
.
rethrowRuntimeException
(
ex
);
return
null
;
}
}
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/support/SpringEncoder.java
View file @
63e6c813
...
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.feign.support;
...
@@ -19,6 +19,7 @@ package org.springframework.cloud.netflix.feign.support;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.nio.charset.Charset
;
import
java.util.Collection
;
import
java.util.Collection
;
import
javax.inject.Provider
;
import
javax.inject.Provider
;
...
@@ -32,14 +33,12 @@ import org.springframework.http.HttpOutputMessage;
...
@@ -32,14 +33,12 @@ import org.springframework.http.HttpOutputMessage;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
com.google.common.base.Charsets
;
import
static
org
.
springframework
.
cloud
.
netflix
.
feign
.
support
.
FeignUtils
.
getHttpHeaders
;
import
feign.RequestTemplate
;
import
feign.RequestTemplate
;
import
feign.codec.EncodeException
;
import
feign.codec.EncodeException
;
import
feign.codec.Encoder
;
import
feign.codec.Encoder
;
import
static
org
.
springframework
.
cloud
.
netflix
.
feign
.
support
.
FeignUtils
.
getHttpHeaders
;
/**
/**
* @author Spencer Gibb
* @author Spencer Gibb
*/
*/
...
@@ -89,7 +88,7 @@ public class SpringEncoder implements Encoder {
...
@@ -89,7 +88,7 @@ public class SpringEncoder implements Encoder {
throw
new
EncodeException
(
"Error converting request body"
,
ex
);
throw
new
EncodeException
(
"Error converting request body"
,
ex
);
}
}
request
.
body
(
outputMessage
.
getOutputStream
().
toByteArray
(),
request
.
body
(
outputMessage
.
getOutputStream
().
toByteArray
(),
Charset
s
.
UTF_8
);
// TODO: set charset
Charset
.
forName
(
"UTF-8"
)
);
// TODO: set charset
return
;
return
;
}
}
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/ribbon/RibbonLoadBalancerClient.java
View file @
63e6c813
...
@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
...
@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.ServiceInstance
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerClient
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerRequest
;
import
org.springframework.cloud.client.loadbalancer.LoadBalancerRequest
;
import
org.springframework.util.ReflectionUtils
;
import
com.google.common.base.Throwables
;
import
com.netflix.loadbalancer.ILoadBalancer
;
import
com.netflix.loadbalancer.ILoadBalancer
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.ServerStats
;
import
com.netflix.loadbalancer.ServerStats
;
...
@@ -74,7 +74,7 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
...
@@ -74,7 +74,7 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
recordStats
(
context
,
tracer
,
serverStats
,
null
,
ex
);
recordStats
(
context
,
tracer
,
serverStats
,
null
,
ex
);
Throwables
.
propagate
(
ex
);
ReflectionUtils
.
rethrowRuntimeException
(
ex
);
}
}
return
null
;
return
null
;
}
}
...
@@ -128,7 +128,7 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
...
@@ -128,7 +128,7 @@ public class RibbonLoadBalancerClient implements LoadBalancerClient {
}
}
public
Server
getServer
()
{
public
Server
getServer
()
{
return
server
;
return
this
.
server
;
}
}
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/SendErrorFilter.java
View file @
63e6c813
...
@@ -19,9 +19,10 @@ package org.springframework.cloud.netflix.zuul.filters.post;
...
@@ -19,9 +19,10 @@ package org.springframework.cloud.netflix.zuul.filters.post;
import
javax.servlet.RequestDispatcher
;
import
javax.servlet.RequestDispatcher
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.apachecommons.CommonsLog
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ReflectionUtils
;
import
com.google.common.base.Throwables
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
...
@@ -75,7 +76,7 @@ public class SendErrorFilter extends ZuulFilter {
...
@@ -75,7 +76,7 @@ public class SendErrorFilter extends ZuulFilter {
}
}
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
Throwables
.
propagate
(
ex
);
ReflectionUtils
.
rethrowRuntimeException
(
ex
);
}
}
return
null
;
return
null
;
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/post/SendResponseFilter.java
View file @
63e6c813
...
@@ -25,7 +25,8 @@ import java.util.zip.GZIPInputStream;
...
@@ -25,7 +25,8 @@ import java.util.zip.GZIPInputStream;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.google.common.base.Throwables
;
import
org.springframework.util.ReflectionUtils
;
import
com.netflix.config.DynamicBooleanProperty
;
import
com.netflix.config.DynamicBooleanProperty
;
import
com.netflix.config.DynamicIntProperty
;
import
com.netflix.config.DynamicIntProperty
;
import
com.netflix.config.DynamicPropertyFactory
;
import
com.netflix.config.DynamicPropertyFactory
;
...
@@ -76,7 +77,7 @@ public class SendResponseFilter extends ZuulFilter {
...
@@ -76,7 +77,7 @@ public class SendResponseFilter extends ZuulFilter {
writeResponse
();
writeResponse
();
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
Throwables
.
propagate
(
ex
);
ReflectionUtils
.
rethrowRuntimeException
(
ex
);
}
}
return
null
;
return
null
;
}
}
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/FormBodyWrapperFilter.java
View file @
63e6c813
...
@@ -29,7 +29,6 @@ import org.springframework.http.MediaType;
...
@@ -29,7 +29,6 @@ import org.springframework.http.MediaType;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
import
com.google.common.base.Throwables
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.http.HttpServletRequestWrapper
;
import
com.netflix.zuul.http.HttpServletRequestWrapper
;
...
@@ -83,14 +82,10 @@ public class FormBodyWrapperFilter extends ZuulFilter {
...
@@ -83,14 +82,10 @@ public class FormBodyWrapperFilter extends ZuulFilter {
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
HttpServletRequest
request
=
ctx
.
getRequest
();
HttpServletRequest
request
=
ctx
.
getRequest
();
if
(
request
instanceof
HttpServletRequestWrapper
)
{
if
(
request
instanceof
HttpServletRequestWrapper
)
{
try
{
HttpServletRequest
wrapped
=
(
HttpServletRequest
)
ReflectionUtils
.
getField
(
HttpServletRequest
wrapped
=
(
HttpServletRequest
)
this
.
requestField
this
.
requestField
,
request
);
.
get
(
request
);
ReflectionUtils
.
setField
(
this
.
requestField
,
request
,
this
.
requestField
.
set
(
request
,
new
FormBodyRequestWrapper
(
wrapped
));
new
FormBodyRequestWrapper
(
wrapped
));
}
catch
(
IllegalAccessException
ex
)
{
Throwables
.
propagate
(
ex
);
}
}
}
else
{
else
{
ctx
.
setRequest
(
new
FormBodyRequestWrapper
(
request
));
ctx
.
setRequest
(
new
FormBodyRequestWrapper
(
request
));
...
...
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/pre/Servlet30WrapperFilter.java
View file @
63e6c813
...
@@ -33,7 +33,6 @@ import javax.servlet.http.Part;
...
@@ -33,7 +33,6 @@ import javax.servlet.http.Part;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
import
com.google.common.base.Throwables
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.ZuulFilter
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.context.RequestContext
;
import
com.netflix.zuul.http.HttpServletRequestWrapper
;
import
com.netflix.zuul.http.HttpServletRequestWrapper
;
...
@@ -53,7 +52,7 @@ public class Servlet30WrapperFilter extends ZuulFilter {
...
@@ -53,7 +52,7 @@ public class Servlet30WrapperFilter extends ZuulFilter {
}
}
protected
Field
getRequestField
()
{
protected
Field
getRequestField
()
{
return
requestField
;
return
this
.
requestField
;
}
}
@Override
@Override
...
@@ -76,15 +75,10 @@ public class Servlet30WrapperFilter extends ZuulFilter {
...
@@ -76,15 +75,10 @@ public class Servlet30WrapperFilter extends ZuulFilter {
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
RequestContext
ctx
=
RequestContext
.
getCurrentContext
();
HttpServletRequest
request
=
ctx
.
getRequest
();
HttpServletRequest
request
=
ctx
.
getRequest
();
if
(
request
instanceof
HttpServletRequestWrapper
)
{
if
(
request
instanceof
HttpServletRequestWrapper
)
{
try
{
request
=
(
HttpServletRequest
)
ReflectionUtils
.
getField
(
this
.
requestField
,
request
=
(
HttpServletRequest
)
this
.
requestField
.
get
(
request
);
request
);
}
catch
(
IllegalAccessException
ex
)
{
Throwables
.
propagate
(
ex
);
}
}
}
ctx
.
setRequest
(
new
Servlet30RequestWrapper
(
request
));
ctx
.
setRequest
(
new
Servlet30RequestWrapper
(
request
));
// ctx.setResponse(new HttpServletResponseWrapper(ctx.getResponse()));
return
null
;
return
null
;
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/archaius/ArchaiusAutoConfigurationTests.java
View file @
63e6c813
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
package
org
.
springframework
.
cloud
.
netflix
.
archaius
;
package
org
.
springframework
.
cloud
.
netflix
.
archaius
;
import
com.google.common.collect.Set
s
;
import
java.util.Collection
s
;
import
com.netflix.config.ConfigurationManager
;
import
org.apache.commons.configuration.AbstractConfiguration
;
import
org.apache.commons.configuration.AbstractConfiguration
;
import
org.apache.commons.configuration.event.ConfigurationEvent
;
import
org.apache.commons.configuration.event.ConfigurationEvent
;
import
org.apache.commons.configuration.event.ConfigurationListener
;
import
org.apache.commons.configuration.event.ConfigurationListener
;
...
@@ -27,6 +27,8 @@ import org.springframework.boot.test.EnvironmentTestUtils;
...
@@ -27,6 +27,8 @@ import org.springframework.boot.test.EnvironmentTestUtils;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
com.netflix.config.ConfigurationManager
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
@@ -58,17 +60,20 @@ public class ArchaiusAutoConfigurationTests {
...
@@ -58,17 +60,20 @@ public class ArchaiusAutoConfigurationTests {
public
void
environmentChangeEventPropagated
()
{
public
void
environmentChangeEventPropagated
()
{
this
.
context
=
new
AnnotationConfigApplicationContext
(
this
.
context
=
new
AnnotationConfigApplicationContext
(
ArchaiusAutoConfiguration
.
class
);
ArchaiusAutoConfiguration
.
class
);
ConfigurationManager
.
getConfigInstance
().
addConfigurationListener
(
new
ConfigurationListener
()
{
ConfigurationManager
.
getConfigInstance
().
addConfigurationListener
(
@Override
new
ConfigurationListener
()
{
public
void
configurationChanged
(
ConfigurationEvent
event
)
{
@Override
if
(
event
.
getPropertyName
().
equals
(
"my.prop"
))
{
public
void
configurationChanged
(
ConfigurationEvent
event
)
{
propertyValue
=
event
.
getPropertyValue
();
if
(
event
.
getPropertyName
().
equals
(
"my.prop"
))
{
}
ArchaiusAutoConfigurationTests
.
this
.
propertyValue
=
event
}
.
getPropertyValue
();
});
}
EnvironmentTestUtils
.
addEnvironment
(
context
,
"my.prop=my.newval"
);
}
context
.
publishEvent
(
new
EnvironmentChangeEvent
(
Sets
.
newHashSet
(
"my.prop"
)));
});
assertEquals
(
"my.newval"
,
propertyValue
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"my.prop=my.newval"
);
this
.
context
.
publishEvent
(
new
EnvironmentChangeEvent
(
Collections
.
singleton
(
"my.prop"
)));
assertEquals
(
"my.newval"
,
this
.
propertyValue
);
}
}
}
}
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/hystrix/HystrixOnlyTests.java
View file @
63e6c813
...
@@ -71,21 +71,21 @@ public class HystrixOnlyTests {
...
@@ -71,21 +71,21 @@ public class HystrixOnlyTests {
@Test
@Test
public
void
testHystrixHealth
()
{
public
void
testHystrixHealth
()
{
Map
map
=
getHealth
();
Map
<?,
?>
map
=
getHealth
();
assertTrue
(
"Missing hystrix health key"
,
map
.
containsKey
(
"hystrix"
));
assertTrue
(
"Missing hystrix health key"
,
map
.
containsKey
(
"hystrix"
));
Map
hystrix
=
(
Map
)
map
.
get
(
"hystrix"
);
Map
<?,
?>
hystrix
=
(
Map
<?,
?>
)
map
.
get
(
"hystrix"
);
assertEquals
(
"Wrong hystrix status"
,
"UP"
,
hystrix
.
get
(
"status"
));
assertEquals
(
"Wrong hystrix status"
,
"UP"
,
hystrix
.
get
(
"status"
));
}
}
@Test
@Test
public
void
testNoDiscoveryHealth
()
{
public
void
testNoDiscoveryHealth
()
{
Map
map
=
getHealth
();
Map
<?,
?>
map
=
getHealth
();
// There is explicitly no discovery, so there should be no discovery health key
// There is explicitly no discovery, so there should be no discovery health key
assertFalse
(
"Incorrect existing discovery health key"
,
assertFalse
(
"Incorrect existing discovery health key"
,
map
.
containsKey
(
"discovery"
));
map
.
containsKey
(
"discovery"
));
}
}
private
Map
getHealth
()
{
private
Map
<?,
?>
getHealth
()
{
return
new
TestRestTemplate
().
getForObject
(
"http://localhost:"
+
this
.
port
return
new
TestRestTemplate
().
getForObject
(
"http://localhost:"
+
this
.
port
+
"/admin/health"
,
Map
.
class
);
+
"/admin/health"
,
Map
.
class
);
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/RibbonInterceptorTests.java
View file @
63e6c813
...
@@ -32,9 +32,9 @@ import org.springframework.http.HttpRequest;
...
@@ -32,9 +32,9 @@ import org.springframework.http.HttpRequest;
import
org.springframework.http.client.ClientHttpRequestExecution
;
import
org.springframework.http.client.ClientHttpRequestExecution
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.client.ClientHttpResponse
;
import
org.springframework.http.client.support.HttpRequestWrapper
;
import
org.springframework.http.client.support.HttpRequestWrapper
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
org.springframework.web.util.UriComponentsBuilder
;
import
com.google.common.base.Throwables
;
import
com.netflix.loadbalancer.Server
;
import
com.netflix.loadbalancer.Server
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
@@ -99,7 +99,7 @@ public class RibbonInterceptorTests {
...
@@ -99,7 +99,7 @@ public class RibbonInterceptorTests {
return
request
.
apply
(
this
.
instance
);
return
request
.
apply
(
this
.
instance
);
}
}
catch
(
Exception
ex
)
{
catch
(
Exception
ex
)
{
Throwables
.
propagate
(
ex
);
ReflectionUtils
.
rethrowRuntimeException
(
ex
);
}
}
return
null
;
return
null
;
}
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/ribbon/eureka/DomainExtractingServerListTests.java
View file @
63e6c813
...
@@ -17,11 +17,11 @@
...
@@ -17,11 +17,11 @@
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
eureka
;
package
org
.
springframework
.
cloud
.
netflix
.
ribbon
.
eureka
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.Test
;
import
com.google.common.collect.ImmutableMap
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.CommonClientConfigKey
;
import
com.netflix.client.config.DefaultClientConfigImpl
;
import
com.netflix.client.config.DefaultClientConfigImpl
;
...
@@ -72,8 +72,8 @@ public class DomainExtractingServerListTests {
...
@@ -72,8 +72,8 @@ public class DomainExtractingServerListTests {
assertEquals
(
"hostPort was wrong"
,
HOST_NAME
+
":"
+
PORT
,
des
.
getHostPort
());
assertEquals
(
"hostPort was wrong"
,
HOST_NAME
+
":"
+
PORT
,
des
.
getHostPort
());
}
}
protected
DomainExtractingServer
assertDomainExtractingServer
(
List
<
DiscoveryEnabledServer
>
servers
,
protected
DomainExtractingServer
assertDomainExtractingServer
(
String
zone
)
{
List
<
DiscoveryEnabledServer
>
servers
,
String
zone
)
{
Server
actualServer
=
servers
.
get
(
0
);
Server
actualServer
=
servers
.
get
(
0
);
assertTrue
(
"server was not a DomainExtractingServer"
,
assertTrue
(
"server was not a DomainExtractingServer"
,
actualServer
instanceof
DomainExtractingServer
);
actualServer
instanceof
DomainExtractingServer
);
...
@@ -105,8 +105,7 @@ public class DomainExtractingServerListTests {
...
@@ -105,8 +105,7 @@ public class DomainExtractingServerListTests {
given
(
server
.
getInstanceInfo
()).
willReturn
(
instanceInfo
);
given
(
server
.
getInstanceInfo
()).
willReturn
(
instanceInfo
);
given
(
server
.
getHost
()).
willReturn
(
HOST_NAME
);
given
(
server
.
getHost
()).
willReturn
(
HOST_NAME
);
given
(
instanceInfo
.
getMetadata
()).
willReturn
(
given
(
instanceInfo
.
getMetadata
()).
willReturn
(
ImmutableMap
.<
String
,
String
>
builder
().
put
(
"instanceId"
,
INSTANCE_ID
)
Collections
.<
String
,
String
>
singletonMap
(
"instanceId"
,
INSTANCE_ID
));
.
build
());
given
(
instanceInfo
.
getHostName
()).
willReturn
(
HOST_NAME
);
given
(
instanceInfo
.
getHostName
()).
willReturn
(
HOST_NAME
);
given
(
instanceInfo
.
getIPAddr
()).
willReturn
(
IP_ADDR
);
given
(
instanceInfo
.
getIPAddr
()).
willReturn
(
IP_ADDR
);
given
(
instanceInfo
.
getPort
()).
willReturn
(
PORT
);
given
(
instanceInfo
.
getPort
()).
willReturn
(
PORT
);
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/zuul/filters/ProxyRouteLocatorTests.java
View file @
63e6c813
...
@@ -16,20 +16,17 @@
...
@@ -16,20 +16,17 @@
package
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
;
package
org
.
springframework
.
cloud
.
netflix
.
zuul
.
filters
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mock
;
import
org.mockito.Mock
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.client.discovery.DiscoveryClient
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRouteLocator
;
import
org.springframework.cloud.netflix.zuul.filters.ZuulProperties
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRouteLocator.ProxyRouteSpec
;
import
org.springframework.cloud.netflix.zuul.filters.ProxyRouteLocator.ProxyRouteSpec
;
import
org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute
;
import
org.springframework.cloud.netflix.zuul.filters.ZuulProperties.ZuulRoute
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
org.springframework.core.env.ConfigurableEnvironment
;
import
com.google.common.collect.Lists
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
...
@@ -204,9 +201,9 @@ public class ProxyRouteLocatorTests {
...
@@ -204,9 +201,9 @@ public class ProxyRouteLocatorTests {
public
void
testIgnoreRoutes
()
{
public
void
testIgnoreRoutes
()
{
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
this
.
properties
);
this
.
properties
);
this
.
properties
.
setIgnoredServices
(
Lists
.
newArray
List
(
IGNOREDSERVICE
));
this
.
properties
.
setIgnoredServices
(
Collections
.
singleton
List
(
IGNOREDSERVICE
));
given
(
this
.
discovery
.
getServices
())
given
(
this
.
discovery
.
getServices
())
.
willReturn
(
.
willReturn
(
Lists
.
newArray
List
(
IGNOREDSERVICE
));
Collections
.
singleton
List
(
IGNOREDSERVICE
));
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
String
serviceId
=
routesMap
.
get
(
getMapping
(
IGNOREDSERVICE
));
String
serviceId
=
routesMap
.
get
(
getMapping
(
IGNOREDSERVICE
));
assertNull
(
"routes did not ignore "
+
IGNOREDSERVICE
,
serviceId
);
assertNull
(
"routes did not ignore "
+
IGNOREDSERVICE
,
serviceId
);
...
@@ -216,7 +213,8 @@ public class ProxyRouteLocatorTests {
...
@@ -216,7 +213,8 @@ public class ProxyRouteLocatorTests {
public
void
testAutoRoutes
()
{
public
void
testAutoRoutes
()
{
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
this
.
properties
);
this
.
properties
);
given
(
this
.
discovery
.
getServices
()).
willReturn
(
Lists
.
newArrayList
(
MYSERVICE
));
given
(
this
.
discovery
.
getServices
()).
willReturn
(
Collections
.
singletonList
(
MYSERVICE
));
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
...
@@ -230,7 +228,8 @@ public class ProxyRouteLocatorTests {
...
@@ -230,7 +228,8 @@ public class ProxyRouteLocatorTests {
this
.
properties
.
getRoutes
().
put
(
MYSERVICE
,
route
);
this
.
properties
.
getRoutes
().
put
(
MYSERVICE
,
route
);
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
ProxyRouteLocator
routeLocator
=
new
ProxyRouteLocator
(
this
.
discovery
,
this
.
properties
);
this
.
properties
);
given
(
this
.
discovery
.
getServices
()).
willReturn
(
Lists
.
newArrayList
(
MYSERVICE
));
given
(
this
.
discovery
.
getServices
()).
willReturn
(
Collections
.
singletonList
(
MYSERVICE
));
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
Map
<
String
,
String
>
routesMap
=
routeLocator
.
getRoutes
();
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertNotNull
(
"routesMap was null"
,
routesMap
);
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
assertFalse
(
"routesMap was empty"
,
routesMap
.
isEmpty
());
...
...
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/EurekaServerConfiguration.java
View file @
63e6c813
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
cloud
.
netflix
.
eureka
.
server
;
package
org
.
springframework
.
cloud
.
netflix
.
eureka
.
server
;
import
java.util.Collections
;
import
javax.servlet.Filter
;
import
javax.servlet.Filter
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Qualifier
;
...
@@ -30,7 +32,6 @@ import org.springframework.context.annotation.Import;
...
@@ -30,7 +32,6 @@ import org.springframework.context.annotation.Import;
import
org.springframework.core.Ordered
;
import
org.springframework.core.Ordered
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
import
com.google.common.collect.Lists
;
import
com.sun.jersey.spi.container.servlet.ServletContainer
;
import
com.sun.jersey.spi.container.servlet.ServletContainer
;
/**
/**
...
@@ -57,8 +58,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
...
@@ -57,8 +58,8 @@ public class EurekaServerConfiguration extends WebMvcConfigurerAdapter {
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css|js)/.*"
);
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/(fonts|images|css|js)/.*"
);
bean
.
addInitParameter
(
"com.sun.jersey.config.property.packages"
,
bean
.
addInitParameter
(
"com.sun.jersey.config.property.packages"
,
"com.netflix.discovery;com.netflix.eureka"
);
"com.netflix.discovery;com.netflix.eureka"
);
bean
.
setUrlPatterns
(
Lists
.
newArrayList
(
EurekaServerConfigBean
.
DEFAULT_PREFIX
bean
.
setUrlPatterns
(
Collections
+
"/*"
));
.
singletonList
(
EurekaServerConfigBean
.
DEFAULT_PREFIX
+
"/*"
));
return
bean
;
return
bean
;
}
}
...
...
spring-cloud-netflix-eureka-server/src/main/java/org/springframework/cloud/netflix/eureka/server/event/LeaseManagerMessageBroker.java
View file @
63e6c813
...
@@ -18,22 +18,17 @@ package org.springframework.cloud.netflix.eureka.server.event;
...
@@ -18,22 +18,17 @@ package org.springframework.cloud.netflix.eureka.server.event;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.Nullable
;
import
lombok.extern.apachecommons.CommonsLog
;
import
lombok.extern.apachecommons.CommonsLog
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.netflix.eureka.server.advice.LeaseManagerLite
;
import
org.springframework.cloud.netflix.eureka.server.advice.LeaseManagerLite
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContext
;
import
com.google.common.base.Optional
;
import
com.google.common.base.Predicate
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.appinfo.InstanceInfo
;
import
com.netflix.discovery.shared.Application
;
import
com.netflix.discovery.shared.Application
;
import
com.netflix.eureka.PeerAwareInstanceRegistry
;
import
com.netflix.eureka.PeerAwareInstanceRegistry
;
import
com.netflix.eureka.lease.Lease
;
import
com.netflix.eureka.lease.Lease
;
import
static
com
.
google
.
common
.
collect
.
Iterables
.
tryFind
;
/**
/**
* @author Spencer Gibb
* @author Spencer Gibb
*/
*/
...
@@ -73,22 +68,19 @@ public class LeaseManagerMessageBroker implements LeaseManagerLite<InstanceInfo>
...
@@ -73,22 +68,19 @@ public class LeaseManagerMessageBroker implements LeaseManagerLite<InstanceInfo>
+
isReplication
);
+
isReplication
);
List
<
Application
>
applications
=
PeerAwareInstanceRegistry
.
getInstance
()
List
<
Application
>
applications
=
PeerAwareInstanceRegistry
.
getInstance
()
.
getSortedApplications
();
.
getSortedApplications
();
Optional
<
Application
>
app
=
tryFind
(
applications
,
new
Predicate
<
Application
>()
{
for
(
Application
input
:
applications
)
{
@Override
if
(
input
.
getName
().
equals
(
appName
))
{
public
boolean
apply
(
@Nullable
Application
input
)
{
InstanceInfo
instance
=
null
;
return
input
.
getName
().
equals
(
appName
);
for
(
InstanceInfo
info
:
input
.
getInstances
())
{
if
(
info
.
getHostName
().
equals
(
serverId
))
{
instance
=
info
;
break
;
}
}
this
.
ctxt
.
publishEvent
(
new
EurekaInstanceRenewedEvent
(
this
,
appName
,
serverId
,
instance
,
isReplication
));
break
;
}
}
});
if
(
app
.
isPresent
())
{
Optional
<
InstanceInfo
>
info
=
tryFind
(
app
.
get
().
getInstances
(),
new
Predicate
<
InstanceInfo
>()
{
@Override
public
boolean
apply
(
@Nullable
InstanceInfo
input
)
{
return
input
.
getHostName
().
equals
(
serverId
);
}
});
this
.
ctxt
.
publishEvent
(
new
EurekaInstanceRenewedEvent
(
this
,
appName
,
serverId
,
info
.
orNull
(),
isReplication
));
}
}
return
false
;
return
false
;
}
}
...
...
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