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
79f939be
Commit
79f939be
authored
Jul 27, 2015
by
Spencer Gibb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #455 from jmnarloch/service-path
* service-path: Specifing only the serviceId causes NPE
parents
371f8b3b
798a19e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
FeignClientsRegistrar.java
...gframework/cloud/netflix/feign/FeignClientsRegistrar.java
+4
-3
FeignClientTests.java
...framework/cloud/netflix/feign/valid/FeignClientTests.java
+20
-1
No files found.
spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/feign/FeignClientsRegistrar.java
View file @
79f939be
...
...
@@ -43,6 +43,7 @@ import org.springframework.util.StringUtils;
/**
* @author Spencer Gibb
* @author Jakub Narloch
*/
public
class
FeignClientsRegistrar
implements
ImportBeanDefinitionRegistrar
,
ResourceLoaderAware
,
BeanClassLoaderAware
{
...
...
@@ -115,13 +116,13 @@ public class FeignClientsRegistrar implements ImportBeanDefinitionRegistrar,
private
void
validate
(
Map
<
String
,
Object
>
attributes
)
{
if
(
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"value"
)))
{
Assert
.
isTrue
(!
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"
name
"
)),
"Either
name
or value can be specified, but not both"
);
Assert
.
isTrue
(!
StringUtils
.
hasText
((
String
)
attributes
.
get
(
"
serviceId
"
)),
"Either
serviceId
or value can be specified, but not both"
);
}
}
private
String
getServiceId
(
Map
<
String
,
Object
>
attributes
)
{
String
name
=
(
String
)
attributes
.
get
(
"
name
"
);
String
name
=
(
String
)
attributes
.
get
(
"
serviceId
"
);
if
(!
StringUtils
.
hasText
(
name
))
{
name
=
(
String
)
attributes
.
get
(
"value"
);
}
...
...
spring-cloud-netflix-core/src/test/java/org/springframework/cloud/netflix/feign/valid/FeignClientTests.java
View file @
79f939be
...
...
@@ -16,7 +16,8 @@
package
org
.
springframework
.
cloud
.
netflix
.
feign
.
valid
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
hamcrest
.
Matchers
.
instanceOf
;
import
static
org
.
hamcrest
.
Matchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
...
...
@@ -65,6 +66,7 @@ import feign.RequestTemplate;
/**
* @author Spencer Gibb
* @author Jakub Narloch
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@SpringApplicationConfiguration
(
classes
=
FeignClientTests
.
Application
.
class
)
...
...
@@ -81,6 +83,9 @@ public class FeignClientTests {
private
TestClient
testClient
;
@Autowired
private
TestClientServiceId
testClientServiceId
;
@Autowired
private
Client
feignClient
;
// @FeignClient(value = "http://localhost:9876", loadbalance = false)
...
...
@@ -99,6 +104,12 @@ public class FeignClientTests {
public
List
<
String
>
getHelloHeaders
();
}
@FeignClient
(
serviceId
=
"localapp"
)
protected
static
interface
TestClientServiceId
{
@RequestMapping
(
method
=
RequestMethod
.
GET
,
value
=
"/hello"
)
public
Hello
getHello
();
}
@Configuration
@EnableAutoConfiguration
@RestController
...
...
@@ -210,6 +221,14 @@ public class FeignClientTests {
assertThat
(
delegate
,
is
(
instanceOf
(
feign
.
Client
.
Default
.
class
)));
}
@Test
public
void
testServiceId
()
{
assertNotNull
(
"testClientServiceId was null"
,
testClientServiceId
);
final
Hello
hello
=
testClientServiceId
.
getHello
();
assertNotNull
(
"The hello response was null"
,
hello
);
assertEquals
(
"first hello didn't match"
,
new
Hello
(
"hello world 1"
),
hello
);
}
@Data
@AllArgsConstructor
@NoArgsConstructor
...
...
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