Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
2b14a3df
Commit
2b14a3df
authored
May 03, 2020
by
吴梦升
Committed by
Jason Song
May 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[修改]针对配置未发布场景取消重试和mockhttputil异常与业务实现保持一致
parent
aa184a2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
1 deletion
+20
-1
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
...ip/framework/apollo/internals/RemoteConfigRepository.java
+4
-0
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
...ramework/apollo/internals/RemoteConfigRepositoryTest.java
+16
-1
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java
View file @
2b14a3df
...
...
@@ -182,6 +182,7 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
List
<
ServiceDTO
>
configServices
=
getConfigServices
();
String
url
=
null
;
retryLoopLabel:
for
(
int
i
=
0
;
i
<
maxRetries
;
i
++)
{
List
<
ServiceDTO
>
randomConfigServices
=
Lists
.
newLinkedList
(
configServices
);
Collections
.
shuffle
(
randomConfigServices
);
...
...
@@ -249,6 +250,9 @@ public class RemoteConfigRepository extends AbstractConfigRepository {
Tracer
.
logEvent
(
"ApolloConfigException"
,
ExceptionUtil
.
getDetailMessage
(
statusCodeException
));
transaction
.
setStatus
(
statusCodeException
);
exception
=
statusCodeException
;
if
(
ex
.
getStatusCode
()
==
404
)
{
break
retryLoopLabel
;
}
}
catch
(
Throwable
ex
)
{
Tracer
.
logEvent
(
"ApolloConfigException"
,
ExceptionUtil
.
getDetailMessage
(
ex
));
transaction
.
setStatus
(
ex
);
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/RemoteConfigRepositoryTest.java
View file @
2b14a3df
...
...
@@ -22,6 +22,7 @@ import com.ctrip.framework.apollo.core.dto.ServiceDTO;
import
com.ctrip.framework.apollo.core.signature.Signature
;
import
com.ctrip.framework.apollo.enums.ConfigSourceType
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigException
;
import
com.ctrip.framework.apollo.exceptions.ApolloConfigStatusCodeException
;
import
com.ctrip.framework.apollo.util.ConfigUtil
;
import
com.ctrip.framework.apollo.util.OrderedProperties
;
import
com.ctrip.framework.apollo.util.factory.PropertiesFactory
;
...
...
@@ -208,6 +209,19 @@ public class RemoteConfigRepositoryTest {
remoteConfigRepository
.
getConfig
();
}
@Test
(
expected
=
ApolloConfigException
.
class
)
public
void
testGetRemoteConfigWithNotFount
()
throws
Exception
{
when
(
someResponse
.
getStatusCode
()).
thenReturn
(
404
);
RemoteConfigRepository
remoteConfigRepository
=
new
RemoteConfigRepository
(
someNamespace
);
//must stop the long polling before exception occurred
remoteConfigLongPollService
.
stopLongPollingRefresh
();
remoteConfigRepository
.
getConfig
();
}
@Test
public
void
testRepositoryChangeListener
()
throws
Exception
{
Map
<
String
,
String
>
configurations
=
ImmutableMap
.
of
(
"someKey"
,
"someValue"
);
...
...
@@ -394,7 +408,8 @@ public class RemoteConfigRepositoryTest {
if
(
someResponse
.
getStatusCode
()
==
200
||
someResponse
.
getStatusCode
()
==
304
)
{
return
(
HttpResponse
<
T
>)
someResponse
;
}
throw
new
ApolloConfigException
(
String
.
format
(
"Http request failed due to status code: %d"
,
throw
new
ApolloConfigStatusCodeException
(
someResponse
.
getStatusCode
(),
String
.
format
(
"Http request failed due to status code: %d"
,
someResponse
.
getStatusCode
()));
}
...
...
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