Skip to content

Commit 75ac12b

Browse files
committed
Fix for Bug#99292 (Bug#31195955), Contribution: Support Windows time zone \'Coordinated Universal Time\'.
Change-Id: Ib7b992d0a51d30ff6a9ca9175181b5f35bd48188
1 parent 5940440 commit 75ac12b

File tree

5 files changed

+3063
-294
lines changed

5 files changed

+3063
-294
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
Version 9.5.0
55

6+
- Fix for Bug#99292 (Bug#31195955), Contribution: Support Windows time zone \'Coordinated Universal Time\'.
7+
Thanks to Frédéric Barrière for his contribution.
8+
69
- Fix for Bug#107094 (Bug#34104230), NullPointerException when calling equals with null on MultiHostConnectionProxy.
710

811
- Fix for Bug#107543 (Bug#34464351), Cannot execute a SELECT statement that writes to an OUTFILE.

src/main/core-api/java/com/mysql/cj/util/TimeUtil.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,23 @@ public static long getCurrentTimeNanosOrMillis() {
132132
/**
133133
* Returns the 'official' Java timezone name for the given timezone
134134
*
135-
* @param timezoneStr
135+
* @param timeZoneStr
136136
* the 'common' timezone name
137137
* @param exceptionInterceptor
138138
* exception interceptor
139139
*
140140
* @return the Java timezone name for the given timezone
141141
*/
142-
public static String getCanonicalTimeZone(String timezoneStr, ExceptionInterceptor exceptionInterceptor) {
143-
if (timezoneStr == null) {
142+
public static String getCanonicalTimeZone(String timeZoneStr, ExceptionInterceptor exceptionInterceptor) {
143+
if (timeZoneStr == null) {
144144
return null;
145145
}
146146

147-
timezoneStr = timezoneStr.trim();
147+
timeZoneStr = timeZoneStr.trim();
148148

149-
// handle '+/-hh:mm' form ...
150-
if (timezoneStr.length() > 2) {
151-
if ((timezoneStr.charAt(0) == '+' || timezoneStr.charAt(0) == '-') && Character.isDigit(timezoneStr.charAt(1))) {
152-
return "GMT" + timezoneStr;
153-
}
149+
// Handle '+/-hh:mm' form.
150+
if (timeZoneStr.length() > 2 && (timeZoneStr.charAt(0) == '+' || timeZoneStr.charAt(0) == '-') && Character.isDigit(timeZoneStr.charAt(1))) {
151+
return "GMT" + timeZoneStr;
154152
}
155153

156154
LOCK.lock();
@@ -162,13 +160,13 @@ public static String getCanonicalTimeZone(String timezoneStr, ExceptionIntercept
162160
LOCK.unlock();
163161
}
164162

165-
String canonicalTz;
166-
if ((canonicalTz = timeZoneMappings.getProperty(timezoneStr)) != null) {
163+
String canonicalTz = timeZoneMappings.getProperty(timeZoneStr);
164+
if (canonicalTz != null) {
167165
return canonicalTz;
168166
}
169167

170168
throw ExceptionFactory.createException(InvalidConnectionAttributeException.class,
171-
Messages.getString("TimeUtil.UnrecognizedTimeZoneId", new Object[] { timezoneStr }), exceptionInterceptor);
169+
Messages.getString("TimeUtil.UnrecognizedTimeZoneId", new Object[] { timeZoneStr }), exceptionInterceptor);
172170
}
173171

174172
/**
@@ -329,11 +327,9 @@ private static void loadTimeZoneMappings(ExceptionInterceptor exceptionIntercept
329327
} catch (IOException e) {
330328
throw ExceptionFactory.createException(Messages.getString("TimeUtil.LoadTimeZoneMappingError"), exceptionInterceptor);
331329
}
332-
// bridge all Time Zone ids known by Java
330+
// Bridge all Time Zones known by Java.
333331
for (String tz : TimeZone.getAvailableIDs()) {
334-
if (!timeZoneMappings.containsKey(tz)) {
335-
timeZoneMappings.put(tz, tz);
336-
}
332+
timeZoneMappings.put(tz, tz);
337333
}
338334
}
339335

0 commit comments

Comments
 (0)