-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Use logs dir as working directory #124966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 18 commits
57bd949
6bb542b
ee4956f
3f65603
0d3cdea
5e08b5a
6be4935
f4e0622
9fae96e
75f664d
a658206
b54b497
c4c5f31
1301be0
1136cad
e01136f
264158f
ae3eb71
0c9c3c4
5243f77
43db0f2
5fb48da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1435,30 +1435,57 @@ private void tweakJvmOptions(Path configFileRoot) { | |
| Path jvmOptions = configFileRoot.resolve("jvm.options"); | ||
| try { | ||
| String content = new String(Files.readAllBytes(jvmOptions)); | ||
| Map<String, String> expansions = jvmOptionExpansions(); | ||
| for (String origin : expansions.keySet()) { | ||
| if (content.contains(origin) == false) { | ||
| throw new IOException("template property " + origin + " not found in template."); | ||
| Map<ReplacementKey, String> expansions = jvmOptionExpansions(); | ||
| for (var entry : expansions.entrySet()) { | ||
| ReplacementKey replacement = entry.getKey(); | ||
| String key = replacement.key(); | ||
| if (content.contains(key) == false) { | ||
| key = replacement.fallback(); | ||
| if (content.contains(key) == false) { | ||
| throw new IOException("Template property '" + replacement + "' not found in template:\n" + content); | ||
| } | ||
| } | ||
| content = content.replace(origin, expansions.get(origin)); | ||
| content = content.replace(key, entry.getValue()); | ||
| } | ||
| Files.write(jvmOptions, content.getBytes()); | ||
| } catch (IOException ioException) { | ||
| throw new UncheckedIOException(ioException); | ||
| } | ||
| } | ||
|
|
||
| private Map<String, String> jvmOptionExpansions() { | ||
| Map<String, String> expansions = new HashMap<>(); | ||
| private record ReplacementKey(String key, String fallback) {} | ||
|
|
||
| private Map<ReplacementKey, String> jvmOptionExpansions() { | ||
| Map<ReplacementKey, String> expansions = new HashMap<>(); | ||
| Version version = getVersion(); | ||
| String heapDumpOrigin = getVersion().onOrAfter("6.3.0") ? "-XX:HeapDumpPath=data" : "-XX:HeapDumpPath=/heap/dump/path"; | ||
| expansions.put(heapDumpOrigin, "-XX:HeapDumpPath=" + confPathLogs); | ||
| if (version.onOrAfter("6.2.0")) { | ||
| expansions.put("logs/gc.log", confPathLogs.resolve("gc.log").toString()); | ||
|
|
||
| ReplacementKey heapDumpPathSub; | ||
| if (version.before("8.18.0") && version.onOrAfter("6.3.0")) { | ||
ldematte marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| heapDumpPathSub = new ReplacementKey("-XX:HeapDumpPath=data", ""); | ||
|
||
| } else { | ||
| // temporarily fall back to the old substitution so both old and new work during backport | ||
| heapDumpPathSub = new ReplacementKey("# -XX:HeapDumpPath=/heap/dump/path", "-XX:HeapDumpPath=data"); | ||
| } | ||
| if (getVersion().getMajor() >= 7) { | ||
| expansions.put("-XX:ErrorFile=logs/hs_err_pid%p.log", "-XX:ErrorFile=" + confPathLogs.resolve("hs_err_pid%p.log")); | ||
| expansions.put(heapDumpPathSub, "-XX:HeapDumpPath=" + confPathLogs); | ||
|
|
||
| ReplacementKey gcLogSub; | ||
| if (version.before("8.18.0") && version.onOrAfter("6.2.0")) { | ||
| gcLogSub = new ReplacementKey("logs/gc.log", ""); | ||
| } else { | ||
| // temporarily check the old substitution first so both old and new work during backport | ||
| gcLogSub = new ReplacementKey("logs/gc.log", "gc.log"); | ||
| } | ||
| expansions.put(gcLogSub, confPathLogs.resolve("gc.log").toString()); | ||
|
|
||
| ReplacementKey errorFileSub; | ||
| if (version.before("8.18.0") && version.getMajor() >= 7) { | ||
| errorFileSub = new ReplacementKey("-XX:ErrorFile=logs/hs_err_pid%p.log", ""); | ||
| } else { | ||
| // temporarily check the old substitution first so both old and new work during backport | ||
| errorFileSub = new ReplacementKey("-XX:ErrorFile=logs/hs_err_pid%p.log", "-XX:ErrorFile=hs_err_pid%p.log"); | ||
| } | ||
| expansions.put(errorFileSub, "-XX:ErrorFile=" + confPathLogs.resolve("hs_err_pid%p.log")); | ||
|
|
||
| return expansions; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.