Repository navigation
Conversation
use_java(), java_resolve() and everything built on them (java_ensure(), local_java_env(), with_java_env()) plus java_quick_install() failed or warned without network access even when the requested Java was cached: - Installs in the 0.3.0 layout (<platform>/<arch>/<version>) are listed with distribution/backend "unknown" and never matched a Corretto/native request, so the network was queried. They are now treated as Corretto native installs, after exact matches. - java_download() always resolved metadata online first. When that fails it now reuses a matching archive from the distrib cache (newest cached Corretto build, deterministic Temurin/Zulu names, 0.3.0 Corretto names), and re-raises the original error when nothing matches. - use_java() skips the online version check when the archive is cached, avoiding noisy Temurin probe warnings offline.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #111 +/- ##
==========================================
+ Coverage 91.76% 92.07% +0.31%
==========================================
Files 27 27
Lines 3025 3131 +106
==========================================
+ Hits 2776 2883 +107
+ Misses 249 248 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…files - java_quick_install() links an already installed Java (either cache layout, including 0.3.0 installs) into the project instead of downloading and unpacking it again. The project-link step of java_install() moves to java_link_project(), which mirrors the cache layout of the install it links. - use_java() and java_quick_install() share java_find_installed(), which also drops the "No Java distributions have been installed yet" alert from these lookups. - java_clear_distrib() deleted "<archive>md5" instead of "<archive>.md5", leaving checksum files of 0.3.0 archives behind. - 0.4.0 has not been released to CRAN, so the NEWS for this work moves into the 0.4.0 entry (with a note on resetting the cache) and the version stays 0.4.0.
…o installs Addresses review of #111: - java_download() fell back to a cached archive on any metadata error, so online a version the vendor no longer serves silently succeeded from cache. Requests that get no response (and HTTP 5xx in read_json_url()) now fail with class rJavaEnv_network_error, the Corretto/Temurin/Zulu resolvers keep that class when re-raising, and only those errors trigger the fallback. - 0.3.0's java_unpack() accepted any archive, so a legacy-layout install is only reused for Corretto requests if the JDK identifies itself as Corretto (release file, or version.txt for Corretto 8). - java_quick_install() takes the project link layout from the install's folder depth rather than its distribution label. - java_download() docs and NEWS describe when cached archives are used. - The use_java() test checks that version validation is not called, instead of mocking it to fail.
Windows Corretto 8 ships a release file that does not name the vendor, so java_home_is_corretto() rejected it and a 0.3.0 install would be downloaded again. Corretto (8 on Linux, macOS and Windows, and 11+) ships version.txt and commitId.txt, which Temurin and Zulu do not, so accept that pair whether or not a release file exists.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
use_java(21), thejava_resolve()family andjava_quick_install()contacted the vendor API, and failed or warned, even when Java 21 was already cached.installed/<os>/<arch>/<version>) asunknown/unknownbut never reused them. It also never reused 0.3.0 archives. So every JDK was downloaded and unpacked a second time. In a real 0.3.0 → 0.4.0 test with Java 17 and 21, the cache grew from 1.1 GB to 2.1 GB.Changes
java_installed_matching()/java_find_installed(), used byuse_java(),java_resolve()andjava_quick_install()):releasefile names Corretto, or it ships Corretto'sversion.txtandcommitId.txt. The second case covers Corretto 8, whosereleasefile is missing on Linux and macOS and doesn't name the vendor on Windows; Temurin and Zulu ship neither file.java_unpack()accepted any archive, so a non-Corretto JDK could end up in that layout.java_quick_install()links an already installed Java into the project instead of downloading it.java_install()moved tojava_link_project().java_install()output is unchanged.java_download()— used only when the vendor API cannot be reached:rJavaEnv_network_error, which the Corretto/Temurin/Zulu resolvers keep when they re-raise.distrib/. For Corretto that is the newest cached build of the requested version, including 0.3.0 archive names. Temurin and Zulu names are fixed by the request.force = TRUE.use_java()skips the online version check when the archive is cached. Offline, that check otherwise warns for Temurin.java_clear_distrib()looked for<archive>md5instead of<archive>.md5, so it left 0.3.0 checksum files behind.java_download()docs describe when cached archives are used. 0.4.0 hasn't gone to CRAN, so the NEWS is folded into the 0.4.0 entry, which now also explains how to reset the cache. The version stays 0.4.0.Testing
tests/testthat/test-offline_cache.R(13 tests) covers:releasefile;test-java_env_session.R, which needsrJava. That test fails the same way onmain.use_java(21)andjava_quick_install(17, project)(and separatelyuse_java(8)); then this branch runs the same steps on that cache.unshare -n):use_java(),java_resolve(),java_ensure(),local_java_env(),with_java_env()andjava_quick_install().java_download("21.0.9")with a cached 21.0.9 archive raises "not available", as onmain; offline it uses the cache.use_java(21).🤖 Generated with Claude Code
https://claude.ai/code/session_01JknUFhxmgsHgeuv1PDNmUW