Conversation
…logged in order to avoid double log or memory leak when tmp file not deleted are involved (CXF-9251)
|
Hi @reta , Unfortunately, as I wrote in https://issues.apache.org/jira/browse/CXF-9251 ... I couldn't right now simulate the scenario that I had at work. For now U have to trust me on that :/ . If I have news I'll keep U posted. Keep me updated about what U think about this problem. |
Thanks a lot @vp340 , it is very possible we have missed few places, thank you for reporting those, I will take a closer look shortly |
|
Thanks a lot for your time. |
… so it launched : java.util.ConcurrentModificationException
… LoggingCallback, ensuring log only once, and prevent memory leaks
|
Hi @reta, I try another simple approch: Implement a LoggingCallback wrapper (OneTimeLoggingCallback) that ensures logging occurs only once and helps prevent memory leaks by dereferencing the LoggingCallback instance upon completion, making it eligible for garbage collection. Have a great evening! P.S. |
…sure the logging doesn't happen twice using also an atomic boolean. (if clean is set to 2 seconds and this.wrappedCallback = null is only set in the cpu cache and not wrote in memory)
| } catch (Exception ex) { | ||
| // ignore | ||
| } | ||
| message.setContent(OutputStream.class, origStream); |
There was a problem hiding this comment.
@vp340 I think we should just unregister callback on close? That would make sure, it will be called only once
message.setContent(OutputStream.class, origStream);
cos.deregisterCallback(this);
DelayedCachedOutputStreamCleaner held in a queue list the reference to CachedOutputStream s. The ones never unregistered from the queue are the one who has a tmp file not deleted.
When the timer thread tries to close() the cos ... if the cos is actually a LoggingOutputStream it also calls the onClose() of LoggingCallback.
In certain cases so it logs twice (the second without payload because it is already consumed)
Furthermore, it keeps inMem all the objects that are referenced in the class (such as the Message) and that are needed for logging.
I propose to deregister the callback at the end to avoid rewind calls to it.
This way even if DelayedCachedOutputStreamCleaner keeps the LoggingOutputStream in the queue, there isn't the reference to the callback and so GC can clean those object. And double logs are not produce in the first place