Skip to content

Commit

Permalink
Update ServiceManager.java
Browse files Browse the repository at this point in the history
optimize service conflict error message, see like[https://github.com/apache/skywalking/issues/10991],
some times the service conflict will print error message to the skywalking-api.log, but not enough to find which service conflict
  • Loading branch information
wongtp committed Jan 19, 2024
1 parent d5b99f9 commit f182795
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,20 @@ private Map<Class, BootService> loadAllServices() {
throw new ServiceConflictException("Duplicate service define for :" + bootServiceClass);
}
} else {
Class<? extends BootService> targetService = overrideImplementor.value();
if (bootedServices.containsKey(targetService)) {
boolean presentDefault = bootedServices.get(targetService)
.getClass()
.isAnnotationPresent(DefaultImplementor.class);
Class<? extends BootService> targetServiceClass = overrideImplementor.value();
if (bootedServices.containsKey(targetServiceClass)) {
BootService previousService = bootedServices.get(targetServiceClass);
boolean presentDefault = previousService.getClass().isAnnotationPresent(DefaultImplementor.class);
if (presentDefault) {
bootedServices.put(targetService, bootService);
bootedServices.put(targetServiceClass, bootService);
} else {
throw new ServiceConflictException(
"Service " + bootServiceClass + " overrides conflict, " + "exist more than one service want to override :" + targetService);
String errorMsg = String.format("Service %s overrides conflict, more then one service found, " +
"service[%s] want to override[%s], please check your plugins",
bootServiceClass, targetServiceClass, previousService.getClass());
throw new ServiceConflictException(errorMsg);
}
} else {
bootedServices.put(targetService, bootService);
bootedServices.put(targetServiceClass , bootService);
}
}
}
Expand Down

0 comments on commit f182795

Please sign in to comment.