Skip to content

Commit b8e6ccb

Browse files
committed
..
1 parent 119e4f0 commit b8e6ccb

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

docviewerapi/src/com/log4ic/utils/convert/DocViewerConverter.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ public static LinkedList<File> getRunningQueue() {
4848
* @throws Exception
4949
*/
5050
public static File toSwf(File file, String outPath) throws Exception {
51-
synchronized (lock) {
52-
if (pdfConverter == null) {
53-
//PDFConverter.loadConfig();
54-
pdfConverter = new PDFConverter();
51+
if (pdfConverter == null) {
52+
synchronized (lock) {
53+
if (pdfConverter == null) {
54+
//PDFConverter.loadConfig();
55+
pdfConverter = new PDFConverter();
56+
}
5557
}
5658
}
5759
try {
58-
runningQueue.add(file);
60+
synchronized (lock) {
61+
runningQueue.add(file);
62+
}
5963
String suffix = FileUtils.getFileSuffix(file);
6064
if (StringUtils.isBlank(suffix)) {
6165
throw new Exception("The file not has a suffix!");
@@ -67,18 +71,24 @@ public static File toSwf(File file, String outPath) throws Exception {
6771

6872
return pdfConverter.convert(pdf, outPath, DocViewer.isSplitPage(), false);
6973
} finally {
70-
runningQueue.remove(file);
74+
synchronized (lock) {
75+
runningQueue.remove(file);
76+
}
7177
}
7278
}
7379

7480
public static File toPDF(File file, String outPath) throws Exception {
75-
synchronized (lock) {
76-
if (officeConverter == null) {
77-
officeConverter = new OfficeConverter();
81+
if (officeConverter == null) {
82+
synchronized (lock) {
83+
if (officeConverter == null) {
84+
officeConverter = new OfficeConverter();
85+
}
7886
}
7987
}
8088
try {
81-
runningQueue.add(file);
89+
synchronized (lock) {
90+
runningQueue.add(file);
91+
}
8292
File pdf = null;
8393

8494
File dir = deploy(file, outPath);
@@ -88,7 +98,9 @@ public static File toPDF(File file, String outPath) throws Exception {
8898
}
8999
return pdf;
90100
} finally {
91-
runningQueue.remove(file);
101+
synchronized (lock) {
102+
runningQueue.remove(file);
103+
}
92104
}
93105
}
94106
}

0 commit comments

Comments
 (0)