Skip to content

Commit 2735d22

Browse files
committed
8345213: JVM Prefers /etc/timezone Over /etc/localtime on Debian 12
Backport-of: c8a521fddac9d42fe93ea9b3ab89e804bc48bf4e
1 parent b0eeb39 commit 2735d22

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

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2023, 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
@@ -60,7 +60,6 @@ static char *isFileIdentical(char* buf, size_t size, char *pathname);
6060
#endif
6161

6262
#if defined(__linux__) || defined(_ALLBSD_SOURCE)
63-
static const char *ETC_TIMEZONE_FILE = "/etc/timezone";
6463
static const char *ZONEINFO_DIR = "/usr/share/zoneinfo";
6564
static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime";
6665
#else
@@ -239,40 +238,13 @@ getPlatformTimeZoneID()
239238
{
240239
struct stat64 statbuf;
241240
char *tz = NULL;
242-
FILE *fp;
243241
int fd;
244242
char *buf;
245243
size_t size;
246244
int res;
247245

248-
#if defined(__linux__)
249-
/*
250-
* Try reading the /etc/timezone file for Debian distros. There's
251-
* no spec of the file format available. This parsing assumes that
252-
* there's one line of an Olson tzid followed by a '\n', no
253-
* leading or trailing spaces, no comments.
254-
*/
255-
if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) {
256-
char line[256];
257-
258-
if (fgets(line, sizeof(line), fp) != NULL) {
259-
char *p = strchr(line, '\n');
260-
if (p != NULL) {
261-
*p = '\0';
262-
}
263-
if (strlen(line) > 0) {
264-
tz = strdup(line);
265-
}
266-
}
267-
(void) fclose(fp);
268-
if (tz != NULL) {
269-
return tz;
270-
}
271-
}
272-
#endif /* defined(__linux__) */
273-
274246
/*
275-
* Next, try /etc/localtime to find the zone ID.
247+
* Try /etc/localtime to find the zone ID.
276248
*/
277249
RESTARTABLE(lstat64(DEFAULT_ZONEINFO_FILE, &statbuf), res);
278250
if (res == -1) {

0 commit comments

Comments
 (0)