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