[
https://issues.apache.org/jira/browse/SSHD-625?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15114987#comment-15114987
]
Eugene Petrenko commented on SSHD-625:
--------------------------------------
Thank you. This is a good idea to subscribe to the
{{setUncaughtExceptionHandler}}. I'll consider that.
Of course I understand OOM is bad, and it should not happen. I wrote about it
mostly as an example of what can go wrong. Another example is AssertionError.
This exception may appear in production. VerifyError is the other example of
what may go wrong.
On my side I had strange behaviour. So SSHD sever stopped processing requests
at all. I suppose, this was caused by a VerifyError and unhandled exceptions.
To fix that, I updated the code to include try/catch-es from my side, and I
re-wrote it a bit to avoid possible VerifyError (it looks like Java may throw
it when method-group lambda expessions are used, e.g. myFoo::bar()
My only concern is to protect the SSHD library from breaking the server once
something goes wrong. This is where catching may help to avoid unhandled
exceptions to bother NIO callbacks. (And we know Murphy's law)...
> Use catch(Throwable) where possible to avoid stopping performing queries and
> to log errors
> ------------------------------------------------------------------------------------------
>
> Key: SSHD-625
> URL: https://issues.apache.org/jira/browse/SSHD-625
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 1.0.0
> Reporter: Eugene Petrenko
> Assignee: Goldstein Lyor
> Priority: Minor
>
> There are several places in library source where you catch Exception to log
> it. Not Throwable. But it may easily turn out any some Error is thrown from
> user provided implementations.
> Here is incorrect catch: *
> org.apache.sshd.server.config.keys.AuthorizedKeysAuthenticator#authenticate
> There is no catch at all in
> * org.apache.sshd.server.auth.UserAuthKeyboardInteractive#doAuth
> * org.apache.sshd.server.channel.ChannelSession#handleRequest
> The problem is that once my code throws a Error (e.g. VerifyError or OOM) the
> error goes strait into JVM internals without being explicitly logged. As a
> side effect of that SSHD server stops functioning. Connections are accepted
> but not being processed.
> My current workaround is to explicitly wrap all classes I implement with
> try/catch. I believe it should be done inside the library to avoid everyone
> from writing similar try-catch. I believe it's OK to forcibly close any
> connection once exception was caught and logged
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)