Skip to content

Commit e40ea87

Browse files
vlyubinaarondav
authored andcommitted
[Minor] [SQL] [SPARK-6729] Minor fix for DriverQuirks get
The function uses .substring(0, X), which will trigger OutOfBoundsException if string length is less than X. A better way to do this is to use startsWith, which won't error out in this case. Author: Volodymyr Lyubinets <[email protected]> Closes apache#5378 from vlyubin/quirks and squashes the following commits: 504e8e0 [Volodymyr Lyubinets] Minor fix for DriverQuirks get
1 parent 30363ed commit e40ea87

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/jdbc/DriverQuirks.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ private[sql] object DriverQuirks {
4949
* Fetch the DriverQuirks class corresponding to a given database url.
5050
*/
5151
def get(url: String): DriverQuirks = {
52-
if (url.substring(0, 10).equals("jdbc:mysql")) {
52+
if (url.startsWith("jdbc:mysql")) {
5353
new MySQLQuirks()
54-
} else if (url.substring(0, 15).equals("jdbc:postgresql")) {
54+
} else if (url.startsWith("jdbc:postgresql")) {
5555
new PostgresQuirks()
5656
} else {
5757
new NoQuirks()

0 commit comments

Comments
 (0)