You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2009/09/11 13:25:55 UTC
DO NOT REPLY [Bug 47821] New: Touch task doesn't work on Solaris for
a file which you do not own
https://issues.apache.org/bugzilla/show_bug.cgi?id=47821
Summary: Touch task doesn't work on Solaris for a file which
you do not own
Product: Ant
Version: unspecified
Platform: PC
OS/Version: Solaris
Status: NEW
Severity: normal
Priority: P2
Component: Core tasks
AssignedTo: notifications@ant.apache.org
ReportedBy: johan_corveleyn@hotmail.com
--- Comment #0 from Johan Corveleyn <jo...@hotmail.com> 2009-09-11 04:25:53 PDT ---
>From "man touch" on Solaris 10:
A user with write access to a file, but who is not the owner
of the file or a super-user, can change the modification and
access times of that file only to the current time. Attempts
to set a specific time with touch will result in an error.
I.e., if you don't own a file, following works in Solaris:
$ touch thefile # sets current time -> ok
But the following doesn't:
$ touch -t 200909111155 thefile # sets a given time -> not ok
So, I'd expect ant's touch task, without datetime argument, to also work in
this case. However it doesn't. Also, it doesn't signal an error about the
failure to set the modification time.
Looking into the source code, I found that ultimately, the touch task (without
datetime argument) calls thefile.setLastModified(System.currentTimeMillis()).
This is probably equivalent to calling touch with a given datetime argument
(namely the current time), which doesn't work.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47821] Touch task doesn't work on Solaris for a
file which you do not own
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47821
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
--- Comment #1 from Stefan Bodewig <bo...@apache.org> 2009-09-14 03:05:45 PDT ---
As you've found yourself, Ant is using the Java API and not the native Unix
touch command. Inside the Java API there is no alternative to
File.setLoastModified(long).
Honestly I have no idea how that method is implemented inside the Java class
library. It may be smart enough to recognize the current timestamp and then
invoke a different system call than it uses when asked for a different
timestamp, but I doubt it.
Anyway, if the Java class lib isn't doing the "correct" thing for you here,
there isn't anything we can do from the Ant side.
I'd recommend you use the exec task and explicitly invoke the touch command for
your case.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47821] Touch task doesn't work on Solaris for a
file which you do not own
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47821
--- Comment #3 from Stefan Bodewig <bo...@apache.org> 2010-06-24 03:41:20 EDT ---
starting with svn revision 957442 Ant logs a warning message.
I'll add a few words to the manual page.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47821] Touch task doesn't work on Solaris for a
file which you do not own
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47821
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Component|Core tasks |Documentation
Resolution| |FIXED
Target Milestone|--- |1.8.2
--- Comment #4 from Stefan Bodewig <bo...@apache.org> 2010-06-24 03:54:38 EDT ---
I've documented the limitations with svn revision 957444
I've opted for a warning rather than an exception since I was too afraid of
breaking existing builds - in particular since we've hidden the
setLastModified invocation under several layers of void methods and I really
don't feel good about hunting down all callers to ensure they know how to
handle exceptions thrown from there.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47821] Touch task doesn't work on Solaris for a
file which you do not own
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47821
Johan Corveleyn <jo...@hotmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|WONTFIX |
--- Comment #2 from Johan Corveleyn <jo...@hotmail.com> 2009-09-14 04:43:18 PDT ---
I understand this is difficult to do, and cannot be done without using
platform-specific Runtime.exec code. It's a pity that the Java api doesn't
offer you a way to do this.
But isn't there a way you could do the following, in the touch task, when no
datetime argument is given?
* Try setLastModified(System.currentTimeMillis())
* If that fails (i.e. returns false), and the platform is unix, try a
Runtime.exec of touch?
At the very least, touch should raise an error when it fails to set the
timestamp. File.setLastModified returns a boolean to indicate whether or not it
succeeded. This return value is currently ignored. Can you use that return
value to raise an error if needed?
Maybe this could also be documented in the manual for the touch task?
Some background: in our build environment, this issue has caused serious
problems after we switched from Linux to Solaris, and it was hard to find out
what exactly went wrong. We used the copy task to deploy a new build to a
JavaWebStart server. By default, the copy task only copies newer files, if they
already exist on the target location. Because the touch failed, sometimes old
files (which needed to be redeployed) were not copied. It took us quite some
time to figure out why it failed, and to replace all touch tasks with <exec ...
/>.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
DO NOT REPLY [Bug 47821] Touch task doesn't work on Solaris for a
file which you do not own
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=47821
Maarten Coene <ma...@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maarten_coene@yahoo.com
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.