Silence Exceptions on closing ssl connection with mysql and spring boot

I have (spring boot) integration tests that use a test container for a (mysql)database. When the tests end (even if they are successful), I get an ssl exception (see below). I've looked around, and it seems this is an error with the mysql driver. I would like to silence these so that in the event anything fails, I can easily determine from the logs (while right now, the majority of my logs are from this misleading exception) Does anyone know how to silence these logs (I don't want to not use ssl). For your reference, the logs are printed below:

2019-12-15 12:50:52.588  INFO 16171 --- [       Thread-3] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2019-12-15 12:50:52.588  INFO 16171 --- [       Thread-3] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
Sun Dec 15 12:50:52 EST 2019 WARN: Caught while disconnecting...

EXCEPTION STACK TRACE:



** BEGIN NESTED EXCEPTION ** 

javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify

STACKTRACE:

javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133)
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:307)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:263)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:254)
at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1319)
at com.mysql.cj.NativeSession.quit(NativeSession.java:182)
at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1750)
at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
at com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:135)
at com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:441)
at        java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at     java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)


** END NESTED EXCEPTION **


Sun Dec 15 12:50:52 EST 2019 WARN: Caught while disconnecting...

EXCEPTION STACK TRACE:



** BEGIN NESTED EXCEPTION ** 

javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify
...
rest ommitted for brevity

Thanks

1 answer

  • answered 2019-12-15 19:44 Alexey

    Well, you just need to add

    logging.level.<package_name>=ERROR

    to your spring configuration properties I would first try with

    logging.level.javax.net.ssl=ERROR

    but if it doesn't work try with different packages. Problem that I see in the log is that it looks like it was done not via standard logging mechanism but to stderr. If that's the case and properties approach won't work - then you'll need to specify your own PrintStream for stderr. That can be done with

    System.setErr(new PrintStream(new OutputStream() {
                @Override
                public void write(int i) throws IOException {
                    //ignore
                }
            }));