in maven-wrapper/src/main/java/org/apache/maven/wrapper/DefaultDownloader.java [89:106]
private void downloadInternal(URI address, Path destination) throws IOException {
URL url = address.toURL();
URLConnection conn = url.openConnection();
addBasicAuthentication(address, conn);
final String userAgentValue = calculateUserAgent();
conn.setRequestProperty("User-Agent", userAgentValue);
Path temp = destination
.getParent()
.resolve(destination.getFileName() + "."
+ Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp");
try (InputStream inStream = conn.getInputStream()) {
Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING);
Files.move(temp, destination, StandardCopyOption.REPLACE_EXISTING);
} finally {
Files.deleteIfExists(temp);
}
}