We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Infinite loop when calling NodeRendererBase.renderToSize using Java


I am attaching a sample demo app and an input file. It should print text
“Start visiting shape” before calling the API and print “finished visiting shape” after it completes.

From the demo you will see that it never finishes. The code is hung in the following stack trace:

at sun/dc/pr/PathDasher.appendLine(Native Method)
at sun/dc/DuctusRenderingEngine.feedConsumer(DuctusRenderingEngine.java:293)
at sun/dc/DuctusRenderingEngine.strokeTo(DuctusRenderingEngine.java:170)
at sun/java2d/pipe/LoopPipe.getStrokeSpans(LoopPipe.java:290)
at sun/java2d/pipe/LoopPipe.draw(LoopPipe.java:213)
at sun/java2d/pipe/PixelToParallelogramConverter.draw(PixelToParallelogramConverter.java:160)
at sun/java2d/pipe/ValidatePipe.draw(ValidatePipe.java:166)
at sun/java2d/SunGraphics2D.draw(SunGraphics2D.java:2509)
at com/aspose/words/internal/zzFA.zzZ(Bytecode PC:336)
at com/aspose/words/internal/zzP5.zzY(Bytecode PC:64)
at com/aspose/words/internal/zzH.zzY(Bytecode PC:5)
at com/aspose/words/internal/zzZN.zzY(Bytecode PC:10)
at com/aspose/words/internal/zzZY.zzZ(Bytecode PC:12)
at com/aspose/words/internal/zzI.zzZ(Bytecode PC:29)
at com/aspose/words/internal/zzM.zzZ(Bytecode PC:7)
at com/aspose/words/internal/zzI.zzZ(Bytecode PC:29)
at com/aspose/words/internal/zzM.zzZ(Bytecode PC:7)
at com/aspose/words/internal/zzP5.zzZ(Bytecode PC:102)
at com/aspose/words/internal/zzP5.zzZ(Bytecode PC:138)
at com/aspose/words/NodeRendererBase.renderToSize(Bytecode PC:33)

The command to run the sample app is simply:

java -jar Aspose_Demo.jar

And ensure the input.docx file is a sibling as the path is hardcoded.

Can you please advise how we should proceed? When this thread gets hung, it blocks other threads in our production application and causes significant trouble. It requires a production restart.

Can you please let me know if it is possible for us to programmatically detect (using Aspose.Words API) which shapes will cause the infinite loop so that we can skip them and prevent issues in the production environment? This would be a nice short term workaround to alleviate the troubles.

Another potential workaround for the short term would be if we could somehow interrupt the Aspose thread. Is there some mechanism where we can tell Aspose to abort and end what it is doing quickly? I.e. does it check for the thread being interrupted or anything? Can I call Task.interrupt() to interrupt the task and have it finish? I am guessing that is not an option in a tight loop like where this is likely.

Also, please let us know when the issue can be resolved in Aspose directly.

Also, I was not able to upload the JAR or the word document as it is not authorized. Please let me know an acceptable method to upload the content.


Here is the code for the sample app since I can’t upload the JAR.

I reproduced it using the latest Aspose v20.4

import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import com.aspose.words.Document;
import com.aspose.words.DocumentVisitor;
import com.aspose.words.Shape;
import com.aspose.words.ShapeRenderer;
import com.aspose.words.VisitorAction;

public class Main {

public static void main(String[] args) throws FileNotFoundException, Exception {
	// TODO Auto-generated method stub
	final DocumentVisitor visitor = new DocumentVisitor() {
		public int visitShapeStart(Shape shape) throws Exception {
			System.out.println("Start visiting shape");
			ShapeRenderer shapeRenderer = shape.getShapeRenderer();
			final int width = (int) shape.getWidth();
			final int height = (int) shape.getHeight();
			BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
			Graphics2D graphic = bufferedImage.createGraphics();
			shapeRenderer.renderToSize(graphic, 0, 0, width, height);
			System.out.println("finished visiting shape");
			return VisitorAction.CONTINUE;
	Document doc = new Document(new FileInputStream(new File("input.docx")));



Could you please ZIP and attach your input Word document here for testing? We will investigate the issue and provide you more information on it.

I have submitted the sample app to you via a direct message. Please let me know if it works. I will probably delete it from the remote service once you have it. Please let me know when it is safe to do so.



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 WORDSJAVA-2387 . 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 WORDSJAVA-2387) have been fixed in this Aspose.Words for .NET 20.8 update and this Aspose.Words for Java 20.8 update.