diff options
author | Artur Signell <artur@vaadin.com> | 2012-04-05 17:10:22 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-04-05 17:10:22 +0300 |
commit | 2f395ab251b336a1ba32b01742cfc93f075184f0 (patch) | |
tree | 3fead1f4c04c39538e765faa2b51bcc5cc768d70 | |
parent | c670b2fff5ec7cfa6571960ea39e8ecc66fc1c2e (diff) | |
download | vaadin-framework-2f395ab251b336a1ba32b01742cfc93f075184f0.tar.gz vaadin-framework-2f395ab251b336a1ba32b01742cfc93f075184f0.zip |
Fixed potential problem with file descriptors remaining in use
-rw-r--r-- | src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java index 90efdf2296..9f1691112b 100644 --- a/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java +++ b/src/com/vaadin/terminal/gwt/server/AbstractApplicationServlet.java @@ -15,6 +15,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLConnection; import java.security.GeneralSecurityException; import java.util.Arrays; import java.util.Collection; @@ -34,6 +35,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import sun.net.www.protocol.file.FileURLConnection; + import com.vaadin.Application; import com.vaadin.Application.ApplicationStartEvent; import com.vaadin.Application.SystemMessages; @@ -1123,8 +1126,10 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements // Find the modification timestamp long lastModifiedTime = 0; + URLConnection connection = null; try { - lastModifiedTime = resourceUrl.openConnection().getLastModified(); + connection = resourceUrl.openConnection(); + lastModifiedTime = connection.getLastModified(); // Remove milliseconds to avoid comparison problems (milliseconds // are not returned by the browser in the "If-Modified-Since" // header). @@ -1140,6 +1145,21 @@ public abstract class AbstractApplicationServlet extends HttpServlet implements Level.FINEST, "Failed to find out last modified timestamp. Continuing without it.", e); + } finally { + if (connection instanceof FileURLConnection) { + try { + // Explicitly close the input stream to prevent it + // from remaining hanging + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257700 + InputStream is = connection.getInputStream(); + if (is != null) { + is.close(); + } + } catch (IOException e) { + logger.log(Level.INFO, + "Error closing FileURLConnection input stream", e); + } + } } // Set type mime type if we can determine it based on the filename |