Skip to content

Commit

Permalink
Resolve Memory Leak
Browse files Browse the repository at this point in the history
- Cleared the reader before marking it unused
  • Loading branch information
mhickson committed Nov 5, 2023
1 parent b7a68ad commit 98e41ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/org/apache/xml/utils/XMLReaderManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,15 @@ public synchronized XMLReader getXMLReader() throws SAXException {
* @param reader The XMLReader that's being released.
*/
public synchronized void releaseXMLReader(XMLReader reader) {
if (reader == null) {
return;
}
// If the reader that's being released is the cached reader
// for this thread, remove it from the m_isUse list.
if (m_readers.get() == reader && reader != null) {
m_inUse.remove(reader);
// for this thread, mark it as no longer being in use.
if (m_readers.get() == reader) {
m_readers.set(null);
m_inUse.put(reader, Boolean.FALSE);
}
m_inUse.remove(reader);
}
}

0 comments on commit 98e41ab

Please sign in to comment.