Exception after deepClone function usage

Hello. I need to render compare result of two docx documents.

My code:
<i style=“font-family: “Courier New”;”>
<i style=“font-family: “Courier New”;”>Document sourceDoc = new Document(“sourceDoc1.docx”);
<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>Document importDoc = new Document(“importDoc.docx”);<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>
<i style=“font-family: “Courier New”;”>Document copyOrigin = (Document) sourceDoc.deepClone(true);
<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>NodeCollection copyOriginNodes = copyOrigin.getFirstSection().getBody().getChildNodes();

sourceDoc.acceptAllRevisions();
importDoc.acceptAllRevisions();
sourceDoc.compare(importDoc, “AAA”, new Date());

Document copyAfterCompare = (Document) sourceDoc.deepClone(true);
Body bodyAfterCompare = copyAfterCompare.getFirstSection().getBody();
Node[] arrayNodeCopy = bodyAfterCompare.getChildNodes().toArray();

for (Node node : bodyAfterCompare.getChildNodes().toArray()){
node.toString(SaveFormat.HTML);
}
<pre style=“font-family: “Courier New”; background-color: rgb(255, 255, 255);”>
node.toString throws follwing exception:

<div style=“font-family: “Times New Roman”; white-space: normal;”>java.lang.ArrayIndexOutOfBoundsException: 3
<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzX.zzZ(Unknown Source)
<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzX.zzZ(Unknown Source)
<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zz3.zzW(Unknown Source)
<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZ12.zzZnH(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.getWidth(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.zzPE(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.getX(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.zzPE(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.getX(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.zzPE(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.getX(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzYO.zzPE(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzX.zzZ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzX.zzQ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzW7.zzZ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZ4K.zzZ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzXJ.zzvV(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzXJ.zzY(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZD5.zzZCR(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZD5.zzU(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZCM.zzx(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZ2N.zzS7(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzBA.zzXG(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzBB.zza8(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZQV.zzZ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.Document.updatePageLayout(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.Document.zzXI(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.Document.zzaQ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZX6.zzZ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZZY.zzZXy(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZZY.zzZXH(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZZY.zzZM(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.zzZZN.zzZJ(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”> at com.aspose.words.Node.toString(Unknown Source)<div style=“font-family: “Times New Roman”; white-space: normal;”>
<span style=“font-family: “Times New Roman”; white-space: normal;”>Without sourceDoc.deepClone <span style=“font-family: “Times New Roman”; white-space: normal;”>it works fine
<span style=“font-family: “Times New Roman”; white-space: normal;”>Aspose version: 16.5.0
Hi Leonid,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for Java 16.6.0 and have not found the shared issue. Please use Aspose.Words for Java 16.6.0 and let us know if you have any more queries.

Sorry but this version doesn’t work also. I’ve attached code and documents. Check it please.


Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 3
at com.aspose.words.zzX.zzZ(Unknown Source)
at com.aspose.words.zzX.zzZ(Unknown Source)
at com.aspose.words.zz2.zzW(Unknown Source)
at com.aspose.words.zzZ0F.zzZmy(Unknown Source)
at com.aspose.words.zzYN.getWidth(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzYN.getX(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzYN.getX(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzYN.getX(Unknown Source)
at com.aspose.words.zzYN.zzPw(Unknown Source)
at com.aspose.words.zzX.zzZ(Unknown Source)
at com.aspose.words.zzX.zzQ(Unknown Source)
at com.aspose.words.zzW6.zzZ(Unknown Source)
at com.aspose.words.zzZ3Y.zzZ(Unknown Source)
at com.aspose.words.zzXI.zzvQ(Unknown Source)
at com.aspose.words.zzXI.zzY(Unknown Source)
at com.aspose.words.zzZCN.zzZBL(Unknown Source)
at com.aspose.words.zzZCN.zzU(Unknown Source)
at com.aspose.words.zzZC4.zzx(Unknown Source)
at com.aspose.words.zzZ21.zzS7(Unknown Source)
at com.aspose.words.zzAY.zzXK(Unknown Source)
at com.aspose.words.zzAZ.zz9G(Unknown Source)
at com.aspose.words.zzZQD.zzZ(Unknown Source)
at com.aspose.words.Document.updatePageLayout(Unknown Source)
at com.aspose.words.Document.zzXM(Unknown Source)
at com.aspose.words.Document.zzao(Unknown Source)
at com.aspose.words.zzZWP.zzZ(Unknown Source)
at com.aspose.words.zzZZJ.zzZX1(Unknown Source)
at com.aspose.words.zzZZJ.zzZXa(Unknown Source)
at com.aspose.words.zzZZJ.zzZM(Unknown Source)
at com.aspose.words.zzZZ8.zzZJ(Unknown Source)
at com.aspose.words.Node.toString(Unknown Source)
at com.parley.document.service.wrongCompare.main(wrongCompare.java:20)
Hi Leonid,

Thanks for sharing the detail. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-13964. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-13964) have been fixed in this Aspose.Words for .NET 16.8.0 update and this Aspose.Words for Java 16.8.0 update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.