Skip to content

Commit 70fdf1e

Browse files
committed
8237364: Add early validation to the jdk.jfr.Recording constructor
Reviewed-by: mgronlun, mseledtsov
1 parent 5b5a535 commit 70fdf1e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/jdk.jfr/share/classes/jdk/jfr/Recording.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ public Map<String, String> toMap() {
9999
* A newly created recording is in the {@link RecordingState#NEW} state. To start
100100
* the recording, invoke the {@link Recording#start()} method.
101101
*
102+
* @param settings settings as a map of name-value pairs, not {@code null}
103+
*
102104
* @throws IllegalStateException if Flight Recorder can't be created (for
103105
* example, if the Java Virtual Machine (JVM) lacks Flight Recorder
104106
* support, or if the file repository can't be created or accessed)
@@ -109,9 +111,11 @@ public Map<String, String> toMap() {
109111
* @see jdk.jfr
110112
*/
111113
public Recording(Map<String, String> settings) {
114+
Objects.requireNonNull(settings);
115+
Map<String, String> sanitized = Utils.sanitizeNullFreeStringMap(settings);
112116
PlatformRecorder r = FlightRecorder.getFlightRecorder().getInternal();
113117
synchronized (r) {
114-
this.internal = r.newRecording(settings);
118+
this.internal = r.newRecording(sanitized);
115119
this.internal.setRecording(this);
116120
if (internal.getRecording() != this) {
117121
throw new InternalError("Internal recording not properly setup");

0 commit comments

Comments
 (0)