Upgrade Guava library to version 32.0.0-jre-router pod#16118
Upgrade Guava library to version 32.0.0-jre-router pod#16118AbhishekKumar9984 wants to merge 2 commits into
Conversation
| Object future = service.getClass().getMethod("start").invoke(service); | ||
| if (future instanceof ListenableFuture) { | ||
| ((ListenableFuture<?>) future).get(); | ||
| } |
There was a problem hiding this comment.
Why are we using reflection to call method of service?
| service.getClass().getMethod("awaitTerminated").invoke(service); | ||
| } catch (NoSuchMethodException e) { | ||
| // Guava 13 | ||
| Object future = service.getClass().getMethod("stop").invoke(service); |
There was a problem hiding this comment.
We anyways are upgrading to guava 32.0.0, which won't be compatible to older 12 or 13 versions.
Do we need to handle this exception?
| // If internal authorization enforcement is enabled, we avoid re-initialization of the token manager. | ||
| if (SecurityUtil.isManagedSecurity(cConf) && !SecurityUtil.isInternalAuthEnabled(cConf)) { | ||
| tokenValidator.startAndWait(); | ||
| io.cdap.cdap.common.service.Services.startAndWait(tokenValidator); |
| if (SecurityUtil.isManagedSecurity(cConf) && !SecurityUtil.isInternalAuthEnabled(cConf)) { | ||
| tokenValidator.stopAndWait(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(tokenValidator); | ||
|
|
| } catch (Throwable t) { | ||
| LOG.error(t.getMessage(), t); | ||
| throw Throwables.propagate(t); | ||
| throw new RuntimeException(t); |
There was a problem hiding this comment.
also add Throwables.propagateIfUnchecked
| + "cdap-site.xml. Currently configured as: %s", | ||
| zkClientService.getConnectString())); | ||
| router.startAndWait(); | ||
| io.cdap.cdap.common.service.Services.startAndWait(router); |
| datasetService = injector.getInstance(DatasetService.class); | ||
| datasetService.startAndWait(); | ||
| io.cdap.cdap.common.service.Services.startAndWait(datasetService); | ||
|
|
| io.cdap.cdap.common.service.Services.stopAndWait(logQueryService); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(datasetService); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(dsOpService); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(transactionManager); |
| @Override | ||
| public void handleError(Throwable cause) { | ||
| throw Throwables.propagate(cause); | ||
| throw new RuntimeException(cause); |
There was a problem hiding this comment.
add throwables.propageIfunchecked
| io.cdap.cdap.common.service.Services.stopAndWait((Service) messagingService); | ||
| } | ||
| conf.clear(); | ||
| } |
There was a problem hiding this comment.
add import statement instead of using the fully qualified class name
| return UserGroupInformation.getCurrentUser().getShortUserName(); | ||
| } catch (IOException e) { | ||
| throw Throwables.propagate(e); | ||
| throw new RuntimeException(e); |
There was a problem hiding this comment.
add propagateIfUnchecked before RuntimeException
| userId = UserGroupInformation.getCurrentUser().getShortUserName(); | ||
| } catch (IOException e) { | ||
| throw Throwables.propagate(e); | ||
| throw new RuntimeException(e); |
| + "identifier=" + identifier | ||
| + ", keyId=" + keyId | ||
| + ", digest=" + Bytes.toStringBinary(digest) | ||
| + "}"; |
There was a problem hiding this comment.
Can we use toStringHelper method from MoreObjects class?
| <exclude>third-party-licenses/**</exclude> | ||
| <exclude>.gitpod.yml</exclude> | ||
| <exclude>.gitpod.Dockerfile</exclude> | ||
| <exclude>**/target/**</exclude> |
|
|
||
| Stopwatch watch = new Stopwatch().start(); | ||
| while (!isPresent && watch.elapsedTime(TimeUnit.MILLISECONDS) < timeToWaitMillis) { | ||
| long startTime = System.currentTimeMillis(); |
There was a problem hiding this comment.
In latest guava version Stopwatch.createStarted() method is available. Can we use that?
|
|
||
| ZKClientService zkClient2 = injector2.getInstance(ZKClientService.class); | ||
| zkClient2.startAndWait(); | ||
| io.cdap.cdap.common.service.Services.startAndWait(zkClient2); |
There was a problem hiding this comment.
add fully qualified class name in import
| // create 2 cache instances | ||
| ZKClientService zkClient1 = injector1.getInstance(ZKClientService.class); | ||
| zkClient1.startAndWait(); | ||
| io.cdap.cdap.common.service.Services.startAndWait(zkClient1); |
There was a problem hiding this comment.
add fully qualified class name in import
| io.cdap.cdap.common.service.Services.stopAndWait(dsOpService); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(transactionManager); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(metrics); | ||
| conf.clear(); |
There was a problem hiding this comment.
add fully qualified class name in import
| httpService.stop(); | ||
| router.stopAndWait(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(router); | ||
| } |
There was a problem hiding this comment.
add fully qualified class name in import
| @Override | ||
| protected void shutDown() { | ||
| router.stopAndWait(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(router); |
There was a problem hiding this comment.
add fully qualified class name in import
| @Override | ||
| protected void shutDown() { | ||
| router.stopAndWait(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(router); |
There was a problem hiding this comment.
add fully qualified class name in import
| router2.stopAndWait(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(router1); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(router2); | ||
|
|
There was a problem hiding this comment.
add fully qualified class name in import
| io.cdap.cdap.common.service.Services.stopAndWait(mockService); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
add fully qualified class name in import
| + ", issueTimestamp=" + issueTimestamp | ||
| + ", expireTimestamp=" + expireTimestamp | ||
| + "}"; | ||
| } |
There was a problem hiding this comment.
try to use Moreobjects method
| return accessController; | ||
| } catch (Exception e) { | ||
| throw Throwables.propagate(e); | ||
| throw new RuntimeException(e); |
There was a problem hiding this comment.
also add Throwables.propagateIfUnchecked
| accessControllerClassLoader.close(); | ||
|
|
||
| } catch (Exception ignored) { | ||
|
|
There was a problem hiding this comment.
nir: remove empty lines and add code comment in empty catch block
| throw new RuntimeException(e); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
also add Throwables.propagateIfUnchecked
| throw Throwables.propagate(wrappedException); | ||
| throw new RuntimeException(wrappedException); | ||
| } | ||
| } |
| public void destroy() { | ||
| tokenManager.stop(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(tokenManager); | ||
| } |
There was a problem hiding this comment.
add fully qualified class name in import
| String useLdaps = handlerProps.get("useLdaps"); | ||
| if (Boolean.parseBoolean(Objects.firstNonNull(useLdaps, "false"))) { | ||
| if (Boolean.parseBoolean(useLdaps != null ? useLdaps : "false")) { | ||
| ldapSSLVerifyCertificate = Boolean.parseBoolean( |
There was a problem hiding this comment.
can we use MoreObjects.firstNonNull ?
|
|
||
| throw (Error) t; | ||
|
|
||
| } |
| } catch (ExecutionException ee) { | ||
| // recheck if already created | ||
| throw Throwables.propagate(ee.getCause()); | ||
| throw new RuntimeException(ee.getCause()); |
There was a problem hiding this comment.
also add Throwables.propagateIfUnchecked
| io.cdap.cdap.common.service.Services.startAndWait(keyManager); | ||
| if (expectLeader) { | ||
| Tasks.waitFor(true, () -> keyManager.getCurrentKey() != null, 5L, TimeUnit.SECONDS); | ||
| } |
There was a problem hiding this comment.
add fully qualified class name in import
| keyManager.stopAndWait(); | ||
| io.cdap.cdap.common.service.Services.stopAndWait(keyManager); | ||
| } | ||
| } |
There was a problem hiding this comment.
add fully qualified class name in import
| io.cdap.cdap.common.service.Services.stopAndWait(server); | ||
| // Clear any security properties for zookeeper. | ||
| System.clearProperty(Constants.External.Zookeeper.ENV_AUTH_PROVIDER_1); | ||
| Configuration.setConfiguration(null); |
There was a problem hiding this comment.
add fully qualified class name in import
Updated the Guava dependency version in pom.xml to 32.0.0-jre.
Ensured compatibility with the upgraded Guava version.