mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-19 08:46:09 -04:00
Ignore RejectedExecutionException
This commit is contained in:
parent
5386ae3736
commit
a0c619a747
@ -29,6 +29,7 @@ import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.HMCLog;
|
||||
import org.jackhuang.hmcl.api.event.process.JavaProcessStoppedEvent;
|
||||
import org.jackhuang.hmcl.api.func.Consumer;
|
||||
import org.jackhuang.hmcl.ui.LogWindow;
|
||||
@ -92,15 +93,24 @@ public class Log4jHandler extends Thread implements Consumer<JavaProcessStoppedE
|
||||
if (!interrupted.get())
|
||||
return;
|
||||
if (t.getSource() == monitor) {
|
||||
try {
|
||||
executorService.submit(() -> {
|
||||
if (!interrupted.get()) {
|
||||
if (enabled)
|
||||
newLogLine("</output>").get();
|
||||
if (enabled) {
|
||||
Future f = newLogLine("</output>");
|
||||
if (f != null)
|
||||
f.get();
|
||||
}
|
||||
outputStream.close();
|
||||
join();
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
HMCLog.err("Please contact author", e);
|
||||
} finally {
|
||||
executorService.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,6 +126,7 @@ public class Log4jHandler extends Thread implements Consumer<JavaProcessStoppedE
|
||||
* @param content The content to be written to the log
|
||||
*/
|
||||
public Future newLogLine(String content) {
|
||||
try {
|
||||
return executorService.submit(() -> {
|
||||
if (enabled)
|
||||
try {
|
||||
@ -135,6 +146,9 @@ public class Log4jHandler extends Thread implements Consumer<JavaProcessStoppedE
|
||||
else
|
||||
printlnImpl(content, Level.guessLevel(content));
|
||||
});
|
||||
} catch (RejectedExecutionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Log4jHandlerImpl extends DefaultHandler {
|
||||
|
Loading…
x
Reference in New Issue
Block a user