When dumping the transaction manager context entries, if an exception was thrown in the dump() of a Loggeable or the toString() of the last-resort case for printing an entry value, then the context dump would explode with the exception.
This had two problems:
1) leaving an incomplete context dump
2) leaving an invalid XML log
For example
<log realm="org.jpos.transaction.TransactionManager" at="2024-11-21T12:38:49.741993" lifespan="130ms">
<abort>
...
<context>
...some ctx entries...
...some ctx entries...
ACCOUNT: org.hibernate.LazyInitializationException: could not initialize proxy [org.jpos.gl.FinalAccount#1980] - no Session
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:176)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:322)
... (more stack trace) ...
</log>
As can be seen, the toString() of the value for the ACCOUNT entry (some hibernate proxy in the example, but it's irrelevant to the explanation), threw an Exception.
The rest of the ctx is not dumped, but worse: </context> and </abort> are not closed.
When dumping the transaction manager context entries, if an exception was thrown in the
dump()
of aLoggeable
or thetoString()
of the last-resort case for printing an entry value, then the context dump would explode with the exception.This had two problems: 1) leaving an incomplete context dump 2) leaving an invalid XML log For example
As can be seen, the
toString()
of the value for theACCOUNT
entry (some hibernate proxy in the example, but it's irrelevant to the explanation), threw anException
.The rest of the ctx is not dumped, but worse:
</context>
and</abort>
are not closed.This PR fixes that.