jib
jib copied to clipboard
Warning to use java.time-based API in jib-core Retry.java
(logs from https://travis-ci.org/github/GoogleContainerTools/jib/jobs/676290173)
> Task :jib-core:compileJava
/home/travis/build/GoogleContainerTools/jib/jib-core/src/main/java/com/google/cloud/tools/jib/cache/Retry.java:104: warning: [PreferJavaTimeOverload] Prefer using java.time-based APIs when available. Note that this checker does not and cannot guarantee that the overloads have equivalent semantics, but that is generally the case with overloaded methods.
this.sleepMilliseconds = unit.convert(duration, TimeUnit.MILLISECONDS);
^
(see https://errorprone.info/bugpattern/PreferJavaTimeOverload)
Did you mean 'this.sleepMilliseconds = unit.convert(Duration.ofMillis(duration));'?
1 warning
Is this the Java11 build?
Yeah, seems like only on Java 11.
The Error Prone page says
APIs that require a
long,TimeUnitpair suffer from a number of problems
- they may require plumbing 2 parameters through various layers of your application
- overflows are possible when doing duration math
- they lack semantic meaning (when viewed separately)
- decomposing a duration into a
long,TimeUnitis dangerous because of unit mismatch and/or excessive truncation.