Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ function Thread(line) {
this.tid = match.value;
line = match.shorterString;

if(this.tid === undefined){
match = _extract(/ - Thread t@([0-9a-fx]+)/,line);
this.tid = match.value;
line = match.shorterString;
}

match = _extract(/ prio=([0-9]+)/, line);
this.prio = match.value;
line = match.shorterString;
Expand Down Expand Up @@ -589,7 +595,7 @@ function Analyzer(text) {
var lines = text.split('\n');
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
while (line.charAt(0) === '"' && line.indexOf('prio=') === -1) {
while (line.charAt(0) === '"' && line.indexOf('prio=') === -1 && line.indexOf('t@') === -1) {
// Multi line thread name
i++;
if (i >= lines.length) {
Expand Down
38 changes: 38 additions & 0 deletions tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ QUnit.test( "thread header 13", function(assert) {
assert.equal(new Thread(header).group, undefined);
});

QUnit.test("thread header 14", function(assert){
var header = '"http-bio-8810-exec-147" - Thread t@96965';
assert.equal(new Thread(header).name,'http-bio-8810-exec-147');
assert.equal(new Thread(header).tid, '96965');
assert.equal(new Thread(header).group, undefined);
});

// A thread should be considered running if it has a stack trace and
// is RUNNABLE
QUnit.test("thread.running", function(assert) {
Expand Down Expand Up @@ -311,6 +318,37 @@ QUnit.test( "analyze thread waiting for traditional lock", function(assert) {
assert.equal(thread.synchronizerClasses['47114712gris'], null);
});

QUnit.test(" analyze thread waiting for locks 2", function(assert){
var threadDump= [
'"http-5525-116" - Thread t@151',
' java.lang.Thread.State: BLOCKED',
' at org.apache.log4j.Category.callAppenders(Category.java:205)',
' - waiting to lock <259a4a41> (a org.apache.log4j.spi.RootLogger) owned by "http-5525-127" t@162',
' at org.apache.log4j.Category.forcedLog(Category.java:391)',
' at org.apache.log4j.Category.log(Category.java:856)',
' at org.apache.juli.logging.impl.Log4JLogger.error(Log4JLogger.java:251)',
' at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:274)',
' at java.lang.Thread.run(Thread.java:662)',
'',
' Locked ownable synchronizers:',
' - None',
].join('\n');

var analyzer = new Analyzer(threadDump);
var threads = analyzer.threads;
assert.equal(threads.length, 1);
var thread = threads[0];

assert.equal(thread.wantNotificationOn, null);
assert.equal(thread.wantToAcquire, '259a4a41');

var locksHeld = [ /* None */ ];
assert.deepEqual(thread.locksHeld, locksHeld);

assert.equal(thread.synchronizerClasses['259a4a41'], 'org.apache.log4j.spi.RootLogger');
assert.equal(thread.synchronizerClasses['47114712gris'], null);
});

QUnit.test( "analyze thread holding locks", function(assert) {
var threadDump = [
'"ApplicationImpl pooled thread 8" daemon prio=4 tid=10d96d000 nid=0x11e68a000 runnable [11e689000]',
Expand Down