Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
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
apollo
Commits
c91f6904
Commit
c91f6904
authored
Dec 22, 2016
by
Jason Song
Committed by
GitHub
Dec 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #494 from lepdou/bugfix_1222
bugfix: return empty element array when get array property
parents
451fd882
25bc5588
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
9 deletions
+10
-9
RefreshableConfig.java
...rip/framework/apollo/common/config/RefreshableConfig.java
+5
-4
PortalConfig.java
...amework/apollo/portal/components/config/PortalConfig.java
+4
-4
ConfigTest.java
.../com/ctrip/framework/apollo/portal/config/ConfigTest.java
+1
-1
No files found.
apollo-common/src/main/java/com/ctrip/framework/apollo/common/config/RefreshableConfig.java
View file @
c91f6904
...
...
@@ -5,6 +5,7 @@ import com.google.common.base.Splitter;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.base.Strings
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -90,13 +91,13 @@ public abstract class RefreshableConfig {
}
}
public
String
[]
getArrayProperty
(
String
key
,
String
defaultValue
)
{
public
String
[]
getArrayProperty
(
String
key
,
String
[]
defaultValue
)
{
try
{
String
configuration
=
getValue
(
key
,
defaultValue
);
return
configuration
.
split
(
LIST_SEPARATOR
);
String
value
=
getValue
(
key
);
return
Strings
.
isNullOrEmpty
(
value
)
?
defaultValue
:
value
.
split
(
LIST_SEPARATOR
);
}
catch
(
Exception
e
)
{
Tracer
.
logError
(
"Get array property failed."
,
e
);
return
defaultValue
.
split
(
LIST_SEPARATOR
)
;
return
defaultValue
;
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/config/PortalConfig.java
View file @
c91f6904
...
...
@@ -43,10 +43,10 @@ public class PortalConfig extends RefreshableConfig {
* Level: important
**/
public
List
<
Env
>
portalSupportedEnvs
()
{
String
[]
configuration
=
getArrayProperty
(
"apollo.portal.envs"
,
"FAT,UAT,PRO"
);
String
[]
configuration
s
=
getArrayProperty
(
"apollo.portal.envs"
,
new
String
[]{
"FAT"
,
"UAT"
,
"PRO"
}
);
List
<
Env
>
envs
=
Lists
.
newLinkedList
();
for
(
String
env
:
configuration
)
{
for
(
String
env
:
configuration
s
)
{
envs
.
add
(
Env
.
fromString
(
env
));
}
...
...
@@ -62,10 +62,10 @@ public class PortalConfig extends RefreshableConfig {
}
public
Set
<
Env
>
emailSupportedEnvs
()
{
String
[]
configurations
=
getArrayProperty
(
"email.supported.envs"
,
""
);
String
[]
configurations
=
getArrayProperty
(
"email.supported.envs"
,
null
);
Set
<
Env
>
result
=
Sets
.
newHashSet
();
if
(
StringUtils
.
isEmpty
(
configurations
)
)
{
if
(
configurations
==
null
||
configurations
.
length
==
0
)
{
return
result
;
}
...
...
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/config/ConfigTest.java
View file @
c91f6904
...
...
@@ -39,7 +39,7 @@ public class ConfigTest {
when
(
environment
.
getProperty
(
testKey
)).
thenReturn
(
testValue
);
String
[]
result
=
config
.
getArrayProperty
(
testKey
,
""
);
String
[]
result
=
config
.
getArrayProperty
(
testKey
,
null
);
Assert
.
assertEquals
(
3
,
result
.
length
);
Assert
.
assertEquals
(
"a"
,
result
[
0
]);
...
...
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