Skip to content

Commit c8a521f

Browse files
committedFeb 25, 2025
8345213: JVM Prefers /etc/timezone Over /etc/localtime on Debian 12
Reviewed-by: joehw, jpai, alanb
1 parent 86024eb commit c8a521f

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed
 

‎src/java.base/unix/native/libjava/TimeZone_md.c

+2-30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,6 @@
4646
#define fileclose fclose
4747

4848
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
49-
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
5049
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
5150
static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
5251
#else
@@ -248,40 +247,13 @@ getPlatformTimeZoneID()
248247
{
249248
struct stat statbuf;
250249
char *tz = NULL;
251-
FILE *fp;
252250
int fd;
253251
char *buf;
254252
size_t size;
255253
int res;
256254

257-
#if defined(__linux__)
258-
/*
259-
* Try reading the /etc/timezone file for Debian distros. There's
260-
* no spec of the file format available. This parsing assumes that
261-
* there's one line of an Olson tzid followed by a '\n', no
262-
* leading or trailing spaces, no comments.
263-
*/
264-
if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) {
265-
char line[256];
266-
267-
if (fgets(line, sizeof(line), fp) != NULL) {
268-
char *p = strchr(line, '\n');
269-
if (p != NULL) {
270-
*p = '\0';
271-
}
272-
if (strlen(line) > 0) {
273-
tz = strdup(line);
274-
}
275-
}
276-
(void) fclose(fp);
277-
if (tz != NULL) {
278-
return tz;
279-
}
280-
}
281-
#endif /* defined(__linux__) */
282-
283255
/*
284-
* Next, try /etc/localtime to find the zone ID.
256+
* Try /etc/localtime to find the zone ID.
285257
*/
286258
RESTARTABLE(lstat(DEFAULT_ZONEINFO_FILE, &statbuf), res);
287259
if (res == -1) {

0 commit comments

Comments
 (0)
Please sign in to comment.