You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/02/23 23:08:05 UTC
svn commit: r511134 -
/xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java
Author: mrglavas
Date: Fri Feb 23 14:08:04 2007
New Revision: 511134
URL: http://svn.apache.org/viewvc?view=rev&rev=511134
Log:
Fixing JIRA Bug #977:
http://issues.apache.org/jira/browse/XERCESJ-977
It was possible to get an NPE when calling setChunkIndex or setChunkValue
if the chunk was previously deleted because its reference count dropped
to 0. We now re-create the chunk if it got deleted.
This will churn the garbage collector a bit. There's probably a more
performant solution but this seemed like the safest thing to do given the
stability of the rest of the deferred DOM implementation.
Modified:
xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java
Modified: xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java?view=diff&rev=511134&r1=511133&r2=511134
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DeferredDocumentImpl.java Fri Feb 23 14:08:04 2007
@@ -1952,11 +1952,17 @@
if (value == -1) {
return clearChunkIndex(data, chunk, index);
}
- int ovalue = data[chunk][index];
+ int [] dataChunk = data[chunk];
+ // Re-create chunk if it was deleted.
+ if (dataChunk == null) {
+ createChunk(data, chunk);
+ dataChunk = data[chunk];
+ }
+ int ovalue = dataChunk[index];
if (ovalue == -1) {
- data[chunk][CHUNK_SIZE]++;
+ dataChunk[CHUNK_SIZE]++;
}
- data[chunk][index] = value;
+ dataChunk[index] = value;
return ovalue;
}
private final String setChunkValue(Object data[][], Object value,
@@ -1964,12 +1970,18 @@
if (value == null) {
return clearChunkValue(data, chunk, index);
}
- String ovalue = (String) data[chunk][index];
+ Object [] dataChunk = data[chunk];
+ // Re-create chunk if it was deleted.
+ if (dataChunk == null) {
+ createChunk(data, chunk);
+ dataChunk = data[chunk];
+ }
+ String ovalue = (String) dataChunk[index];
if (ovalue == null) {
- RefCount c = (RefCount) data[chunk][CHUNK_SIZE];
+ RefCount c = (RefCount) dataChunk[CHUNK_SIZE];
c.fCount++;
}
- data[chunk][index] = value;
+ dataChunk[index] = value;
return ovalue;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org