mirror of
https://gitee.com/kekingcn/file-online-preview.git
synced 2026-09-13 16:34:53 +00:00
fix: refresh ImageIO plugins before PDF conversion
This commit is contained in:
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -93,6 +94,8 @@ public class PdfToJpgService {
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
refreshImageIoPlugins();
|
||||
|
||||
int maxThreads = ConfigConstants.getPdfMaxThreads();
|
||||
// 使用固定大小的虚拟线程池
|
||||
this.virtualThreadExecutor = Executors.newFixedThreadPool(maxThreads,
|
||||
@@ -104,6 +107,13 @@ public class PdfToJpgService {
|
||||
scheduleCacheCleanup();
|
||||
}
|
||||
|
||||
static void refreshImageIoPlugins() {
|
||||
// ImageIO only scans once automatically. If another launcher or Java agent initializes
|
||||
// it before Spring Boot installs its application class loader, nested JAR providers such
|
||||
// as jbig2-imageio remain invisible until the application class path is scanned again.
|
||||
ImageIO.scanForPlugins();
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void shutdown() {
|
||||
logger.info("开始关闭PDF转换服务...");
|
||||
@@ -852,4 +862,4 @@ public class PdfToJpgService {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user