Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
replaced non-generic array with collection
Michael Peter Christen148103782009
diff --git a/source/net/yacy/kelondro/workflow/InstantBusyThread.java b/source/net/yacy/kelondro/workflow/InstantBusyThread.javaindex bd28050f5..fe8f4b390 100644--- a/source/net/yacy/kelondro/workflow/InstantBusyThread.java+++ b/source/net/yacy/kelondro/workflow/InstantBusyThread.java@@ -56,7 +56,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyT// freemem is the name of a method that tries to free memory and returns voidfinal Class<?> theClass = (env instanceof Class<?>) ? (Class<?>) env : env.getClass();try {- this.jobExecMethod = theClass.getMethod(jobExec, new Class[0]);+ this.jobExecMethod = theClass.getMethod(jobExec);} catch (final NoSuchMethodException e) {throw new RuntimeException("serverInstantThread, wrong declaration of jobExec: " + e.getMessage());}@@ -64,7 +64,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTif (jobCount == null)this.jobCountMethod = null;else- this.jobCountMethod = theClass.getMethod(jobCount, new Class[0]);+ this.jobCountMethod = theClass.getMethod(jobCount);} catch (final NoSuchMethodException e) {throw new RuntimeException("serverInstantThread, wrong declaration of jobCount: " + e.getMessage());@@ -73,7 +73,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTif (freemem == null)this.freememExecMethod = null;else- this.freememExecMethod = theClass.getMethod(freemem, new Class[0]);+ this.freememExecMethod = theClass.getMethod(freemem);} catch (final NoSuchMethodException e) {throw new RuntimeException("serverInstantThread, wrong declaration of freemem: " + e.getMessage());@@ -87,7 +87,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTpublic int getJobCount() {if (this.jobCountMethod == null) return Integer.MAX_VALUE;try {- final Object result = this.jobCountMethod.invoke(this.environment, new Object[0]);+ final Object result = this.jobCountMethod.invoke(this.environment);if (result instanceof Integer)return ((Integer) result).intValue();else@@ -109,7 +109,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTsynchronized(jobs) {jobs.put(this.handle, getName());}boolean jobHasDoneSomething = false;try {- final Object result = this.jobExecMethod.invoke(this.environment, new Object[0]);+ final Object result = this.jobExecMethod.invoke(this.environment);if (result == null) jobHasDoneSomething = true;else if (result instanceof Boolean) jobHasDoneSomething = ((Boolean) result).booleanValue();} catch (final IllegalAccessException e) {@@ -143,7 +143,7 @@ public final class InstantBusyThread extends AbstractBusyThread implements BusyTpublic void freemem() {if (this.freememExecMethod == null) return;try {- this.freememExecMethod.invoke(this.environment, new Object[0]);+ this.freememExecMethod.invoke(this.environment);} catch (final IllegalAccessException e) {Log.logSevere("BUSYTHREAD", "Internal Error in serverInstantThread.freemem: " + e.getMessage());Log.logSevere("BUSYTHREAD", "shutting down thread '" + getName() + "'");diff --git a/source/net/yacy/peers/Protocol.java b/source/net/yacy/peers/Protocol.javaindex b1681d722..928c56883 100644--- a/source/net/yacy/peers/Protocol.java+++ b/source/net/yacy/peers/Protocol.java@@ -582,7 +582,6 @@ public final class Protocolnull);}- @SuppressWarnings("unchecked")public static int search(final Seed mySeed,final String wordhashes,@@ -672,15 +671,13 @@ public final class Protocol// create containersfinal int words = wordhashes.length() / Word.commonHashLength;assert words > 0 : "wordhashes = " + wordhashes;- final ReferenceContainer<WordReference>[] container = new ReferenceContainer[words];+ final List<ReferenceContainer<WordReference>> container = new ArrayList<ReferenceContainer<WordReference>>(words);for ( int i = 0; i < words; i++ ) {try {- container[i] =- ReferenceContainer.emptyContainer(+ container.add(ReferenceContainer.emptyContainer(Segment.wordReferenceFactory,- ASCII.getBytes(wordhashes.substring(i * Word.commonHashLength, (i + 1)- * Word.commonHashLength)),- count);+ ASCII.getBytes(wordhashes.substring(i * Word.commonHashLength, (i + 1) * Word.commonHashLength)),+ count));} catch ( final RowSpaceExceededException e ) {Log.logException(e);return -1;@@ -774,9 +771,9 @@ public final class Protocol}// add the url entry to the word indexes- for ( int m = 0; m < words; m++ ) {+ for ( final ReferenceContainer<WordReference> c : container ) {try {- container[m].add(entry);+ c.add(entry);} catch ( final RowSpaceExceededException e ) {Log.logException(e);break;@@ -787,7 +784,7 @@ public final class Protocol// store remote result to local result container// insert one container into the search result buffer// one is enough, only the references are used, not the word- containerCache.add(container[0], false, target.getName() + "/" + target.hash, result.joincount, true, time);+ containerCache.add(container.get(0), false, target.getName() + "/" + target.hash, result.joincount, true, time);containerCache.addExpectedRemoteReferences(-count);// insert the containers to the index@@ -802,7 +799,7 @@ public final class ProtocolNetwork.log.logInfo("remote search: peer "+ target.getName()+ " sent "- + container[0].size()+ + container.get(0).size()+ "/"+ result.joincount+ " references for "