NullPointerException on calling shape.getImageData().getImageType() Java Aspose.Words 24.4

Recently upgraded from words 22.7 to 24.4 and started receiving an exception when calling shape.getImageData().getImageType() on a word document. I verified rolling back to 22.7 the issue is no longer present.

java.lang.NullPointerException: Cannot invoke "String.indexOf(String)" because "<parameter1>" is null
	at com.aspose.words.internal.zzWkY.zzH(Unknown Source)
	at com.aspose.words.internal.zzWkY.zzY62(Unknown Source)
	at com.aspose.words.internal.zzYLj.zz0B(Unknown Source)
	at com.aspose.words.internal.zzYLj.zzWzE(Unknown Source)
	at com.aspose.words.internal.zzYLj.zzWUN(Unknown Source)
	at com.aspose.words.internal.zzYLj.zzYNC(Unknown Source)
	at com.aspose.words.zzXHy.zzYpJ(Unknown Source)
	at com.aspose.words.ImageData.getImageType(Unknown Source)

@cpost Could you please attach your input problematic document here for testing? We will check the issue and provide you more information.

Yeah, I tried to attach it here but didn’t see a good way since it’s not an image file.

Try this:
https://file.io/Y2r3QeQtAFBU

Never used this service before, I think it will be deleted after it’s downloaded once.

@cpost Thank you for additional information. Unfortunately, I cannot reproduce the problem using the following simple code:

Document doc = new Document("C:\\Temp\\in.doc");
for (Shape s : (Iterable<Shape>)doc.getChildNodes(NodeType.SHAPE, true))
{
    if (s.hasImage())
        System.out.println(s.getImageData().getImageType());
}

PS: You can zip and attach document directly in the forum.

I should have thought to zip it :slight_smile:

BET.PC.00071840.0.zip (4.5 KB)

I believe this is the relevant bits from our code:

Document doc = AsposeCommon.geAsposeWordDocument(filePath.toString());
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);

for (int i = 0; i < shapes.getCount();  i++) {
	Shape shape = (Shape) shapes.get(i);
	
	if (shape.isImage()) {
		String extension = shape.getImageData().getImageType() != ImageType.UNKNOWN ? FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType()) : ".unknown";
	}
}

@cpost Thank you for additional information. Unfortunately, the problem is still not reproducible on my side. The provided code works fine and does not throw any exceptions.

Stepping through it (minified) it looks like the issue is in this method:

Probably just need to be a little more defensive here. Hopefully there’s enough un-minified code there to be able to locate it.

@cpost Unfortunately, we still cannot reproduce the problem on our side. Without ability to reproduce the problem we cannot analyze it. If possible please create a simple application that will allow us to reproduce the problem.