Null pointer exception when performing setText in SplitRun function using Aspose Docs

I have this function (SplitRun) that I am using in a class where I am highlighting text that I mark for find in a word docs.
private static Run splitRun(Run run, int position) throws Exception
{
Run afterRun = (Run)run.deepClone(true);
String sText = run.getText();
if (sText!= null && sText.length() >= position)
{
afterRun.setText(run.getText().substring(position));
run.setText(run.getText().substring((0), (0) + (position)));
run.getParentNode().insertAfter(afterRun, run);
}
return afterRun;
}
I have turned on the TrackChanges feature in the docx file. This works fine. But the document is not detecting & showing any changes even though the code has changed the font color. Why is this happening?

I introduced the following line after opening the doc so that the track changes API is set in my program.
doc.startTrackRevisions(“Test User”, Calendar.getInstance().getTime());

But when I run the program, I get a null pointer exception. The following is the stack trace
Exception in thread “main” java.lang.NullPointerException
at com.aspose.words.Run.setText(Unknown Source)
at tool.api.DocumentManagement.ReplaceEvaluatorFindAndHighlight.splitRun(ReplaceEvaluatorFindAndHighlight.java:95)
at tool.api.DocumentManagement.ReplaceEvaluatorFindAndHighlight.replacing(ReplaceEvaluatorFindAndHighlight.java:39)
at com.aspose.words.zz0V.zzZVz(Unknown Source)
at com.aspose.words.Range.replace(Unknown Source)
at tool.api.DocumentManagement.DocxHeaderFooterFixup.fixupDocxHeaderAndFooter(DocxHeaderFooterFixup.java:150)
at tool.api.DocumentManagement.DocxHeaderFooterFixup.main(DocxHeaderFooterFixup.java:42)

@Louis.Coutinho

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a simple Java application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.