[
https://issues.apache.org/jira/browse/SCB-1014?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16683102#comment-16683102
]
ASF GitHub Bot commented on SCB-1014:
-------------------------------------
wujimin commented on a change in pull request #985: [SCB-1014] Fix priority of
ExceptionToResponseConverter
URL:
https://github.com/apache/servicecomb-java-chassis/pull/985#discussion_r232515285
##########
File path:
swagger/swagger-invocation/invocation-core/src/main/java/org/apache/servicecomb/swagger/invocation/exception/ExceptionToProducerResponseConverters.java
##########
@@ -23,31 +23,37 @@
import org.apache.servicecomb.swagger.invocation.Response;
import org.apache.servicecomb.swagger.invocation.SwaggerInvocation;
-public class ExceptionToResponseConverters {
- private Map<Class<?>, ExceptionToResponseConverter<Throwable>>
exceptionToResponseConverters =
+public class ExceptionToProducerResponseConverters {
+ private Map<Class<?>, ExceptionToProducerResponseConverter<Throwable>>
exceptionToProducerResponseConverters =
new HashMap<>();
- private ExceptionToResponseConverter<Throwable> defaultConverter;
+ private ExceptionToProducerResponseConverter<Throwable> defaultConverter;
+ /**
+ * Load the {@link ExceptionToProducerResponseConverter} implementations.
Ensure that those converters whose {@link
ExceptionToProducerResponseConverter#getOrder()}
+ * return smaller value takes higher priority.
+ */
@SuppressWarnings("unchecked")
- public ExceptionToResponseConverters() {
-
SPIServiceUtils.getSortedService(ExceptionToResponseConverter.class).forEach(converter
-> {
+ public ExceptionToProducerResponseConverters() {
+
SPIServiceUtils.getSortedService(ExceptionToProducerResponseConverter.class).forEach(converter
-> {
if (converter.getExceptionClass() == null) {
if (defaultConverter == null) {
defaultConverter = converter;
}
return;
}
- exceptionToResponseConverters.put(converter.getExceptionClass(),
converter);
+ if
(!exceptionToProducerResponseConverters.containsKey(converter.getExceptionClass()))
{
Review comment:
java.util.Map#putIfAbsent
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Fix priority problem of ExceptionToResponseConverter
> ----------------------------------------------------
>
> Key: SCB-1014
> URL: https://issues.apache.org/jira/browse/SCB-1014
> Project: Apache ServiceComb
> Issue Type: Bug
> Reporter: YaoHaishi
> Assignee: YaoHaishi
> Priority: Major
>
> Currently the priority rule of default ExceptionToResponseConverter is that
> the smaller the order is, the higher the priority is. But the other common
> ExceptionToResponseConverters obey the contrary priority rule.
> We need to modify the implementation logic of ExceptionToResponseConverters
> to make sure the two kinds of ExceptionToResponseConverters obey the same
> priority rule.
> And the name of ExceptionToResponseConverter will be changed to remind users
> to be aware of the modification.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)