Author: nextgens
Date: 2007-02-25 13:08:42 +0000 (Sun, 25 Feb 2007)
New Revision: 11912
Modified:
trunk/freenet/src/freenet/client/async/USKManager.java
trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
Log:
Add the same thing for backgroundFetchers, log an error if something tries to
unsubscribe from an USK more than once.
Modified: trunk/freenet/src/freenet/client/async/USKManager.java
===================================================================
--- trunk/freenet/src/freenet/client/async/USKManager.java 2007-02-24
21:24:35 UTC (rev 11911)
+++ trunk/freenet/src/freenet/client/async/USKManager.java 2007-02-25
13:08:42 UTC (rev 11912)
@@ -182,6 +182,13 @@
synchronized(this) {
USK clear = origUSK.clearCopy();
USKCallback[] callbacks = (USKCallback[])
subscribersByClearUSK.get(clear);
+ if(callbacks == null){ // maybe we should throw
something ? shall we allow multiple unsubscriptions ?
+ if(Logger.shouldLog(Logger.MINOR, this)){
+ Logger.error(this, "The callback is
null! it has been already unsubscribed, hasn't it?");
+ new NullPointerException("The callback
is null! it has been already unsubscribed, hasn't it?").printStackTrace();
+ }
+ return;
+ }
int j=0;
for(int i=0;i<callbacks.length;i++) {
USKCallback c = callbacks[i];
@@ -239,4 +246,13 @@
public int getFetcherByUSKSize(){
return fetchersByUSK.size();
}
+
+ /**
+ * The result of that method will be displayed on the Statistic Toadlet
: it will help catching #1147
+ * Afterwards it should be removed: it's not usefull :)
+ * @return the number of BackgroundFetchers started by USKManager
+ */
+ public int getBackgroundFetcherByUSKSize(){
+ return backgroundFetchersByClearUSK.size();
+ }
}
Modified: trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2007-02-24 21:24:35 UTC (rev 11911)
+++ trunk/freenet/src/freenet/clients/http/StatisticsToadlet.java
2007-02-25 13:08:42 UTC (rev 11912)
@@ -227,6 +227,7 @@
if (numARKFetchers > 0)
activityList.addChild("li",
"ARK\u00a0Fetch\u00a0Requests:\u00a0" + numARKFetchers);
activityList.addChild("li",
"FetcherByUSKSize:\u00a0" + node.clientCore.uskManager.getFetcherByUSKSize());
+ activityList.addChild("li",
"BackgroundFetcherByUSKSize:\u00a0" +
node.clientCore.uskManager.getBackgroundFetcherByUSKSize());
}
}