Hi,
I’m trying to convert 2 dwg files to png at the same time, so I start two threads at the same time.
But it always throw exception.
com.aspose.cad.cadexceptions.ImageLoadException: Image loading failed.
Caused by: class com.aspose.cad.internal.Exceptions.ArgumentException: Item has already been added. Key in dictionary: ‘98’ Key being added: ‘98’
com.aspose.cad.internal.F.k.a(Unknown Source)
com.aspose.cad.internal.F.k.b(Unknown Source)
com.aspose.cad.internal.dI.n.(Unknown Source)
com.aspose.cad.internal.dI.k.(Unknown Source)
com.aspose.cad.internal.dI.n.a(Unknown Source)
com.aspose.cad.internal.dI.aA.a(Unknown Source)
com.aspose.cad.internal.dI.az.load(Unknown Source)
com.aspose.cad.Image.a(Unknown Source)
com.aspose.cad.Image.load(Unknown Source)
So I am wondering if the sdk support multiple threads running or not?
@huanglanxin,
I have observed your comments. Can you please share source file and sample code along with environment details and also please share which version you are using on your end so that we can further investigate to help you out.
Env: windows 10 x64, jdk1.8, aspose.cad 17.12
code below:
import com.aspose.cad.Image;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
public class CadThreadTest {
private static final String DWG1 = "/path/to/dwg1";
private static final String DWG2 = "/path/to/dwg2";
public void test() {
ExecutorService executorService = Executors.newFixedThreadPool(2);
executorService.execute(new CadThread(DWG1));
executorService.execute(new CadThread(DWG2));
executorService.shutdown();
try {
executorService.awaitTermination(100, TimeUnit.SECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new CadThreadTest().test();
}
class CadThread implements Runnable {
private String filePath;
public CadThread(String filePath) {
this.filePath = filePath;
}
public void run() {
System.out.println(Thread.currentThread().getName() + " - Processing: " + filePath);
Image image = Image.load(filePath);
try {
image.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
@huanglanxin,
Thanks for sharing sample code with us. As i requested earlier please share source files as well for further investigation.
sample.zip (800.8 KB)
Attached sample dwg files
@huanglanxin,
I have worked with file shared by you using Aspose.CAD for Java 17.12 and have been able to observe the issue. A ticket with ID CADJAVA-341 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.