-
Bug
-
Resolution: Fixed
-
P4
-
11, 16
-
b25
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8268245 | 15.0.4 | Ekaterina Vergizova | P4 | Resolved | Fixed | b04 |
JDK-8305059 | 11.0.20-oracle | Joakim Nordström | P4 | Resolved | Fixed | b01 |
JDK-8268027 | 11.0.12 | Erik Gahlin | P4 | Resolved | Fixed | b05 |
src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java indexes from 0 for string pool entries with:
private final AtomicLong sidIdx = new AtomicLong();
and entries obtained via:
long sid = this.sidIdx.getAndIncrement();
src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriter.java writes string pool entries with:
long l = StringPool.addString(s);
if (l > 0) {
...
}
The first entry to the StringPool will have id 0 but will never be used for events using the EventWriter. This can be seen with a test application that repeatedly emits a custom event with string field. The string will be in the constant pool, but the actual event data will have written the entire string out.
Something like:
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.util.Arrays;
import jdk.jfr.Configuration;
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
import jdk.jfr.Description;
import jdk.jfr.Enabled;
import jdk.jfr.Event;
import jdk.jfr.Label;
public class EventCommit {
@Label("Basic Event")
@Description("An event with just a message as payload")
static class BasicEvent extends Event {
@Label("Message")
public String message;
}
public static void main(String[] args) {
try {
Configuration c = Configuration.getConfiguration("default");
Recording r = new Recording(c);
r.start();
for (int i = 0; i < 10; i++) {
BasicEvent event = new BasicEvent();
event.message = "123456789010111213141516";
event.commit();
}
r.stop();
r.dump(Files.createTempFile("my-recording", ".jfr"));
r.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private final AtomicLong sidIdx = new AtomicLong();
and entries obtained via:
long sid = this.sidIdx.getAndIncrement();
src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriter.java writes string pool entries with:
long l = StringPool.addString(s);
if (l > 0) {
...
}
The first entry to the StringPool will have id 0 but will never be used for events using the EventWriter. This can be seen with a test application that repeatedly emits a custom event with string field. The string will be in the constant pool, but the actual event data will have written the entire string out.
Something like:
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.file.Files;
import java.util.Arrays;
import jdk.jfr.Configuration;
import jdk.jfr.FlightRecorder;
import jdk.jfr.Recording;
import jdk.jfr.Description;
import jdk.jfr.Enabled;
import jdk.jfr.Event;
import jdk.jfr.Label;
public class EventCommit {
@Label("Basic Event")
@Description("An event with just a message as payload")
static class BasicEvent extends Event {
@Label("Message")
public String message;
}
public static void main(String[] args) {
try {
Configuration c = Configuration.getConfiguration("default");
Recording r = new Recording(c);
r.start();
for (int i = 0; i < 10; i++) {
BasicEvent event = new BasicEvent();
event.message = "123456789010111213141516";
event.commit();
}
r.stop();
r.dump(Files.createTempFile("my-recording", ".jfr"));
r.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
- backported by
-
JDK-8268027 JFR EventWriter does not use first string from StringPool with id 0
- Resolved
-
JDK-8268245 JFR EventWriter does not use first string from StringPool with id 0
- Resolved
-
JDK-8305059 JFR EventWriter does not use first string from StringPool with id 0
- Resolved
- links to
-
Commit openjdk/jdk15u-dev/f77ca300
-
Commit openjdk/jdk/c85c9ad1
-
Review openjdk/jdk15u-dev/68
-
Review openjdk/jdk/1097
(2 links to)