/** {@inheritDoc} */ public URL getResource(String path) throws java.net.MalformedURLException { if (servletContext == null) { return super.getResource(path); } if (path == null || !path.startsWith("/")) { throw new MalformedURLException("path must start with a '/'"); } return servletContext.getResource(path); }
@Override public URL getResource(String path) throws MalformedURLException { URL resource = super.getResource(path); if (resource == null && "/".equals(path)) { // Liquibase assumes that "/" always exists, if we don't have a directory // use a temporary location. try { if (this.emptyRootFolder == null) { synchronized (this) { File tempFolder = File.createTempFile("spr", "servlet"); tempFolder.delete(); tempFolder.mkdirs(); tempFolder.deleteOnExit(); this.emptyRootFolder = tempFolder; } } return this.emptyRootFolder.toURI().toURL(); } catch (IOException ex) { // Ignore } } return resource; }