You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2016/07/14 19:21:27 UTC
[Bug 59859] New: Tomcat WebDAV MOVE operation fails on Windows
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
Bug ID: 59859
Summary: Tomcat WebDAV MOVE operation fails on Windows
Product: Tomcat 8
Version: 8.0.36
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Catalina
Assignee: dev@tomcat.apache.org
Reporter: csutherl@redhat.com
Created attachment 34040
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34040&action=edit
reproducer app
The WebDAV MOVE operation doesn't seem to work in tomcat8 or tomcat8.5 (it
works fine in tomcat7) on Windows. Here are some reproduction steps and a
reproducer to show the behavior. Note that this only occurs on Windows; I also
tested on Linux and it works fine there, so I think something is wrong at the
OS/java level here.
Reproduction steps:
1) Install tomcat 8 on Windows
2) Add the webdav role and a user with that role to your conf/tomcat-users.xml
3) Deploy the attached webdav test application (webdavapp.war)
4) Start tomcat and make the following MOVE request:
curl -i -X MOVE --header "Destination:
http://localhost:8080/webdavapp/webdav/hello2.txt" --user "tomcat:tomcat"
http://localhost:8080/webdavapp/webdav/hello.txt
5) Observe the 500 response
Actual Results:
HTTP/1.1 500 Internal Server Error
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Wed, 31 Dec 1969 16:00:00 PST
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 1040
Date: Thu, 14 Jul 2016 22:35:32 GMT
Connection: close
Expected Results (as seen on Linux):
HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Cache-Control: private
Expires: Wed, 31 Dec 1969 19:00:00 EST
Content-Length: 0
Date: Thu, 14 Jul 2016 18:42:30 GMT
Additional Information:
I did spend some time tracing this in jdb and found that the MOVE is partially
working...it successfully copies the resource to the destination and but it is
failing to delete the old resource. I think I tracked the failure down to the
following block within o.a.c.servlets.WebdavServlet.doMove():
1745 if(!resource.isDirectory()) {
1746 if(!resource.delete()) {
1747
resp.sendError(WebdavStatus.SC_INTERNAL_SERVER_ERROR);
1748 return false;
The problem occurs in the (o.a.c.webresources.CachedResource) resource.delete()
call; it returns false and doesn't delete the resource for some reason (no
exception is thrown, but the errorState flag is set to 1 on the response).
Furthermore, if you make the same exact call again it will successfully delete
the previously copied destination, copy the original to the destination again,
and then fail to delete the original throwing the 500. I can't understand why
the resource.delete() can fail because it passes through to what ends up being
a o.a.c.webresources.FileResource.delete(). I compared the successful
deletion's FileResource instance to the unsuccessful deletion and the instances
match almost exactly (path's differ which is expected). I'm not sure what could
be at play here unless its at the JVM level.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #10 from Coty Sutherland <cs...@redhat.com> ---
Good idea! I don't know why I didn't do that given that the FileResource class
uses try-with-resources for it's FIS usage. I like your patch change much
better :)
Thanks!!
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #4 from Coty Sutherland <cs...@redhat.com> ---
> Just to be sure: you tested the same setup (including the exact same
> DAV-mounted directory structure) on both Tomcat 7 and Tomcat 8 and only
> Tomcat 8 fails? So, no file-permissions issues or anything like that?
Correct. I downloaded both versions, unzipped them in the same folder, made the
same configuration changes to add the role/user, deployed the same application,
and made the exact same request from my hypervisor to both (I started and
stopped each in between, they weren't running at the same time).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
Felix Schumacher <fe...@internetallee.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #34077|0 |1
is obsolete| |
--- Comment #8 from Felix Schumacher <fe...@internetallee.de> ---
Created attachment 34078
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34078&action=edit
Use try-with and don't throw IOException while closing InputStream
Close InputStream, but don't throw IOException when close() fails. Log the
exception (that hopefully never gets thrown).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #9 from Felix Schumacher <fe...@internetallee.de> ---
This issue is #89595 in coverity :)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #7 from Coty Sutherland <cs...@redhat.com> ---
Created attachment 34077
--> https://bz.apache.org/bugzilla/attachment.cgi?id=34077&action=edit
FIS.close() patch
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
Felix Schumacher <fe...@internetallee.de> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #12 from Felix Schumacher <fe...@internetallee.de> ---
Fixed in trunk, 8.5.x and 8.0.x. Should be released with 8.0.37, 8.5.5 and
9.0.0.M10.
Thanks for the work and the initial patch.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
Michael Osipov <19...@gmx.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
OS| |All
--- Comment #1 from Michael Osipov <19...@gmx.net> ---
Windows file locking?
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #6 from Coty Sutherland <cs...@redhat.com> ---
OK, after a lot of poking around I think I found a solution :D
I figured out that the problem was with a FileInputStream. Tomcat7 doesn't use
FIS' in the webresources package, but tomcat8+ does. I determined this by
noticing that that the file handle was hanging around (via lsof) after the MOVE
call is made. Then I took a look at a heap dump taken after the issue (before a
GC removed the reference) and found the FIS object in a Finalizer. After that,
I started in the move method and stepped through the method with jdb while
periodically running lsof to see when the handle was created. This led me to
java/org/apache/catalina/servlets/WebdavServlet.java:1679 where a FIS was being
retrieved from the resource, but not closed. My patch drops the FIS into a
variable and then adds a close call after the write method is invoked to remove
the handle. I don't think the write method should close the FIS since the FIS
din't originate within the write method, which is why I put the close after the
write returned.
I verified that this doesn't leave a handle open on linux and that the move
operation from my reproduction steps works on both linux and windows after the
patch is applied.
Please review and provide feedback.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #11 from Coty Sutherland <cs...@redhat.com> ---
By the way, I tested the amended patch and it looks to resolve the issue as
expected.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #5 from Coty Sutherland <cs...@redhat.com> ---
I updated the o.a.c.webresources.FileResource class and replaced the
resource.delete() (because File.delete() throws no exceptions when it fails)
with the following block:
110 try {
111 Path p = resource.toPath();
112 Files.delete(p);
113 return true;
114 } catch (Exception e) {
115 log.error("There was an exception! " + e.getMessage());
116 return false;
117 }
Trying my test with this in place yields an the following message in the
catalina.log:
org.apache.catalina.webresources.FileResource.delete There was an exception!
C:\apache-tomcat-8.0.36\webapps\webdavapp\hello.txt: The process cannot access
the file because it is being used by another process.
The process owning the file handle is the java process that tomcat is running
in. It looks like tomcat doesn't grab the file handle until the request is
made, but then never releases the handle whereas tomcat7 does (or never gets
it).
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #2 from Coty Sutherland <cs...@redhat.com> ---
> Windows file locking?
I'm no Windows expert, but I don't see how the issue could be file locking
because it works in tomcat7 on the same machine with the same
configuration/test application. I tested tomcat7 right before I tested tomcat8.
Additionally, I tested this with java 1.7.0u80 and 1.8.0u92 (both are the
latest from jdk releases from Oracle) and the issue remains.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 59859] Tomcat WebDAV MOVE operation fails on Windows
Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59859
--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
(In reply to Coty Sutherland from comment #2)
> > Windows file locking?
>
> I'm no Windows expert, but I don't see how the issue could be file locking
> because it works in tomcat7 on the same machine with the same
> configuration/test application. I tested tomcat7 right before I tested
> tomcat8.
>
> Additionally, I tested this with java 1.7.0u80 and 1.8.0u92 (both are the
> latest from jdk releases from Oracle) and the issue remains.
Just to be sure: you tested the same setup (including the exact same
DAV-mounted directory structure) on both Tomcat 7 and Tomcat 8 and only Tomcat
8 fails? So, no file-permissions issues or anything like that?
The Resources implementation has been changed quite a bit between Tomcat 7 ->
8, so it's almost certainly a bug buried in there.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org