unwrap cause from internal exception and prevent from breaking thread (ref #629)

This commit is contained in:
galimru 2020-01-28 12:59:27 +04:00
parent 55e27c1167
commit 1b18b1ccdb

View File

@ -26,6 +26,7 @@ import org.telegram.telegrambots.meta.generics.UpdatesReader;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.lang.reflect.InvocationTargetException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.nio.charset.StandardCharsets;
@ -277,12 +278,12 @@ public class DefaultBotSession implements BotSession {
} catch (InternalError e) {
// handle InternalError to workaround OpenJDK bug (resolved since 13.0)
// https://bugs.openjdk.java.net/browse/JDK-8173620
Throwable cause = e.getCause();
if (cause instanceof IOException) {
log.error(e.getLocalizedMessage(), e);
}
throw e;
if (e.getCause() instanceof InvocationTargetException) {
Throwable cause = e.getCause().getCause();
log.error(cause.getLocalizedMessage(), cause);
} else throw e;
}
return Collections.emptyList();
}
}