mysql-binlog-connector-java icon indicating copy to clipboard operation
mysql-binlog-connector-java copied to clipboard

Notify about user without 'REPLICATION SLAVE' privilege

Open JackEggie opened this issue 8 years ago • 1 comments

I was reading binlog by a mysql user without 'REPLICATION SLAVE' privilege. And I found out that no exception would be thrown, but the application stop working.

Then I debugged the code with my question: If I had not implement my LifecycleListener, how can I catch this kind of exception?

Exception initialized at BinaryLogClient:

                if (marker == 0xFF) {
                    ErrorPacket errorPacket = new ErrorPacket(inputStream.read(packetLength - 1));
                    throw new ServerException(errorPacket.getErrorMessage(), errorPacket.getErrorCode(),
                        errorPacket.getSqlState());
                }

Exception caught at BinaryLogClient, but do nothing:

            if (isConnected()) {
                synchronized (lifecycleListeners) {
                    for (LifecycleListener lifecycleListener : lifecycleListeners) {
                        lifecycleListener.onCommunicationFailure(this, e);
                    }
                }
            }

I suggest that you can inform user of this exception, so that user can do something with the privileges.

JackEggie avatar Jan 05 '18 08:01 JackEggie

@JackEggie right. (re)Throwing exception if no lifecycleListeners are registered might be an option. Thanks!

shyiko avatar Jan 09 '18 02:01 shyiko