Skip to content

Upgrade Guava library to version 32.0.0-jre-router pod#16118

Open
AbhishekKumar9984 wants to merge 2 commits into
cdapio:cs_guava_upgradefrom
cloudsufi:router-cloudsufi-guava-upgrade
Open

Upgrade Guava library to version 32.0.0-jre-router pod#16118
AbhishekKumar9984 wants to merge 2 commits into
cdapio:cs_guava_upgradefrom
cloudsufi:router-cloudsufi-guava-upgrade

Conversation

@AbhishekKumar9984
Copy link
Copy Markdown

Updated the Guava dependency version in pom.xml to 32.0.0-jre.
Ensured compatibility with the upgraded Guava version.

Object future = service.getClass().getMethod("start").invoke(service);
if (future instanceof ListenableFuture) {
((ListenableFuture<?>) future).get();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add import statement

if (SecurityUtil.isManagedSecurity(cConf) && !SecurityUtil.isInternalAuthEnabled(cConf)) {
tokenValidator.stopAndWait();
io.cdap.cdap.common.service.Services.stopAndWait(tokenValidator);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this in import

} catch (Throwable t) {
LOG.error(t.getMessage(), t);
throw Throwables.propagate(t);
throw new RuntimeException(t);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add Throwables.propagateIfUnchecked

+ "cdap-site.xml. Currently configured as: %s",
zkClientService.getConnectString()));
router.startAndWait();
io.cdap.cdap.common.service.Services.startAndWait(router);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this to import

datasetService = injector.getInstance(DatasetService.class);
datasetService.startAndWait();
io.cdap.cdap.common.service.Services.startAndWait(datasetService);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this to import

@Override
public void handleError(Throwable cause) {
throw Throwables.propagate(cause);
throw new RuntimeException(cause);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add throwables.propageIfunchecked

io.cdap.cdap.common.service.Services.stopAndWait((Service) messagingService);
}
conf.clear();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add propagateIfUnchecked before RuntimeException

userId = UserGroupInformation.getCurrentUser().getShortUserName();
} catch (IOException e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

+ "identifier=" + identifier
+ ", keyId=" + keyId
+ ", digest=" + Bytes.toStringBinary(digest)
+ "}";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use toStringHelper method from MoreObjects class?

Comment thread pom.xml
<exclude>third-party-licenses/**</exclude>
<exclude>.gitpod.yml</exclude>
<exclude>.gitpod.Dockerfile</exclude>
<exclude>**/target/**</exclude>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is it needed?


Stopwatch watch = new Stopwatch().start();
while (!isPresent && watch.elapsedTime(TimeUnit.MILLISECONDS) < timeToWaitMillis) {
long startTime = System.currentTimeMillis();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

httpService.stop();
router.stopAndWait();
io.cdap.cdap.common.service.Services.stopAndWait(router);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

@Override
protected void shutDown() {
router.stopAndWait();
io.cdap.cdap.common.service.Services.stopAndWait(router);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

@Override
protected void shutDown() {
router.stopAndWait();
io.cdap.cdap.common.service.Services.stopAndWait(router);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

io.cdap.cdap.common.service.Services.stopAndWait(mockService);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

+ ", issueTimestamp=" + issueTimestamp
+ ", expireTimestamp=" + expireTimestamp
+ "}";
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to use Moreobjects method

return accessController;
} catch (Exception e) {
throw Throwables.propagate(e);
throw new RuntimeException(e);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add Throwables.propagateIfUnchecked

accessControllerClassLoader.close();

} catch (Exception ignored) {

Copy link
Copy Markdown

@dheeraj-kholia-cs dheeraj-kholia-cs May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nir: remove empty lines and add code comment in empty catch block

throw new RuntimeException(e);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add Throwables.propagateIfUnchecked

throw Throwables.propagate(wrappedException);
throw new RuntimeException(wrappedException);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

public void destroy() {
tokenManager.stop();
io.cdap.cdap.common.service.Services.stopAndWait(tokenManager);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use MoreObjects.firstNonNull ?


throw (Error) t;

}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove empty lines

} catch (ExecutionException ee) {
// recheck if already created
throw Throwables.propagate(ee.getCause());
throw new RuntimeException(ee.getCause());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add Throwables.propagateIfUnchecked

io.cdap.cdap.common.service.Services.startAndWait(keyManager);
if (expectLeader) {
Tasks.waitFor(true, () -> keyManager.getCurrentKey() != null, 5L, TimeUnit.SECONDS);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

keyManager.stopAndWait();
io.cdap.cdap.common.service.Services.stopAndWait(keyManager);
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add fully qualified class name in import

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants