Skip to content

Commit 1df68f0

Browse files
yrodierembellade
authored andcommitted
HHH-19848 Avoid NPE in MySQLLegacyDialect
1 parent 7c27d09 commit 1df68f0

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MySQLLegacyDialect.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,18 @@ public MySQLLegacyDialect(DialectResolutionInfo info) {
191191

192192
protected static DatabaseVersion createVersion(DialectResolutionInfo info) {
193193
final String versionString = info.getDatabaseVersion();
194-
final String[] components = StringHelper.split( ".", versionString );
195-
if ( components.length >= 3 ) {
196-
try {
197-
final int majorVersion = Integer.parseInt( components[0] );
198-
final int minorVersion = Integer.parseInt( components[1] );
199-
final int patchLevel = Integer.parseInt( components[2] );
200-
return DatabaseVersion.make( majorVersion, minorVersion, patchLevel );
201-
}
202-
catch (NumberFormatException ex) {
203-
// Ignore
194+
if ( versionString != null ) {
195+
final String[] components = StringHelper.split( ".", versionString );
196+
if ( components.length >= 3 ) {
197+
try {
198+
final int majorVersion = Integer.parseInt( components[0] );
199+
final int minorVersion = Integer.parseInt( components[1] );
200+
final int patchLevel = Integer.parseInt( components[2] );
201+
return DatabaseVersion.make( majorVersion, minorVersion, patchLevel );
202+
}
203+
catch (NumberFormatException ex) {
204+
// Ignore
205+
}
204206
}
205207
}
206208
return info.makeCopyOrDefault( DEFAULT_VERSION );

0 commit comments

Comments
 (0)