On Sat, Jan 10, 2009 at 9:17 AM, Matthew Toseland
<[email protected]> wrote:
> On Monday 22 December 2008 10:17, [email protected] wrote:
>> Author: j16sdiz
>> Date: 2008-12-22 10:17:00 +0000 (Mon, 22 Dec 2008)
>> New Revision: 24728
>>
>> Modified:
>>    trunk/freenet/src/freenet/pluginmanager/PluginInfoWrapper.java
>>    trunk/freenet/src/freenet/support/JarClassLoader.java
>> Log:
>> force close the jar file when plugin unload
>
> Is it safe to close it when the only reason we want to close it is it's not
> unloading properly?

It may cause throwing classnotfoundexception (when you try to load a
_new_ class),
or filenotfound exception (if you want to load a resource, e.g. l10n file).

since the plugin is stopped, loading a new class should be rare.
filenotfoundexception on load resource should be handled already.

I agree this is ugly, but until we can cancel a request immediately,
this is the best we can do for windows.


>>
>> Modified: trunk/freenet/src/freenet/pluginmanager/PluginInfoWrapper.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/pluginmanager/PluginInfoWrapper.java
> 2008-12-22 09:52:06 UTC (rev 24727)
>> +++ trunk/freenet/src/freenet/pluginmanager/PluginInfoWrapper.java
> 2008-12-22 10:17:00 UTC (rev 24728)
>> @@ -4,7 +4,9 @@
>>  import java.util.HashSet;
>>
>>  import freenet.l10n.L10n;
>> +import freenet.support.JarClassLoader;
>>  import freenet.support.Logger;
>> +import freenet.support.io.Closer;
>>
>>  public class PluginInfoWrapper {
>>
>> @@ -130,6 +132,13 @@
>>                               }
>>                       }
>>               }
>> +
>> +             // Close the jar file, so we may delete / reload it
>> +             ClassLoader cl = plug.getClass().getClassLoader();
>> +             if (cl instanceof JarClassLoader) {
>> +                     Closer.close((JarClassLoader) cl);
>> +             }
>> +
>>               // always remove plugin
>>               manager.removePlugin(this);
>>       }
>>
>> Modified: trunk/freenet/src/freenet/support/JarClassLoader.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/support/JarClassLoader.java     2008-12-22
> 09:52:06 UTC (rev 24727)
>> +++ trunk/freenet/src/freenet/support/JarClassLoader.java     2008-12-22
> 10:17:00 UTC (rev 24728)
>> @@ -19,6 +19,7 @@
>>  package freenet.support;
>>
>>  import java.io.ByteArrayOutputStream;
>> +import java.io.Closeable;
>>  import java.io.File;
>>  import java.io.FileOutputStream;
>>  import java.io.IOException;
>> @@ -38,7 +39,7 @@
>>   * @author <a href="mailto:[email protected]";>David Roden</a>
>>   * @version $Id$
>>   */
>> -public class JarClassLoader extends ClassLoader {
>> +public class JarClassLoader extends ClassLoader implements Closeable {
>>
>>       /** The temporary jar file. */
>>       private JarFile tempJarFile;
>> @@ -166,4 +167,7 @@
>>               return name.replace('.', '/') + ".class";
>>       }
>>
>> +     public void close() throws IOException {
>> +             tempJarFile.close();
>> +     }
>>  }
>
> _______________________________________________
> Devl mailing list
> [email protected]
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>
_______________________________________________
Devl mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to