Skip to content

Commit a75ee01

Browse files
committed
Don't store the org.xml.sax.Locator object. We never need it and the fact that we keep a reference may contribute to the issue described in AXIS-2863.
1 parent a65c9cc commit a75ee01

2 files changed

Lines changed: 5 additions & 20 deletions

File tree

axis/src/main/java/org/apache/axis/encoding/DeserializationContext.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ public class DeserializationContext implements ContentHandler, DTDHandler,
8484

8585
private NSStack namespaces = new NSStack();
8686

87-
private Locator locator;
88-
8987
// Class used for deserialization using class metadata from
9088
// downstream deserializers
9189
private Class destClass;
@@ -964,14 +962,11 @@ public void endPrefixMapping(String prefix)
964962

965963
public void setDocumentLocator(Locator locator)
966964
{
967-
if (!doneParsing && (recorder != null)) {
968-
recorder.setDocumentLocator(locator);
969-
}
970-
this.locator = locator;
971-
}
972-
973-
public Locator getDocumentLocator() {
974-
return locator;
965+
// We don't store the Locator because we don't need it. In addition it is typically
966+
// a reference to some internal object of the parser and not keeping that reference
967+
// ensures that this object (which may be heavyweight) can be garbage collected
968+
// early (see AXIS-2863 for an issue that may be related to this: in that case,
969+
// Locator is implemented by oracle.xml.parser.v2.XMLReader).
975970
}
976971

977972
public void characters(char[] p1, int p2, int p3) throws SAXException {

axis/src/main/java/org/apache/axis/message/SAX2EventRecorder.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public class SAX2EventRecorder {
2828

2929
private static final Integer Z = new Integer(0);
3030

31-
private static final Integer STATE_SET_DOCUMENT_LOCATOR = new Integer(0);
3231
private static final Integer STATE_START_DOCUMENT = new Integer(1);
3332
private static final Integer STATE_END_DOCUMENT = new Integer(2);
3433
private static final Integer STATE_START_PREFIX_MAPPING = new Integer(3);
@@ -53,22 +52,16 @@ public class SAX2EventRecorder {
5352
private static final Integer STATE_END_CDATA = new Integer(17);
5453
private static final Integer STATE_COMMENT = new Integer(18);
5554

56-
org.xml.sax.Locator locator;
5755
objArrayVector events = new objArrayVector();
5856

5957
public void clear() {
60-
locator = null;
6158
events = new objArrayVector();
6259
}
6360
public int getLength()
6461
{
6562
return events.getLength();
6663
}
6764

68-
public int setDocumentLocator(org.xml.sax.Locator p1) {
69-
locator = p1;
70-
return events.add(STATE_SET_DOCUMENT_LOCATOR, Z,Z,Z,Z);
71-
}
7265
public int startDocument() {
7366
return events.add(STATE_START_DOCUMENT, Z,Z,Z,Z);
7467
}
@@ -187,9 +180,6 @@ public void replay(int start, int stop, ContentHandler handler) throws SAXExcept
187180
} else if (event == STATE_SKIPPED_ENTITY) {
188181
handler.skippedEntity((String)events.get(n,1));
189182

190-
} else if (event == STATE_SET_DOCUMENT_LOCATOR) {
191-
handler.setDocumentLocator(locator);
192-
193183
} else if (event == STATE_START_DOCUMENT) {
194184
handler.startDocument();
195185

0 commit comments

Comments
 (0)