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
b3acc139
Commit
b3acc139
authored
Jan 03, 2018
by
saga
Committed by
Ryan Baxter
Jan 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add check to prevent StackOverflowError (#2580)
parent
3abc89b9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
2 deletions
+52
-2
FeignClientsRegistrar.java
...gframework/cloud/netflix/feign/FeignClientsRegistrar.java
+8
-2
FeignClientsRegistrarTests.java
...ework/cloud/netflix/feign/FeignClientsRegistrarTests.java
+44
-0
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrar.java
View file @
b3acc139
...
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
cloud
.
netflix
.
feign
;
import
java.io.IOException
;
import
java.lang.annotation.Annotation
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
...
...
@@ -36,7 +35,6 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
import
org.springframework.beans.factory.support.BeanDefinitionBuilder
;
import
org.springframework.beans.factory.support.BeanDefinitionReaderUtils
;
import
org.springframework.beans.factory.support.BeanDefinitionRegistry
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.EnvironmentAware
;
import
org.springframework.context.ResourceLoaderAware
;
import
org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
;
...
...
@@ -208,6 +206,14 @@ class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
AnnotationAttributes
annotation
=
AnnotationAttributes
.
fromMap
(
attributes
);
// This blows up if an aliased property is overspecified
// FIXME annotation.getAliasedString("name", FeignClient.class, null);
Assert
.
isTrue
(
!
annotation
.
getClass
(
"fallback"
).
isInterface
(),
"Fallback class must implement the interface annotated by @FeignClient"
);
Assert
.
isTrue
(
!
annotation
.
getClass
(
"fallbackFactory"
).
isInterface
(),
"Fallback factory must produce instances of fallback classes that implement the interface annotated by @FeignClient"
);
}
/* for testing */
String
getName
(
Map
<
String
,
Object
>
attributes
)
{
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrarTests.java
View file @
b3acc139
...
...
@@ -20,13 +20,19 @@ package org.springframework.cloud.netflix.feign;
import
java.util.Collections
;
import
org.junit.Test
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.mock.env.MockEnvironment
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
/**
* @author Spencer Gibb
* @author Gang Li
*/
public
class
FeignClientsRegistrarTests
{
...
...
@@ -74,4 +80,42 @@ public class FeignClientsRegistrarTests {
registrar
.
setEnvironment
(
new
MockEnvironment
());
return
registrar
.
getName
(
Collections
.<
String
,
Object
>
singletonMap
(
"name"
,
name
));
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testFallback
()
{
new
AnnotationConfigApplicationContext
(
FallbackTestConfig
.
class
);
}
@Test
(
expected
=
IllegalArgumentException
.
class
)
public
void
testFallbackFactory
()
{
new
AnnotationConfigApplicationContext
(
FallbackFactoryTestConfig
.
class
);
}
@Configuration
@EnableAutoConfiguration
@EnableFeignClients
(
clients
=
{
FeignClientsRegistrarTests
.
FallbackClient
.
class
})
protected
static
class
FallbackTestConfig
{
}
@FeignClient
(
name
=
"fallbackTestClient"
,
url
=
"http://localhost:8080/"
,
fallback
=
FallbackClient
.
class
)
protected
interface
FallbackClient
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
String
fallbackTest
();
}
@Configuration
@EnableAutoConfiguration
@EnableFeignClients
(
clients
=
{
FeignClientsRegistrarTests
.
FallbackFactoryClient
.
class
})
protected
static
class
FallbackFactoryTestConfig
{
}
@FeignClient
(
name
=
"fallbackFactoryTestClient"
,
url
=
"http://localhost:8081/"
,
fallbackFactory
=
FallbackFactoryClient
.
class
)
protected
interface
FallbackFactoryClient
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
String
fallbackFactoryTest
();
}
}
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