hanicz commented on code in PR #1069:
URL: https://github.com/apache/knox/pull/1069#discussion_r2242888393
##########
gateway-server/src/main/java/org/apache/knox/gateway/services/token/impl/ZookeeperTokenStateService.java:
##########
@@ -58,14 +62,46 @@ public ZookeeperTokenStateService(GatewayServices
gatewayServices, AliasServiceF
@Override
public void init(GatewayConfig config, Map<String, String> options) throws
ServiceLifecycleException {
log.deprecatedServiceUsage(this.getClass().getCanonicalName());
- final ZookeeperRemoteAliasService zookeeperAliasService =
(ZookeeperRemoteAliasService) aliasServiceFactory.create(gatewayServices,
ALIAS_SERVICE, config, options,
+
+ final Object createdService = aliasServiceFactory.create(gatewayServices,
ALIAS_SERVICE, config, options,
ZookeeperRemoteAliasService.class.getName());
+
+ if (createdService == null) {
+ throw new ServiceLifecycleException("aliasServiceFactory.create()
returned null - cannot create ZookeeperRemoteAliasService");
+ }
+
+ if (!(createdService instanceof ZookeeperRemoteAliasService)) {
+ throw new ServiceLifecycleException("aliasServiceFactory.create()
returned unexpected type: " + createdService.getClass().getName() +
+ ", expected: ZookeeperRemoteAliasService");
+ }
+
+ final ZookeeperRemoteAliasService zookeeperAliasService =
(ZookeeperRemoteAliasService) createdService;
+
+
options.put(ZookeeperRemoteAliasService.OPTION_NAME_SHOULD_CREATE_TOKENS_SUB_NODE,
"true");
options.put(ZookeeperRemoteAliasService.OPTION_NAME_SHOULD_USE_LOCAL_ALIAS,
"false");
- zookeeperAliasService.registerRemoteTokenStateChangeListener(this);
- zookeeperAliasService.init(config, options);
- super.setAliasService(zookeeperAliasService);
- super.init(config, options);
+
+ try {
Review Comment:
These try-catches don't seem to address anything.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]