mysql-binlog-connector-java
mysql-binlog-connector-java copied to clipboard
Notify about user without 'REPLICATION SLAVE' privilege
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 right. (re)Throwing exception if no lifecycleListeners are registered might be an option. Thanks!