This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-commons-fsclassloader.git
commit 8ae9364c296c0ff03264675a14bce08ac0176890 Author: Carsten Ziegeler <[email protected]> AuthorDate: Tue Jun 16 07:18:48 2015 +0000 SLING-4809 : Filesystem classwriter does not delete directories git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1685721 13f79535-47bb-0310-9956-ffa450edef68 --- .../fsclassloader/impl/FSClassLoaderProvider.java | 42 ++++++++++++++++------ 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java b/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java index 74d2a2f..ee6b6bc 100644 --- a/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java +++ b/src/main/java/org/apache/sling/commons/fsclassloader/impl/FSClassLoaderProvider.java @@ -27,6 +27,8 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; @@ -152,20 +154,35 @@ public class FSClassLoaderProvider } private void checkClassLoader(final String filePath) { - synchronized ( this ) { - final FSDynamicClassLoader currentLoader = this.loader; - if ( currentLoader != null && filePath.endsWith(".class") ) { - // remove store directory and .class - final String path = filePath.substring(this.root.getAbsolutePath().length() + 1, filePath.length() - 6); - // convert to a class name - final String className = path.replace(File.separatorChar, '.'); - currentLoader.check(className); + if ( filePath.endsWith(".class") ) { + // remove store directory and .class + final String path = filePath.substring(this.root.getAbsolutePath().length() + 1, filePath.length() - 6); + // convert to a class name + final String className = path.replace(File.separatorChar, '.'); + + synchronized ( this ) { + final FSDynamicClassLoader currentLoader = this.loader; + if ( currentLoader != null ) { + currentLoader.check(className); + } } } } //---------- SCR Integration ---------------------------------------------- + private boolean deleteRecursive(final File f, final List<String> names) { + if ( f.isDirectory() ) { + for(final File c : f.listFiles()) { + if ( !deleteRecursive(c, names) ) { + return false; + } + } + } + names.add(f.getAbsolutePath()); + return f.delete(); + } + /** * @see org.apache.sling.commons.classloader.ClassLoaderWriter#delete(java.lang.String) */ @@ -173,10 +190,13 @@ public class FSClassLoaderProvider final String path = cleanPath(name); final File file = new File(path); if ( file.exists() ) { - final boolean result = file.delete(); - logger.debug("Deleted {} : {}", name,result); + final List<String> names = new ArrayList<String>(); + final boolean result = deleteRecursive(file, names); + logger.debug("Deleted {} : {}", name, result); if ( result ) { - this.checkClassLoader(file.getAbsolutePath()); + for(final String n : names ) { + this.checkClassLoader(n); + } } return result; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
