Cat.logError(new Exception("null child message"))触发死循环

bgibtngc  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(44)

Describe the bug
cat 客户端发生死循环触发应用down机应

java.lang.Exception: null child message
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:63)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:30)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:563)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:574)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.truncateAndFlush(DefaultMessageManager.java:609)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.addTransactionChild(DefaultMessageManager.java:411)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.add(DefaultMessageManager.java:402)
   at com.dianping.cat.message.internal.DefaultMessageManager.add(DefaultMessageManager.java:83)
   at com.dianping.cat.message.internal.DefaultEvent.complete(DefaultEvent.java:42)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logEvent(DefaultMessageProducer.java:112)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:85)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:95)
   at com.dianping.cat.Cat.logError(Cat.java:289)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:63)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:30)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:563)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:574)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.truncateAndFlush(DefaultMessageManager.java:609)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.addTransactionChild(DefaultMessageManager.java:411)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.add(DefaultMessageManager.java:402)
   at com.dianping.cat.message.internal.DefaultMessageManager.add(DefaultMessageManager.java:83)
   at com.dianping.cat.message.internal.DefaultEvent.complete(DefaultEvent.java:42)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logEvent(DefaultMessageProducer.java:112)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:85)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:95)
   at com.dianping.cat.Cat.logError(Cat.java:289)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:63)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:30)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:563)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:574)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.truncateAndFlush(DefaultMessageManager.java:609)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.addTransactionChild(DefaultMessageManager.java:411)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.add(DefaultMessageManager.java:402)
   at com.dianping.cat.message.internal.DefaultMessageManager.add(DefaultMessageManager.java:83)
   at com.dianping.cat.message.internal.DefaultEvent.complete(DefaultEvent.java:42)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logEvent(DefaultMessageProducer.java:112)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:85)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:95)
   at com.dianping.cat.Cat.logError(Cat.java:289)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:63)
   at com.dianping.cat.message.internal.DefaultTransaction.addChild(DefaultTransaction.java:30)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:563)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.migrateMessage(DefaultMessageManager.java:574)
   at com.dianping.cat.message.internal.DefaultMessageManager$TransactionHelper.truncateAndFlush(DefaultMessageManager.java:609)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.addTransactionChild(DefaultMessageManager.java:411)
   at com.dianping.cat.message.internal.DefaultMessageManager$Context.add(DefaultMessageManager.java:402)
   at com.dianping.cat.message.internal.DefaultMessageManager.add(DefaultMessageManager.java:83)
   at com.dianping.cat.message.internal.DefaultEvent.complete(DefaultEvent.java:42)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logEvent(DefaultMessageProducer.java:112)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:85)
   at com.dianping.cat.message.internal.DefaultMessageProducer.logError(DefaultMessageProducer.java:95)
   at com.dianping.cat.Cat.logError(Cat.java:289)

To Reproduce
部分使用java版本 cat客户端 应用,偶发性发生down机。

Desktop (please complete the following information):

  • Version com.dianping.catcat-client3.0.0
eivnm1vs

eivnm1vs1#

方案一

public class DefaultTransaction extends AbstractMessage implements Transaction {
	@Override
	public DefaultTransaction addChild(Message message) {
		if (m_children == null) {
			m_children = new ArrayList<Message>();
		}

		if (message != null) {
			m_children.add(message);
		} else {
                        // 可以通过暂时注释掉这个message 避免死循环
			// Cat.logError(new Exception("null child message"));
		}
		return this;
	}
}

方案二

public class DefaultTransaction extends AbstractMessage implements Transaction {
	@Override
	public DefaultTransaction addChild(Message message) {
		if (m_children == null) {
			m_children = new ArrayList<Message>();
		}

		if(message == null) {
			message = new DefaultEvent("exception", "null child message");
		}
		m_children.add(message);
		
		return this;
	}
}

暂时的方案可以通过不在累加 null child message 节点实现,但是无法排查出第一次空节点产生的原因。

相关问题