From c8a521fddac9d42fe93ea9b3ab89e804bc48bf4e Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Tue, 25 Feb 2025 23:03:18 +0000 Subject: [PATCH] 8345213: JVM Prefers /etc/timezone Over /etc/localtime on Debian 12 Reviewed-by: joehw, jpai, alanb --- .../unix/native/libjava/TimeZone_md.c | 32 ++----------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/src/java.base/unix/native/libjava/TimeZone_md.c b/src/java.base/unix/native/libjava/TimeZone_md.c index bc55f099bd9..cd253edde60 100644 --- a/src/java.base/unix/native/libjava/TimeZone_md.c +++ b/src/java.base/unix/native/libjava/TimeZone_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,6 @@ #define fileclose fclose #if defined(__linux__) || defined(_ALLBSD_SOURCE) -static const char *ETC_TIMEZONE_FILE = "/etc/timezone"; static const char *ZONEINFO_DIR = "/usr/share/zoneinfo"; static const char *DEFAULT_ZONEINFO_FILE = "/etc/localtime"; #else @@ -248,40 +247,13 @@ getPlatformTimeZoneID() { struct stat statbuf; char *tz = NULL; - FILE *fp; int fd; char *buf; size_t size; int res; -#if defined(__linux__) /* - * Try reading the /etc/timezone file for Debian distros. There's - * no spec of the file format available. This parsing assumes that - * there's one line of an Olson tzid followed by a '\n', no - * leading or trailing spaces, no comments. - */ - if ((fp = fopen(ETC_TIMEZONE_FILE, "r")) != NULL) { - char line[256]; - - if (fgets(line, sizeof(line), fp) != NULL) { - char *p = strchr(line, '\n'); - if (p != NULL) { - *p = '\0'; - } - if (strlen(line) > 0) { - tz = strdup(line); - } - } - (void) fclose(fp); - if (tz != NULL) { - return tz; - } - } -#endif /* defined(__linux__) */ - - /* - * Next, try /etc/localtime to find the zone ID. + * Try /etc/localtime to find the zone ID. */ RESTARTABLE(lstat(DEFAULT_ZONEINFO_FILE, &statbuf), res); if (res == -1) {