BoardiesITSolutions / Android-MySQL-Connector

Native MySQL Connector for Android
MIT License
51 stars 15 forks source link

Issue parsing welcome packet for MySQL Servers that contain text in version #2

Closed boardy closed 6 years ago

boardy commented 6 years ago

Describe the bug Some MySQL versions have text in the version number. When the connector parses the version number it causes an exception as the number parsing fails with a NumberFormatException

To Reproduce Steps to reproduce the behavior: Connect to a database where the version number also contains text. E.g. 5.7.22-log

Expected behavior Version should be parsed, any non numeric character (except for dots (.) should be removed.

Logcat

06-18 10:27:19.835 13257-13298/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: com.BoardiesITSolutions.MysqlManager, PID: 13257
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:353)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NumberFormatException: For input string: "22-log"
        at java.lang.Integer.parseInt(Integer.java:608)
        at java.lang.Integer.parseInt(Integer.java:643)
        at com.BoardiesITSolutions.AndroidMySQLConnector.Connection.parseVersionNumber(Connection.java:799)
        at com.BoardiesITSolutions.AndroidMySQLConnector.Connection.processWelcomePacket(Connection.java:321)
        at com.BoardiesITSolutions.AndroidMySQLConnector.Connection.access$000(Connection.java:37)
        at com.BoardiesITSolutions.AndroidMySQLConnector.Connection$1.socketDataSent(Connection.java:283)
        at com.BoardiesITSolutions.AndroidMySQLConnector.SocketSender.doInBackground(SocketSender.java:53)
        at com.BoardiesITSolutions.AndroidMySQLConnector.SocketSender.doInBackground(SocketSender.java:11)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
        at java.lang.Thread.run(Thread.java:764) 

Desktop (please complete the following information):

boardy commented 6 years ago

This has been fixed in version 0.23