close(jarFileConnection); closeQuietly(connection);
/** * Construct. * * @param scope The scope class to detect the resource * @param path absolute path to resource */ public LessResource(final Class<?> scope, final String path) { this.scope = scope; this.path = path; try { this.lastModified = Connections.getLastModified(Thread.currentThread().getContextClassLoader().getResource(path)); } catch (IOException e) { throw new WicketRuntimeException(e); } }
long lastModified = Connections.getLastModified(url); Connections.close(connection);
/** * Closes a connection, ignoring any exceptions if they occur * * @param connection */ public static void closeQuietly(final URLConnection connection) { try { close(connection); } catch (Exception e) { // ignore } }
Connections.closeQuietly(connection);
/** * Closes a connection, ignoring any exceptions if they occur * * @param connection */ public static void closeQuietly(URLConnection connection) { try { close(connection); } catch (Exception e) { // ignore } }
/** * Closes this resource. * * @throws IOException */ @Override public void close() throws IOException { StreamData data = getData(false); if (data != null) { Connections.closeQuietly(data.connection); if (data.inputStreams != null) { for (InputStream is : data.inputStreams) { IOUtils.closeQuietly(is); } } streamData = null; } }
@Override public Time lastModifiedTime() { try { final ServletContext context = ((WebApplication)Application.get()).getServletContext(); final URL resourceURL = context.getResource(url); if (resourceURL == null) { throw new FileNotFoundException("Unable to find resource '" + url + "' in the servlet context"); } return Connections.getLastModified(resourceURL); } catch (IOException e) { log.warn("failed to retrieve last modified timestamp", e); return null; } }
private void updateContentLength() throws IOException { StreamData data = getData(false); if (data != null) { URLConnection connection = url.openConnection(); try { data.contentLength = connection.getContentLength(); } finally { Connections.close(connection); } } }
/** * Closes this resource. * * @throws IOException */ @Override public void close() throws IOException { StreamData data = getData(false); if (data != null) { Connections.closeQuietly(data.connection); if (data.inputStreams != null) { for (InputStream is : data.inputStreams) { IOUtils.closeQuietly(is); } } streamData = null; } }
@Override public Time lastModifiedTime() { try { final ServletContext context = ((WebApplication)Application.get()).getServletContext(); final URL resourceURL = context.getResource(url); if (resourceURL == null) { throw new FileNotFoundException("Unable to find resource '" + url + "' in the servlet context"); } return Connections.getLastModified(resourceURL); } catch (IOException e) { log.warn("failed to retrieve last modified timestamp", e); return null; } }
private void updateContentLength() throws IOException { StreamData data = getData(false); if (data != null) { URLConnection connection = url.openConnection(); try { data.contentLength = connection.getContentLength(); } finally { Connections.close(connection); } } }
closeQuietly(connection);
/** * @see org.apache.wicket.util.watch.IModifiable#lastModifiedTime() * @return The last time this resource was modified */ @Override public Time lastModifiedTime() { try { // get url modification timestamp final Time time = Connections.getLastModified(url); // if timestamp changed: update content length and last modified date if (Objects.equal(time, lastModified) == false) { lastModified = time; updateContentLength(); } return lastModified; } catch (IOException e) { log.warn("getLastModified() for '{}' failed: {}", url, e.getMessage()); // allow modification watcher to detect the problem return null; } }
/** * @see org.apache.wicket.util.watch.IModifiable#lastModifiedTime() * @return The last time this resource was modified */ @Override public Time lastModifiedTime() { try { // get url modification timestamp final Time time = Connections.getLastModified(url); // if timestamp changed: update content length and last modified date if (Objects.equal(time, lastModified) == false) { lastModified = time; updateContentLength(); } return lastModified; } catch (IOException e) { log.warn("getLastModified() for '{}' failed: {}", url, e.getMessage()); // allow modification watcher to detect the problem return null; } }