Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Impala Jdbc URL (including schema without properties) parsing exception #644

Merged
merged 4 commits into from
Nov 2, 2023

Conversation

CzyerChen
Copy link
Contributor

Fix Impala Jdbc URL (including schema without properties) parsing exception

  • Add a unit test to verify that the fix works.

  • Explain briefly why the bug exists and how to fix it.
    When set up Impala jdbc url like jdbc:impala://localhost:21050/test without properties behind, it may cause exception java.lang.NumberFormatException: For input string: "21050/test". To avoid conversion exceptions, optimized the positioning of URL params.

  • Update the CHANGES log.

@wu-sheng wu-sheng added this to the 9.1.0 milestone Nov 2, 2023
@wu-sheng wu-sheng added bug Something isn't working plugin labels Nov 2, 2023
@@ -99,7 +102,7 @@ public ConnectionInfo parse() {
} else {
String[] hostAndPort = hostSegment[0].split(":");
if (hostAndPort.length != 1) {
return new ConnectionInfo(component, DB_TYPE, hostAndPort[0], Integer.valueOf(hostAndPort[1]), fetchDatabaseNameFromURL(location
return new ConnectionInfo(component, DB_TYPE, hostAndPort[0], Integer.parseInt(hostAndPort[1]), fetchDatabaseNameFromURL(location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why change this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ConnectionInfo's param port need type int not Integer, whether Integer.parseInt is better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My question is why do you use parseInt insteads of valueOf.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the ConnectionInfo's port need type int, so Integer.parseInt is enough, and Integer.valueOf(Integer.valueOf(parseInt()) here return Integer may be unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert Integer .valueOf changes, and fix impala url parse exception only first.

@wu-sheng
Copy link
Member

wu-sheng commented Nov 2, 2023

CI fails as you don't follow the code style

Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.2.1:check (validate) on project apm-jdbc-commons: You have 2 Checkstyle violations. -> [Help 1]

The code style file is in the root, and you should run maven verify on your local side.

@CzyerChen
Copy link
Contributor Author

maven-checkstyle-plugin:3.2.1:check (validate)

Got it!

@wu-sheng wu-sheng merged commit 2721438 into apache:main Nov 2, 2023
181 checks passed
@CzyerChen CzyerChen deleted the bugfix/jdbc_impala branch May 11, 2024 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants