Skip to content

Commit cadbc36

Browse files
rgithubliVictor Rudometov
authored andcommitted
8364257: JFR: User-defined events and settings with a one-letter name cannot be configured
Backport-of: ea7e943874288e1cbea10a6bd82d6c7f2a1c9ae0
1 parent b1cdae0 commit cadbc36

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/jdk.jfr/share/classes/jdk/jfr/internal/SettingsManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private Collection<InternalSetting> makeInternalSettings(Map<String, String> rec
194194
String key = entry.getKey();
195195
String value = entry.getValue();
196196
int index = key.indexOf("#");
197-
if (index > 1 && index < key.length() - 2) {
197+
if (index > 0 && index < key.length() - 1) {
198198
String eventName = key.substring(0, index);
199199
eventName = Utils.upgradeLegacyJDKEvent(eventName);
200200
InternalSetting s = internals.get(eventName);

test/jdk/jdk/jfr/api/flightrecorder/TestSettingsControl.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Set;
2929

3030
import jdk.jfr.Event;
31+
import jdk.jfr.Name;
3132
import jdk.jfr.Recording;
3233
import jdk.jfr.SettingControl;
3334
import jdk.jfr.SettingDefinition;
@@ -42,7 +43,7 @@
4243
public class TestSettingsControl {
4344
static class MySettingsControl extends SettingControl {
4445

45-
public static boolean setWasCalled;
46+
public static boolean myvalueSet;
4647

4748
private String value = "default";
4849

@@ -57,7 +58,9 @@ public String combine(Set<String> values) {
5758

5859
@Override
5960
public void setValue(String value) {
60-
setWasCalled = true;
61+
if ("myvalue".equals(value)) {
62+
myvalueSet = true;
63+
}
6164
this.value = value;
6265
}
6366

@@ -67,23 +70,24 @@ public String getValue() {
6770
}
6871

6972
}
70-
73+
@Name("M")
7174
static class MyCustomSettingEvent extends Event {
7275
@SettingDefinition
76+
@Name("m")
7377
boolean mySetting(MySettingsControl msc) {
7478
return true;
7579
}
7680
}
7781

7882
public static void main(String[] args) throws Throwable {
7983
Recording r = new Recording();
80-
r.enable(MyCustomSettingEvent.class).with("mySetting", "myvalue");
84+
r.enable("M").with("m", "myvalue");
8185
r.start();
8286
MyCustomSettingEvent e = new MyCustomSettingEvent();
8387
e.commit();
8488
r.stop();
8589
r.close();
86-
assertTrue(MySettingsControl.setWasCalled, "SettingControl.setValue was not called");
90+
assertTrue(MySettingsControl.myvalueSet, "SettingControl.setValue(\"myvalue\") was not called");
8791
}
8892
}
8993

0 commit comments

Comments
 (0)