Free Support Forum - aspose.com

Cloning PPT slide throws NullPointerException in multi threaded mode

Hi,
I have a powerpoint template file (.potx) in which I have a few slides. In my code I am trying to generate a PPT by cloning slides from the .potx file and setting values in it. Let’s call the .potx template as sourcePPT and the new PPT that I am trying to create as destinationPPT.

The issue is: the following code works without issues in single threaded mode. But when I have multiple-threads cloning from the source slide it throws the following NPE. I have made sure that my class is thread-safe (there are no class variables that I am using anywhere in the code, its a local method variables, so each thread will have its own copy).

java.lang.NullPointerException
at com.aspose.slides.a9.equals(Unknown Source)
at com.aspose.slides.ae4.equals(Unknown Source)
at com.aspose.slides.PVIObject.equals(Unknown Source)
at com.aspose.slides.ae7.do(Unknown Source)
at com.aspose.slides.acu.do(Unknown Source)
at com.aspose.slides.ap3.do(Unknown Source)
at com.aspose.slides.apm.do(Unknown Source)
at com.aspose.slides.apm.do(Unknown Source)
at com.aspose.slides.r.do(Unknown Source)
at com.aspose.slides.rq.do(Unknown Source)
at com.aspose.slides.rq.do(Unknown Source)
at com.aspose.slides.bg.do(Unknown Source)
at com.aspose.slides.vs.do(Unknown Source)
at com.aspose.slides.ald.do(Unknown Source)
at com.aspose.slides.agp.do(Unknown Source)
at com.aspose.slides.agp.do(Unknown Source)
at com.aspose.slides.age.do(Unknown Source)
at com.aspose.slides.MasterSlideCollection.do(Unknown Source)
at com.aspose.slides.MasterSlideCollection.do(Unknown Source)
at com.aspose.slides.SlideCollection.addClone(Unknown Source)
at com.aspose.slides.SlideCollection.insertClone(Unknown Source)
at

code:

Presentation sourcePPT = new 
Presentation(ResourceUtil.getResourcePath(DEFAULT_PREBID_IMPS_PPT_TEMPLATE_PATH));
Presentation destinationPPT = new Presentation();
ISlideCollection destinationSlides = destinationPPT.getSlides();
destinationSlides.insertClone(destinationSlides.size(), sourcePPT.getSlides().get_Item(indexOfSourceSlide));

The issue with NPE happens only when multiple threads are running this code (again, as mentioned earlier this code is in a method and no class variables being used, so it is completely thread safe).

Is Aspose thread safe? Am I doing the cloning correctly ?

@hese2428,
Welcome to our community! Thank you for the issue description. To help you, we need to know the following:

  • The POTX file (you can compress the file to a ZIP archive and upload it)
  • The code example with multithreaded cloning for reproducing the error
  • The version of Aspose.Slides you used

HI Andrey,

Thanks for your quick response! I am attaching the code extracted into a class that you can run. Also attaching the potx file, before running the code just update POTX_TEMPLATE_PATH.

Aspose version I am using is Java 21.3.
Env: MacOS Mojave 10.14.6
aspose.zip (1.9 MB)

Note: When I kept only one slide in my source template, I did not get the NPE exception. So it is probably something to do with destinationPTT taking time to clone slides from a source that has many slides ?

@hese2428,
Thank you for the additional information. I reproduced the error and received the same result. I’ve logged the issue in our tracking system with ID SLIDESJAVA-38525. Our development team will investigate this case. You will be notified when it is fixed.

Aspose.Slides is being developed in compliance with this concept.

thanks for taking a look! We were in the process of buying the library, but this would be a show stopper for us because our application is multi-threaded and should generate at least 10 reports simultaneously. Is there an ETA for the fix, so we can plan accordingly.

@hese2428,
I requested an estimated time to fix this issue from our development team. I let you know as soon as possible.

Thanks Andrey, looking forward to hearing from you.

HI Andrey, any word on this ?

@hese2428,
A fix for the error you described will be released in Aspose.Slides 21.5.

thanks, do you know when that would be ?

@hese2428,
Aspose.Slides 21.5 will be released towards the end of May.