Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Default to the current thread's name when there's no RubyThread

  • Loading branch information...
commit e5d068df3f0780aed906c08f75bea4f5be940aab 1 parent 3a720ed
@iconara authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 src/org/jruby/runtime/profile/JsonProfilePrinter.java
View
13 src/org/jruby/runtime/profile/JsonProfilePrinter.java
@@ -47,9 +47,18 @@ public JsonProfilePrinter(ProfileData profileData) {
public void printProfile(PrintStream out) {
Invocation topInvocation = getTopInvocation();
IntHashMap<MethodData> methods = methodData(topInvocation);
- String threadName = getProfileData().getThreadContext().getThread().getNativeThread().getName();
+ String threadName = null;
- out.printf("{\n\t\"total_time\":%d,\n\t\"thread_name\":\"%s\",\n\t\"methods\":[\n", topInvocation.getDuration(), threadName);
+ if (getProfileData().getThreadContext().getThread() == null) {
+ threadName = Thread.currentThread().getName();
+ } else {
+ threadName = getProfileData().getThreadContext().getThread().getNativeThread().getName();
+ }
+
+ out.println("{");
+ out.printf("\t\"total_time\":%s,\n", nanosToSecondsString(topInvocation.getDuration()));
+ out.printf("\t\"thread_name\":\"%s\",\n", threadName);
+ out.println("\t\"methods\":[");
Iterator<MethodData> i = methods.values().iterator();
while (i.hasNext()) {
Please sign in to comment.
Something went wrong with that request. Please try again.