-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Disallow negative TimeValues #53913
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
Disallow negative TimeValues #53913
Changes from 15 commits
8c2a742
cc2a587
8b45357
025074f
df20456
af86c3d
4f2636a
5baf1f5
df6900e
1f129e8
222bd83
bcd33b8
81e6458
b9bfb73
5567b7a
41c8095
a29c639
ac9e0f4
996b4a2
e4ac3bd
f893e17
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 |
---|---|---|
|
@@ -28,8 +28,8 @@ | |
import org.elasticsearch.common.unit.ByteSizeValue; | ||
import org.elasticsearch.common.unit.TimeValue; | ||
import org.elasticsearch.monitor.jvm.JvmStats.GarbageCollector; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.threadpool.Scheduler.Cancellable; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.threadpool.ThreadPool.Names; | ||
|
||
import java.util.HashMap; | ||
|
@@ -165,13 +165,20 @@ public JvmGcMonitorService(Settings settings, ThreadPool threadPool) { | |
} | ||
|
||
private static TimeValue getValidThreshold(Settings settings, String key, String level) { | ||
TimeValue threshold = settings.getAsTime(level, null); | ||
final TimeValue threshold; | ||
|
||
try { | ||
threshold = settings.getAsTime(level, null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I'm wondering if the better long-term fix is to make the GC threshold settings not be group settings anymore, but affix settings. Then we would not need to resort this, as we'd get the proper setting named pushed down anyway, and this wrapping would be necessary. I think that would be a good follow up to this one. |
||
} catch (RuntimeException ex) { | ||
final String settingValue = settings.get(level); | ||
throw new IllegalArgumentException("failed to parse setting [" + getThresholdName(key, level) + "] with value [" + | ||
settingValue + "] as a time value", ex); | ||
} | ||
|
||
if (threshold == null) { | ||
throw new IllegalArgumentException("missing gc_threshold for [" + getThresholdName(key, level) + "]"); | ||
} | ||
if (threshold.nanos() <= 0) { | ||
throw new IllegalArgumentException("invalid gc_threshold [" + threshold + "] for [" + getThresholdName(key, level) + "]"); | ||
} | ||
|
||
return threshold; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.