You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2020/12/04 07:22:30 UTC
[uima-uimaj] 01/01: [UIMA-6295] CAS transportable Java object not
serialised or deserialised with compressed binary
This is an automated email from the ASF dual-hosted git repository.
rec pushed a commit to branch UIMA-6295-CAS-transportable-Java-object-not-serialised-or-deserialised-with-compressed-binary
in repository https://gitbox.apache.org/repos/asf/uima-uimaj.git
commit 15733de9437184deb7c00067bfd3d9b7b1b8c3cf
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Fri Dec 4 08:22:24 2020 +0100
[UIMA-6295] CAS transportable Java object not serialised or deserialised with compressed binary
- Added a set tracking whether _save_to_cas_data() has already been called on an FS during the serialization process to avoid _save_to_cas_data() being called twice and potentially creating new FSes in that way that are then not discovered and properly linked up by the serialization process anymore.
---
.../org/apache/uima/cas/impl/BinaryCasSerDes6.java | 27 ++++++++++++++--------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java b/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
index b5d7b39..00ebcf9 100644
--- a/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
+++ b/uimaj-core/src/main/java/org/apache/uima/cas/impl/BinaryCasSerDes6.java
@@ -63,6 +63,7 @@ import org.apache.uima.internal.util.IntListIterator;
import org.apache.uima.internal.util.IntVector;
import org.apache.uima.internal.util.Misc;
import org.apache.uima.internal.util.PositiveIntSet;
+import org.apache.uima.internal.util.PositiveIntSet_impl;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.cas.BooleanArray;
import org.apache.uima.jcas.cas.ByteArray;
@@ -386,7 +387,12 @@ public class BinaryCasSerDes6 implements SlotKindsConstants {
* FSs being serialized. For delta, just the deltas above the delta line.
* Constructed from indexed plus reachable, above the delta line.
*/
- private List<TOP> fssToSerialize;
+ private List<TOP> fssToSerialize;
+
+ /**
+ * Set of FSes on which UimaSerializable _save_to_cas_data has already been called.
+ */
+ private PositiveIntSet uimaSerializableSavedToCas;
/**
* FSs being processed, including below-the-line deltas.
@@ -735,6 +741,8 @@ public class BinaryCasSerDes6 implements SlotKindsConstants {
os = new OptimizeStrings(doMeasurements);
+ uimaSerializableSavedToCas = new PositiveIntSet_impl(1024, 1, 1024);
+
/******************************************************************
* Find all FSs to be serialized via the indexes
* including those FSs referenced
@@ -1491,8 +1499,9 @@ public class BinaryCasSerDes6 implements SlotKindsConstants {
}
}
} else {
- if (fs instanceof UimaSerializable) {
+ if (fs instanceof UimaSerializable && !uimaSerializableSavedToCas.contains(fs._id)) {
((UimaSerializable)fs)._save_to_cas_data();
+ uimaSerializableSavedToCas.add(fs._id);
}
final BitSet featuresModified = changedFs.featuresModified;
int next = featuresModified.nextSetBit(0);
@@ -2838,7 +2847,9 @@ public class BinaryCasSerDes6 implements SlotKindsConstants {
isTypeMapping ? fs -> isTypeInTgt(fs) : null,
isTypeMapping ? typeMapper : null)
.getAllFSsAllViews_sofas_reachable();
- ;
+ // AllFSs internally already causes _save_to_cas_data() to be called, so we have to add all
+ // the FSes that are returned here to the uimaSerializableSavedToCas tracking set
+ allFSs.getAllFSs().forEach(fs -> uimaSerializableSavedToCas.add(fs._id));
}
fssToSerialize = CASImpl.filterAboveMark(allFSs.getAllFSsSorted(), mark);
foundFSs = allFSs.getAllNew();
@@ -3037,12 +3048,10 @@ public class BinaryCasSerDes6 implements SlotKindsConstants {
fsStartIndexes.addItemId(fs, nextTgtId, isIncludedType); // maps src heap to tgt seq
if (isIncludedType) {
- // Disabled the following additional call to _save_to_cas_data, since it would cause a bug. See
- // [UIMA-6295] CAS transportable Java object not serialised or deserialised with compressed binary.
- //
- // if (fs instanceof UimaSerializable) {
- // ((UimaSerializable)fs)._save_to_cas_data();
- // }
+ if (fs instanceof UimaSerializable && !uimaSerializableSavedToCas.contains(fs._id)) {
+ ((UimaSerializable)fs)._save_to_cas_data();
+ uimaSerializableSavedToCas.add(fs._id);
+ }
// for features in type -
// strings: accumulate those strings that are in the target, if optimizeStrings != null