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
310f558e
Commit
310f558e
authored
Jun 12, 2017
by
Dave Syer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.3.x'
parents
1a0428da
4783b074
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
12 deletions
+38
-12
HystrixStreamAggregator.java
...cloud/netflix/turbine/stream/HystrixStreamAggregator.java
+22
-6
HystrixStreamAggregatorTests.java
.../netflix/turbine/stream/HystrixStreamAggregatorTests.java
+16
-6
No files found.
spring-cloud-netflix-turbine-stream/src/main/java/org/springframework/cloud/netflix/turbine/stream/HystrixStreamAggregator.java
View file @
310f558e
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
cloud
.
netflix
.
turbine
.
stream
;
package
org
.
springframework
.
cloud
.
netflix
.
turbine
.
stream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -56,18 +57,33 @@ public class HystrixStreamAggregator {
...
@@ -56,18 +57,33 @@ public class HystrixStreamAggregator {
payload
=
payload
.
replace
(
"\\\""
,
"\""
);
payload
=
payload
.
replace
(
"\\\""
,
"\""
);
}
}
try
{
try
{
@SuppressWarnings
(
"unchecked"
)
if
(
payload
.
startsWith
(
"["
))
{
Map
<
String
,
Object
>
map
=
this
.
objectMapper
.
readValue
(
payload
,
Map
.
class
);
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
data
=
getPayloadData
(
map
);
List
<
Map
<
String
,
Object
>>
list
=
this
.
objectMapper
.
readValue
(
payload
,
List
.
class
);
log
.
debug
(
"Received hystrix stream payload: "
+
data
);
for
(
Map
<
String
,
Object
>
map
:
list
)
{
this
.
subject
.
onNext
(
data
);
sendMap
(
map
);
}
}
else
{
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
map
=
this
.
objectMapper
.
readValue
(
payload
,
Map
.
class
);
sendMap
(
map
);
}
}
}
catch
(
IOException
ex
)
{
catch
(
IOException
ex
)
{
log
.
error
(
"Error receiving hystrix stream payload: "
+
payload
,
ex
);
log
.
error
(
"Error receiving hystrix stream payload: "
+
payload
,
ex
);
}
}
}
}
private
void
sendMap
(
Map
<
String
,
Object
>
map
)
{
Map
<
String
,
Object
>
data
=
getPayloadData
(
map
);
if
(
log
.
isDebugEnabled
())
{
log
.
debug
(
"Received hystrix stream payload: "
+
data
);
}
this
.
subject
.
onNext
(
data
);
}
public
static
Map
<
String
,
Object
>
getPayloadData
(
Map
<
String
,
Object
>
jsonMap
)
{
public
static
Map
<
String
,
Object
>
getPayloadData
(
Map
<
String
,
Object
>
jsonMap
)
{
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
Map
<
String
,
Object
>
origin
=
(
Map
<
String
,
Object
>)
jsonMap
.
get
(
"origin"
);
Map
<
String
,
Object
>
origin
=
(
Map
<
String
,
Object
>)
jsonMap
.
get
(
"origin"
);
...
...
spring-cloud-netflix-turbine-stream/src/test/java/org/springframework/cloud/netflix/turbine/stream/HystrixStreamAggregatorTests.java
View file @
310f558e
...
@@ -16,18 +16,19 @@
...
@@ -16,18 +16,19 @@
package
org
.
springframework
.
cloud
.
netflix
.
turbine
.
stream
;
package
org
.
springframework
.
cloud
.
netflix
.
turbine
.
stream
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
equalTo
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
java.util.Map
;
import
java.util.Map
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.rule.OutputCapture
;
import
org.springframework.boot.test.rule.OutputCapture
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
static
org
.
hamcrest
.
CoreMatchers
.
containsString
;
import
static
org
.
hamcrest
.
CoreMatchers
.
equalTo
;
import
static
org
.
hamcrest
.
CoreMatchers
.
not
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
rx.subjects.PublishSubject
;
import
rx.subjects.PublishSubject
;
...
@@ -53,6 +54,15 @@ public class HystrixStreamAggregatorTests {
...
@@ -53,6 +54,15 @@ public class HystrixStreamAggregatorTests {
}
}
@Test
@Test
public
void
messageWrappedInArray
()
throws
Exception
{
this
.
publisher
.
subscribe
(
map
->
{
assertThat
(
map
.
get
(
"type"
),
equalTo
(
"HystrixCommand"
));
});
this
.
aggregator
.
sendToSubject
(
"["
+
PAYLOAD
+
"]"
);
this
.
output
.
expect
(
not
(
containsString
(
"ERROR"
)));
}
@Test
public
void
doubleEncodedMessage
()
throws
Exception
{
public
void
doubleEncodedMessage
()
throws
Exception
{
this
.
publisher
.
subscribe
(
map
->
{
this
.
publisher
.
subscribe
(
map
->
{
assertThat
(
map
.
get
(
"type"
),
equalTo
(
"HystrixCommand"
));
assertThat
(
map
.
get
(
"type"
),
equalTo
(
"HystrixCommand"
));
...
...
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