pvillard31 commented on code in PR #11258:
URL: https://github.com/apache/nifi/pull/11258#discussion_r3252652053
##########
nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcService.java:
##########
@@ -296,4 +298,16 @@ private boolean timeConstantEqualityCheck(final String
value1, final String valu
return MessageDigest.isEqual(value1.getBytes(StandardCharsets.UTF_8),
value2.getBytes(StandardCharsets.UTF_8));
}
+
+ private Duration getDuration(long duration, TimeUnit unit) {
+ return switch (unit) {
+ case DAYS -> Duration.ofDays(duration);
+ case HOURS -> Duration.ofHours(duration);
+ case MICROSECONDS ->
Duration.ofMillis(TimeUnit.MILLISECONDS.convert(duration,
TimeUnit.MICROSECONDS));
Review Comment:
In the `MICROSECONDS` branch, the conversion goes through
`TimeUnit.MILLISECONDS.convert(...)`, which truncates a sub-millisecond input
to zero and would make the cache expire immediately. Is that loss of precision
intentional?
##########
nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcService.java:
##########
@@ -296,4 +298,16 @@ private boolean timeConstantEqualityCheck(final String
value1, final String valu
return MessageDigest.isEqual(value1.getBytes(StandardCharsets.UTF_8),
value2.getBytes(StandardCharsets.UTF_8));
}
+
+ private Duration getDuration(long duration, TimeUnit unit) {
Review Comment:
Could `getDuration` be replaced with a single call to `Duration.of(duration,
unit.toChronoUnit())`, which handles every `TimeUnit` value correctly and
removes the need for a helper method?
##########
nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authentication/oidc/OidcService.java:
##########
@@ -296,4 +298,16 @@ private boolean timeConstantEqualityCheck(final String
value1, final String valu
return MessageDigest.isEqual(value1.getBytes(StandardCharsets.UTF_8),
value2.getBytes(StandardCharsets.UTF_8));
}
+
+ private Duration getDuration(long duration, TimeUnit unit) {
Review Comment:
Should the `duration` and `unit` parameters be declared `final` to match the
NiFi code style and the rest of this class?
--
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]