Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.2.3
-
None
Description
Currently, we solely rely on System.currentTimeMillis to track start/end times as well as durations. This is error prone and not guaranteed to deliver a monotic value with positive durations.
We should consider employing System.nanoTime throughout the core where the above mentioned conditions are met. E.g., in some of:
maven-aether-provider/src/test/java/org/apache/maven/repository/internal/util/ConsoleTransferListener.java: long duration = System.currentTimeMillis() - resource.getTransferStartTime(); maven-compat/src/main/java/org/apache/maven/repository/legacy/MavenArtifact.java: this.transferStartTime = System.currentTimeMillis(); maven-core/src/main/java/org/apache/maven/lifecycle/internal/builder/BuilderCommon.java: long buildEndTime = System.currentTimeMillis(); maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java: long buildStartTime = System.currentTimeMillis(); maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleModuleBuilder.java: long buildEndTime = System.currentTimeMillis(); maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java: long finish = System.currentTimeMillis(); maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java: long duration = System.currentTimeMillis() - resource.getTransferStartTime(); maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java: long duration = System.currentTimeMillis() - resource.getTransferStartTime(); DefaultMaven.java: request.setStartTime( new Date() ); DefaultMavenExecutionRequest.java: public Date getStartTime() DefaultMavenExecutionRequest.java: projectBuildingRequest.setBuildStartTime( getStartTime() ); MavenExecutionRequest.java: Date getStartTime(); MavenSession.java: public Date getStartTime() MavenSession.java: return request.getStartTime(); ExecutionEventLogger.java: long time = finish - session.getRequest().getStartTime().getTime();
and all other code spots where Date or long is used.
Attachments
Issue Links
- is blocked by
-
MRESOLVER-14 Statistics should be calculated using System.nanoTime() instead of System.currentTimeMillis()
- Closed
- is depended upon by
-
MNG-5626 Avoid negative durations or handle them correctly
- Closed
- requires
-
MRESOLVER-635 Use Instant instead of untyped millis for TransferResource startTime
- Closed
- links to