tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: Disable class monitoring for reloading container classes
Date Sat, 09 Oct 2010 14:18:31 GMT
Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
>> Subject: Re: Disable class monitoring for reloading container classes
> 
>> The timestamp of the file should be /the/ timestamp for the 
>> file, and shouldn't be affected by the current DST settings.
>> The timestamp for the file itself might be affected by the
>> current DST setting when you /touch/ it, but not when you do
>> a simple stat() call.
> 
> My guess is that the problem is specific to the platform: either the JVM or the OS is
adjusting the retrieved time stamp, making it relative to the current offset from UTC.  Even
though this particular OS is not widely used as a Java EE platform (compared to the number
of Linux and Windows boxes out there), I'm a bit surprised the issue hasn't been reported
elsewhere.
> 
> Try using simple Java and C programs to check the File.lastModified() and stat() st_mtime
values respectively, comparing the results both before and after the DST switch.  That should
determine if the problem is in the OS, the JVM, or Tomcat.
> 

Jane,

Below is a simple perl program that will show the "last modified" time of a file, in 3 
flavors :
- the original timestamp as a binary value (number of non-leap seconds since the "epoch",

on most systems this is 00:00:00 UTC, January 1, 1970).
- the same timestamp as GMT date/time (this is Greenwich time, non DST-adjusted)
- the same time stamp as "local" time (DST-adjusted)

Copy and paste this into a text file, save it as "showmodified.pl", then type

perl showmodified.pl <file_path>

What would be interesting would be to run the program on your two different servers, to 
see if they answer differently.
This does not use the Java JVM in any way.  It uses perl, which itself uses mostly the 
built-in C library of the OS.
So it will tell you what the OS responds for the file timestamps.
Someone here might be able to provide a quick Java equivalent, to see if the JVM thinks 
differently on the same system.

Note : I also send the program as an attachment.  The list will probably strip it, so I 
emailed a copy to you directly.


#!/usr/bin/perl
# showmodified.pl
use warnings;
use strict;
my ($sec,$min,$hour,$mday,$mon,$year);
my $subject = $ARGV[0] or die "missing argument";
die "File not found or not readable : $!" unless ((-f $subject) && (-r $subject));

my $now = time();
($sec,$min,$hour,$mday,$mon,$year) = gmtime($now);
$year +=1900; $mon +=1;
print "Current GMT time (no DST) : 
",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year,$mon,$mday,$hour,$min,$sec),"\n";

($sec,$min,$hour,$mday,$mon,$year) = localtime($now);
$year +=1900; $mon +=1;
print "Current local time (with DST) : 
",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year,$mon,$mday,$hour,$min,$sec),"\n";

print "File [$subject]:\n";

my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks)
            = stat($subject);
print "last modified timestamp : $mtime\n";
print "the file was last modified ",$now-$mtime," seconds ago\n";

($sec,$min,$hour,$mday,$mon,$year) = gmtime($mtime);
$year +=1900; $mon +=1;
print "last modified as GMT time (no DST) : 
",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year,$mon,$mday,$hour,$min,$sec),"\n";

($sec,$min,$hour,$mday,$mon,$year) = localtime($mtime);
$year +=1900; $mon +=1;
print "last modified as local time (with DST) : 
",sprintf("%04d/%02d/%02d-%02d:%02d:%02d",$year,$mon,$mday,$hour,$min,$sec),"\n";

exit;

Mime
View raw message