Skip to content
Permalink
Browse files

8237364: Add early validation to the jdk.jfr.Recording constructor

Reviewed-by: mgronlun, mseledtsov
  • Loading branch information
Erik Gahlin
Erik Gahlin committed Jan 29, 2020
1 parent 5b5a535 commit 70fdf1e5eecc0e5c948ae6c1b0914ed3266628a2
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/jdk.jfr/share/classes/jdk/jfr/Recording.java
@@ -99,6 +99,8 @@ public EventSettings with(String name, String value) {
* A newly created recording is in the {@link RecordingState#NEW} state. To start
* the recording, invoke the {@link Recording#start()} method.
*
* @param settings settings as a map of name-value pairs, not {@code null}
*
* @throws IllegalStateException if Flight Recorder can't be created (for
* example, if the Java Virtual Machine (JVM) lacks Flight Recorder
* support, or if the file repository can't be created or accessed)
@@ -109,9 +111,11 @@ public EventSettings with(String name, String value) {
* @see jdk.jfr
*/
public Recording(Map<String, String> settings) {
Objects.requireNonNull(settings);
Map<String, String> sanitized = Utils.sanitizeNullFreeStringMap(settings);
PlatformRecorder r = FlightRecorder.getFlightRecorder().getInternal();
synchronized (r) {
this.internal = r.newRecording(settings);
this.internal = r.newRecording(sanitized);
this.internal.setRecording(this);
if (internal.getRecording() != this) {
throw new InternalError("Internal recording not properly setup");

0 comments on commit 70fdf1e

Please sign in to comment.