diff --git a/core/src/main/java/com/alibaba/druid/util/MySqlUtils.java b/core/src/main/java/com/alibaba/druid/util/MySqlUtils.java index 52724363b7..26bb6f0a33 100644 --- a/core/src/main/java/com/alibaba/druid/util/MySqlUtils.java +++ b/core/src/main/java/com/alibaba/druid/util/MySqlUtils.java @@ -1417,7 +1417,7 @@ public static java.util.Date parseDate(String str, TimeZone timeZone) { public static long parseMillis(byte[] str, TimeZone timeZone) { if (str == null) { - throw new IllegalArgumentException(new String(str, UTF8)); + throw new IllegalArgumentException("str not be null"); } return parseMillis(str, 0, str.length, timeZone); @@ -1435,7 +1435,7 @@ public static long parseMillis(final byte[] str, final int off, final int len, f public static ZonedDateTime parseDateTime(final byte[] str, final int off, final int len, ZoneId zoneId) { if (str == null) { - throw new IllegalArgumentException(new String(str, UTF8)); + throw new IllegalArgumentException("str not be null"); } if (len < 8) { diff --git a/core/src/test/java/com/alibaba/druid/util/MySqlUtilsTest.java b/core/src/test/java/com/alibaba/druid/util/MySqlUtilsTest.java new file mode 100644 index 0000000000..ac009dc508 --- /dev/null +++ b/core/src/test/java/com/alibaba/druid/util/MySqlUtilsTest.java @@ -0,0 +1,24 @@ +package com.alibaba.druid.util; + +import junit.framework.TestCase; +import org.junit.Assert; + +import java.time.ZoneId; +import java.util.TimeZone; + +/** + * @author: ruansheng + * @date: 2024-01-22 + */ +public class MySqlUtilsTest extends TestCase { + + public void testParseMillis() { + Assert.assertThrows(IllegalArgumentException.class, + () -> MySqlUtils.parseMillis(null, TimeZone.getTimeZone("GMT+8"))); + } + + public void testParseDateTime() { + Assert.assertThrows(IllegalArgumentException.class, + () -> MySqlUtils.parseDateTime(null, 0, 0, ZoneId.systemDefault())); + } +} \ No newline at end of file