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
edcd974f
Commit
edcd974f
authored
Jul 08, 2016
by
Jason Song
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter out properties comment for config file
parent
29f2ad94
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
3 deletions
+23
-3
PropertiesConfigFile.java
...trip/framework/apollo/internals/PropertiesConfigFile.java
+23
-3
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/PropertiesConfigFile.java
View file @
edcd974f
...
...
@@ -41,17 +41,37 @@ public class PropertiesConfigFile extends AbstractConfigFile {
StringWriter
writer
=
new
StringWriter
();
try
{
m_configProperties
.
get
().
store
(
writer
,
null
);
return
writer
.
getBuffer
().
toString
();
StringBuffer
stringBuffer
=
writer
.
getBuffer
();
filterPropertiesComment
(
stringBuffer
);
return
stringBuffer
.
toString
();
}
catch
(
IOException
ex
)
{
ApolloConfigException
exception
=
new
ApolloConfigException
(
String
.
format
(
"Parse properties file content failed for namespace: %s, cause: %s"
,
m_namespace
,
ExceptionUtil
.
getDetailMessage
(
ex
)));
.
format
(
"Parse properties file content failed for namespace: %s, cause: %s"
,
m_namespace
,
ExceptionUtil
.
getDetailMessage
(
ex
)));
Cat
.
logError
(
exception
);
throw
exception
;
}
}
/**
* filter out the first comment line
* @param stringBuffer the string buffer
* @return true if filtered successfully, false otherwise
*/
boolean
filterPropertiesComment
(
StringBuffer
stringBuffer
)
{
//check whether has comment in the first line
if
(
stringBuffer
.
charAt
(
0
)
!=
'#'
)
{
return
false
;
}
int
commentLineIndex
=
stringBuffer
.
indexOf
(
"\n"
);
if
(
commentLineIndex
==
-
1
)
{
return
false
;
}
stringBuffer
.
delete
(
0
,
commentLineIndex
+
1
);
return
true
;
}
@Override
public
boolean
hasContent
()
{
...
...
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