Textabsorber not threadsafe?

We updated Aspose.Pdf from 22.9 to 25.2 in our net48 application.

After this some of our tests began to sporadically fail with this error.

System.NullReferenceException : Object reference not set to an instance of an object.
   at #=ziN9ESXTDEHqQ9i28HzgngP3cCaXcYn3I27OQt_g_ijS91zPT4exR6tc=.#=zXUwQtM4=(Int32 #=ztinjIsc=, SelectFont #=z_TjERaQ=)
   at #=ziN9ESXTDEHqQ9i28HzgngP3cCaXcYn3I27OQt_g_ijS91zPT4exR6tc=.#=ziVxmg0s=(Page #=zSKPUWIc=)
   at #=zvOyvz6ikcTWERin$zzapPX3dfSlIIcEuKMdb$4n8MpXHb3GXVlgoc6IwCIcl.#=zo0mnZ$uIAeQC(BaseOperatorCollection #=zmDI5EdQ=, Resources #=zcTTRzXs=, Page #=zSKPUWIc=, Rectangle #=zJ9WS4RLIO62k)
   at #=zvOyvz6ikcTWERin$zzapPX3dfSlIIcEuKMdb$4n8MpXHb3GXVlgoc6IwCIcl.#=zo0mnZ$uIAeQC(BaseOperatorCollection #=zmDI5EdQ=, Resources #=zcTTRzXs=, Rectangle #=zJ9WS4RLIO62k)
   at #=zvOyvz6ikcTWERin$zzapPX3dfSlIIcEuKMdb$4n8MpXHb3GXVlgoc6IwCIcl.#=zm0pxfxw=(Boolean #=z3EVHd0iNbJch)
   at #=zvOyvz6ikcTWERin$zzapPX3dfSlIIcEuKMdb$4n8MpXHb3GXVlgoc6IwCIcl..ctor(Page #=zSKPUWIc=, TextSearchOptions #=zlPqoBngURRHG, Boolean #=zjoTkxZTjTzVp)
   at Aspose.Pdf.Text.TextAbsorber.Visit(Page page)
   at Aspose.Pdf.PageCollection.Accept(TextAbsorber visitor)

This never happens if the tests are executed in succession with a little delay.
Our tests are mostly structured like this:


using var file = File.OpenRead("SomeFile.pdf");
using var document = new Aspose.Pdf.Document(file);
var absorber = new TextAbsorber();
document.Pages.Accept(absorber);
absorber.Text.ShouldContain("expected text");

For now I put this into a while loop to make our tests pass again.
But please have a look into it.

            TextAbsorber absorber = null!;
            var retryCount = 1;
            while (retryCount <= 4)
            {
                absorber = new TextAbsorber();
                try
                {
                    pdfDocument.Pages.Accept(absorber);
                    break;
                }
                catch (NullReferenceException)
                {
                    retryCount += 1;
                }
            }
            if (retryCount > 4) 
                Assert.Fail("Absorption could not be done");

@SimonSchwendele
We are looking into your question and will provide an explanation soon.

@SimonSchwendele
Currently the library does not guarantee thread-safe operation with one (not different) document. Work is underway to eliminate this shortcoming and if you attached the code you use and any document with which this happens - I would create a task for correction to the development team.