backtrace-labs / backtrace-java Goto Github PK
View Code? Open in Web Editor NEWJava support for Backtrace
License: MIT License
Java support for Backtrace
License: MIT License
While testing backtrace for my desktop application on mac, I noticed that my app had a huge cpu load while doing nothing. Taking a spindump revealed the issue
I see the BacktraceThread.run endlessly invoking Backtrace.handleBacktraceMessage:
https://github.com/backtrace-labs/backtrace-java/blob/master/src/main/java/backtrace/io/BacktraceThread.java#L55
@OverRide
public void run() {
while (running) {
backtrace.handleBacktraceMessage();
}
this.closing.countDown();
LOGGER.info("BacktraceThread has completed the run method");
}
If there is nothing in the queue, Backtrace.handleBacktraceMessage simply returns immediately:
https://github.com/backtrace-labs/backtrace-java/blob/master/src/main/java/backtrace/io/Backtrace.java#L38
void handleBacktraceMessage() {
try {
if (queue.isEmpty()) {
return;
}
...
This is easily reproduce-able by sending a report with attributes that contain some null value.
java.lang.NullPointerException: null
at backtrace.io.data.Attributes.splitClientAttributes(Attributes.java:139)
at backtrace.io.data.Attributes.<init>(Attributes.java:42)
at backtrace.io.data.BacktraceData.setAttributes(BacktraceData.java:171)
at backtrace.io.data.BacktraceData.<init>(BacktraceData.java:148)
at backtrace.io.BacktraceQueueHandler.send(BacktraceQueueHandler.java:33)
at backtrace.io.BacktraceClient.send(BacktraceClient.java:97)
at backtrace.io.BacktraceClient.send(BacktraceClient.java:87)
Starting from jdk16 it's no longer possible to use reflection to access private fields in certain conditions due to strong encapsulation
. https://bugs.openjdk.org/browse/JDK-8256358
Backtrace java uses Gson's reflection based type adapter. Hence the failure.
java.lang.reflect.InaccessibleObjectException: Unable to make field private java.lang.String java.lang.Throwable.detailMessage accessible: module java.base does not "opens java.lang" to unnamed module @63db54ce
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:178)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:172)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:489)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:489)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:117)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:166)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:489)
at com.google.gson.Gson.toJson(Gson.java:727)
at com.google.gson.Gson.toJson(Gson.java:714)
at com.google.gson.Gson.toJson(Gson.java:669)
at com.google.gson.Gson.toJson(Gson.java:649)
at backtrace.io.helpers.BacktraceSerializeHelper.toJson(BacktraceSerializeHelper.java:21)
at backtrace.io.http.ApiSender.sendReport(ApiSender.java:29)
at backtrace.io.Backtrace.sendReport(Backtrace.java:97)
at backtrace.io.Backtrace.processSingleBacktraceMessage(Backtrace.java:74)
at backtrace.io.Backtrace.handleBacktraceMessage(Backtrace.java:47)
at backtrace.io.BacktraceThread.run(BacktraceThread.java:57)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.