Skip to content

Commit c2270cc

Browse files
committed
let's not abuse Objects.toString to handle null
1 parent a4c5a99 commit c2270cc

File tree

1 file changed

+7
-4
lines changed
  • hibernate-core/src/main/java/org/hibernate/dialect

1 file changed

+7
-4
lines changed

hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
import org.hibernate.exception.spi.SQLExceptionConverter;
8282
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
8383
import org.hibernate.internal.CoreMessageLogger;
84-
import org.hibernate.internal.util.StringHelper;
8584
import org.hibernate.internal.util.collections.ArrayHelper;
8685
import org.hibernate.loader.ast.spi.MultiKeyLoadSizingStrategy;
8786
import org.hibernate.mapping.CheckConstraint;
@@ -228,6 +227,7 @@
228227
import static org.hibernate.internal.util.MathHelper.ceilingPowerOfTwo;
229228
import static org.hibernate.internal.util.StringHelper.isBlank;
230229
import static org.hibernate.internal.util.StringHelper.isEmpty;
230+
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
231231
import static org.hibernate.internal.util.StringHelper.splitAtCommas;
232232
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_STRING_ARRAY;
233233
import static org.hibernate.sql.ast.internal.NonLockingClauseStrategy.NON_CLAUSE_STRATEGY;
@@ -5222,9 +5222,12 @@ public static String addUseIndexQueryHint(String query, String hints) {
52225222
if ( matcher.matches() && matcher.groupCount() > 1 ) {
52235223
final String startToken = matcher.group(1);
52245224
// Null if there is no join in the query
5225-
final String joinToken = Objects.toString( matcher.group(2), "" );
5225+
final String joinToken = matcher.group(2);
52265226
final String endToken = matcher.group(3);
5227-
return startToken + " use index (" + hints + ") " + joinToken + endToken;
5227+
return startToken
5228+
+ " use index (" + hints + ") "
5229+
+ ( joinToken == null ? "" : joinToken )
5230+
+ endToken;
52285231
}
52295232
else {
52305233
return query;
@@ -5242,7 +5245,7 @@ protected String prependComment(String sql, String comment) {
52425245
* Perform necessary character escaping on the text of the comment.
52435246
*/
52445247
public static String escapeComment(String comment) {
5245-
if ( StringHelper.isNotEmpty( comment ) ) {
5248+
if ( isNotEmpty( comment ) ) {
52465249
final String escaped = ESCAPE_CLOSING_COMMENT_PATTERN.matcher( comment ).replaceAll( "*\\\\/" );
52475250
return ESCAPE_OPENING_COMMENT_PATTERN.matcher( escaped ).replaceAll( "/\\\\*" );
52485251
}

0 commit comments

Comments
 (0)