From df9ea0a42a6188246bc77ea98b49f2f6babf50c6 Mon Sep 17 00:00:00 2001 From: sgaebel Date: Sun, 26 Jul 2020 23:44:54 +0200 Subject: [PATCH] removes some warnings: unused imports, params --- .project | 1 - htroot/yacy/profile.java | 1 - .../net/yacy/cora/federate/FederateSearchManager.java | 11 +++++------ .../solr/responsewriter/FlatJSONResponseWriter.java | 5 +---- .../cora/protocol/http/auth/YaCyDigestScheme.java | 2 +- source/net/yacy/cora/storage/Configuration.java | 1 - source/net/yacy/cora/util/Html2Image.java | 2 ++ source/net/yacy/document/DateDetection.java | 3 ++- source/net/yacy/document/Parser.java | 1 - .../net/yacy/document/importer/ResumptionToken.java | 1 + .../yacy/document/parser/html/TransformerWriter.java | 6 +++--- source/net/yacy/http/ProxyCacheHandler.java | 7 +++---- source/net/yacy/kelondro/logging/ThreadDump.java | 1 + source/net/yacy/server/http/HTTPDProxyHandler.java | 6 ++++-- source/net/yacy/utils/{gzip.java => Gzip.java} | 8 ++++---- source/net/yacy/utils/crypt.java | 4 ++-- source/net/yacy/utils/cryptbig.java | 8 ++++---- source/net/yacy/yacy.java | 4 ---- test/java/net/yacy/peers/NewsPoolTest.java | 4 ++-- 19 files changed, 35 insertions(+), 41 deletions(-) rename source/net/yacy/utils/{gzip.java => Gzip.java} (95%) diff --git a/.project b/.project index cabb4c415..6cbb7fca6 100644 --- a/.project +++ b/.project @@ -23,6 +23,5 @@ org.eclipse.jdt.core.javanature - org.eclipse.wst.jsdt.core.jsNature diff --git a/htroot/yacy/profile.java b/htroot/yacy/profile.java index 1bfe1dd42..f0e0eb1dd 100644 --- a/htroot/yacy/profile.java +++ b/htroot/yacy/profile.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.util.Iterator; import java.util.Properties; -import net.yacy.cora.protocol.HeaderFramework; import net.yacy.cora.protocol.RequestHeader; import net.yacy.peers.Protocol; import net.yacy.search.Switchboard; diff --git a/source/net/yacy/cora/federate/FederateSearchManager.java b/source/net/yacy/cora/federate/FederateSearchManager.java index 35b052cb4..3bca68f02 100644 --- a/source/net/yacy/cora/federate/FederateSearchManager.java +++ b/source/net/yacy/cora/federate/FederateSearchManager.java @@ -163,7 +163,7 @@ public class FederateSearchManager { public void search(SearchEvent theSearch) { if (theSearch != null) { if (!theSearch.query.isLocal() && !MemoryControl.shortStatus()) { - Set picklist = getBest(theSearch.getQuery()); + Set picklist = getBest(); for (AbstractFederateSearchConnector fsc : picklist) { fsc.search(theSearch); } @@ -180,7 +180,7 @@ public class FederateSearchManager { public List query(QueryParams query) { if (!query.isLocal() && !MemoryControl.shortStatus()) { List sdl = new ArrayList(); - Set picklist = getBest(query); + Set picklist = getBest(); for (AbstractFederateSearchConnector fsc : picklist) { sdl.addAll(fsc.query(query)); } @@ -279,12 +279,11 @@ public class FederateSearchManager { } /** - * Get best systems from configured targets for this search - * - * @param theSearch + * Get best systems from configured targets + * * @return list of searchtargetconnectors */ - protected Set getBest(final QueryParams query) { + protected Set getBest() { HashSet retset = new HashSet(); MultiProtocolURL connectorURL; for (AbstractFederateSearchConnector fsc : conlist) { diff --git a/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java b/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java index 6dfa6bf34..910f4ba1f 100644 --- a/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java +++ b/source/net/yacy/cora/federate/solr/responsewriter/FlatJSONResponseWriter.java @@ -52,10 +52,7 @@ public class FlatJSONResponseWriter implements QueryResponseWriter, EmbeddedSolr private static final char lb = '\n'; - private boolean elasticsearchBulkRequest; - - public FlatJSONResponseWriter(boolean elasticsearchBulkRequest) { - this.elasticsearchBulkRequest = elasticsearchBulkRequest; + public FlatJSONResponseWriter() { } @Override diff --git a/source/net/yacy/cora/protocol/http/auth/YaCyDigestScheme.java b/source/net/yacy/cora/protocol/http/auth/YaCyDigestScheme.java index 7fced6bb4..d729ce605 100644 --- a/source/net/yacy/cora/protocol/http/auth/YaCyDigestScheme.java +++ b/source/net/yacy/cora/protocol/http/auth/YaCyDigestScheme.java @@ -261,7 +261,7 @@ public class YaCyDigestScheme extends DigestScheme { sb.append(checksum).append(':').append(nonce).append(':').append(cnonce); a1 = sb.toString();*/ sb.append(pwd).append(':').append(nonce).append(':').append(cnonce); - hasha1 = encode(digester.digest(EncodingUtils.getBytes(sb.toString(), charset)));; + hasha1 = encode(digester.digest(EncodingUtils.getBytes(sb.toString(), charset))); } else { // unq(username-value) ":" unq(realm-value) ":" passwd /* Modification for YaCy Digest Authentication : the pwd value is already the result of MD5(userName:realm:password) diff --git a/source/net/yacy/cora/storage/Configuration.java b/source/net/yacy/cora/storage/Configuration.java index eba6ad831..64dc3cd6d 100644 --- a/source/net/yacy/cora/storage/Configuration.java +++ b/source/net/yacy/cora/storage/Configuration.java @@ -32,7 +32,6 @@ import java.util.Map; import java.util.TreeMap; import net.yacy.cora.storage.Configuration.Entry; -import net.yacy.cora.storage.Files; /** * this class reads configuration attributes as a list of keywords from a list diff --git a/source/net/yacy/cora/util/Html2Image.java b/source/net/yacy/cora/util/Html2Image.java index 611f38897..baf8d76be 100644 --- a/source/net/yacy/cora/util/Html2Image.java +++ b/source/net/yacy/cora/util/Html2Image.java @@ -237,6 +237,8 @@ public class Html2Image { * @param proxy the eventual proxy address to use. Can be null. * @param destination the destination PDF file that should be written. Must not * be null. + * @param userAgent TODO: implement + * @param acceptLanguage TODO: implement * @param ignoreErrors when true wkhtmltopdf is instructed to ignore load errors * @param maxSeconds the maximum time in seconds to wait for the wkhtmltopdf * dedicated process termination. Beyond this limit the diff --git a/source/net/yacy/document/DateDetection.java b/source/net/yacy/document/DateDetection.java index 3d048ce69..08e7c24e3 100644 --- a/source/net/yacy/document/DateDetection.java +++ b/source/net/yacy/document/DateDetection.java @@ -673,6 +673,7 @@ public class DateDetection { /** * get all dates in the text * @param text + * @param timezoneOffset TODO: implement * @return a set of dates, ordered by time. first date in the ordered set is the oldest time. */ public static LinkedHashSet parse(String text, int timezoneOffset) { @@ -692,7 +693,7 @@ public class DateDetection { * This is used by the query parser for query date modifier on:, from: or to: * * @param text - * @param timezoneOffset + * @param timezoneOffset TODO: implement * @return determined date or null */ public static Date parseLine(final String text, final int timezoneOffset) { diff --git a/source/net/yacy/document/Parser.java b/source/net/yacy/document/Parser.java index 23ba1df8d..fda309be9 100644 --- a/source/net/yacy/document/Parser.java +++ b/source/net/yacy/document/Parser.java @@ -28,7 +28,6 @@ import java.util.Set; import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.document.id.MultiProtocolURL; -import net.yacy.document.Parser.Failure; public interface Parser { diff --git a/source/net/yacy/document/importer/ResumptionToken.java b/source/net/yacy/document/importer/ResumptionToken.java index 855628267..f0c21e6ed 100644 --- a/source/net/yacy/document/importer/ResumptionToken.java +++ b/source/net/yacy/document/importer/ResumptionToken.java @@ -59,6 +59,7 @@ public class ResumptionToken extends TreeMap { private final DigestURL source; + @SuppressWarnings("unused") public ResumptionToken(final DigestURL source, final byte[] b) throws IOException { super((Collator) insensitiveCollator.clone()); this.source = source; diff --git a/source/net/yacy/document/parser/html/TransformerWriter.java b/source/net/yacy/document/parser/html/TransformerWriter.java index a6d6a9189..aafe5bfb6 100644 --- a/source/net/yacy/document/parser/html/TransformerWriter.java +++ b/source/net/yacy/document/parser/html/TransformerWriter.java @@ -252,7 +252,7 @@ public final class TransformerWriter extends Writer { // we have a new tag if (opening) { // case (2): - return filterTagOpening(tagname, content, quotechar); + return filterTagOpening(tagname, content); } // its a close tag where no should be @@ -267,7 +267,7 @@ public final class TransformerWriter extends Writer { // it's a tag! which one? if (opening) { // case (5): the opening should not be here. But we keep the order anyway - this.tagStack.lastElement().content.append(filterTagOpening(tagname, content, quotechar)); + this.tagStack.lastElement().content.append(filterTagOpening(tagname, content)); return new char[0]; } @@ -281,7 +281,7 @@ public final class TransformerWriter extends Writer { return filterTagCloseing(quotechar); } - private char[] filterTagOpening(final String tagname, final char[] content, final char quotechar) { + private char[] filterTagOpening(final String tagname, final char[] content) { final CharBuffer charBuffer = new CharBuffer(ContentScraper.MAX_DOCSIZE, content); ContentScraper.Tag tag = new ContentScraper.Tag(tagname, charBuffer.propParser()); charBuffer.close(); diff --git a/source/net/yacy/http/ProxyCacheHandler.java b/source/net/yacy/http/ProxyCacheHandler.java index 5120b48a8..e2cf4abe0 100644 --- a/source/net/yacy/http/ProxyCacheHandler.java +++ b/source/net/yacy/http/ProxyCacheHandler.java @@ -31,15 +31,14 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.eclipse.jetty.server.Handler; +import org.eclipse.jetty.server.Request; + import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.ResponseHeader; import net.yacy.crawler.data.Cache; import net.yacy.crawler.retrieval.Response; -import net.yacy.http.servlets.YaCyDefaultServlet; - -import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.Request; /** * jetty http handler serves pages from cache if available and valid diff --git a/source/net/yacy/kelondro/logging/ThreadDump.java b/source/net/yacy/kelondro/logging/ThreadDump.java index 1e8d2c78a..c554d304c 100644 --- a/source/net/yacy/kelondro/logging/ThreadDump.java +++ b/source/net/yacy/kelondro/logging/ThreadDump.java @@ -254,6 +254,7 @@ public class ThreadDump extends HashMap> imp } } final String threaddump = sb.toString(); + @SuppressWarnings("unlikely-arg-type") List threads = get(threaddump); if (threads == null) threads = new ArrayList(); Thread.State state = null; diff --git a/source/net/yacy/server/http/HTTPDProxyHandler.java b/source/net/yacy/server/http/HTTPDProxyHandler.java index b181d687b..c63b4ee9c 100644 --- a/source/net/yacy/server/http/HTTPDProxyHandler.java +++ b/source/net/yacy/server/http/HTTPDProxyHandler.java @@ -1044,8 +1044,10 @@ public final class HTTPDProxyHandler { String orgHostName = orgurl.getHost(); if (orgHostName == null) orgHostName = "unknown"; orgHostName = orgHostName.toLowerCase(Locale.ROOT); - String orgHostPath = orgurl.getPath(); if (orgHostPath == null) orgHostPath = ""; - String orgHostArgs = orgurl.getSearchpart();; if (orgHostArgs == null) orgHostArgs = ""; + String orgHostPath = orgurl.getPath(); + if (orgHostPath == null) orgHostPath = ""; + String orgHostArgs = orgurl.getSearchpart(); + if (orgHostArgs == null) orgHostArgs = ""; if (orgHostArgs.length() > 0) orgHostArgs = "?" + orgHostArgs; detailedErrorMsgMap.put("hostName", orgHostName); diff --git a/source/net/yacy/utils/gzip.java b/source/net/yacy/utils/Gzip.java similarity index 95% rename from source/net/yacy/utils/gzip.java rename to source/net/yacy/utils/Gzip.java index e95f82d04..10692ed40 100644 --- a/source/net/yacy/utils/gzip.java +++ b/source/net/yacy/utils/Gzip.java @@ -43,7 +43,7 @@ import net.yacy.cora.document.encoding.UTF8; import net.yacy.cora.util.ConcurrentLog; -public class gzip { +public class Gzip { private final static ConcurrentLog logger = new ConcurrentLog("GZIP"); @@ -109,7 +109,7 @@ public class gzip { return UTF8.String(gunzip(in)); } - public static byte[] gzip(byte[] b) { + public static byte[] gzip(final byte[] b) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(b.length); GZIPOutputStream out = new GZIPOutputStream(baos, Math.min(65536, b.length)){{def.setLevel(Deflater.BEST_COMPRESSION);}}; @@ -215,13 +215,13 @@ public class gzip { } else { target = s[2]; } - gzip.gunzipFile(new File(s[1]), new File(target)); + Gzip.gunzipFile(new File(s[1]), new File(target)); System.exit(0); } if ((s.length < 1) || (s.length > 2)) {help(); System.exit(-1);} String target; if (s.length == 1) target = s[0] + ".gz"; else target = s[1]; - gzip.gzipFile((s[0]), target); + Gzip.gzipFile((s[0]), target); System.exit(0); } diff --git a/source/net/yacy/utils/crypt.java b/source/net/yacy/utils/crypt.java index 45e21c55f..cce46a296 100644 --- a/source/net/yacy/utils/crypt.java +++ b/source/net/yacy/utils/crypt.java @@ -75,7 +75,7 @@ public class crypt { if (key == null) { key = "NULL"; } switch (method) { case 'b' : return "b|" + Base64Order.enhancedCoder.encodeString(content); - case 'z' : return "z|" + Base64Order.enhancedCoder.encode(gzip.gzipString(content)); + case 'z' : return "z|" + Base64Order.enhancedCoder.encode(Gzip.gzipString(content)); case 'p' : return "p|" + content; default : return null; } @@ -94,7 +94,7 @@ public class crypt { } case 'z': try { - return gzip.gunzipString(Base64Order.enhancedCoder.decode(encoded.substring(2))); + return Gzip.gunzipString(Base64Order.enhancedCoder.decode(encoded.substring(2))); } catch (final Exception e) { ConcurrentLog.logException(e); return null; diff --git a/source/net/yacy/utils/cryptbig.java b/source/net/yacy/utils/cryptbig.java index 3572568bd..509249143 100644 --- a/source/net/yacy/utils/cryptbig.java +++ b/source/net/yacy/utils/cryptbig.java @@ -380,7 +380,7 @@ public class cryptbig { //System.out.println("Salt=" + salt); final cryptbig c = new cryptbig(key, salt); boolean gzFlag = true; - byte[] gz = gzip.gzipString(s); + byte[] gz = Gzip.gzipString(s); if (gz.length > s.length()) { // revert compression try { @@ -406,7 +406,7 @@ public class cryptbig { if (b64dec == null) return null; // error in input string (inconsistency) final byte[] dec = c.decryptArray(b64dec); if (dec == null) return null; - if (gzFlag) return gzip.gunzipString(dec); + if (gzFlag) return Gzip.gunzipString(dec); return UTF8.String(dec); } @@ -429,7 +429,7 @@ public class cryptbig { if (key == null) key = "NULL"; if (method == 'p') return "p|" + content; if (method == 'b') return "b|" + Base64Order.enhancedCoder.encodeString(content); - if (method == 'z') return "z|" + Base64Order.enhancedCoder.encode(gzip.gzipString(content)); + if (method == 'z') return "z|" + Base64Order.enhancedCoder.encode(Gzip.gzipString(content)); if (method == 'c') return "c|" + scrambleString(key, content); return null; } @@ -441,7 +441,7 @@ public class cryptbig { encoded = encoded.substring(2); if (method == 'p') return encoded; if (method == 'b') return Base64Order.enhancedCoder.decodeString(encoded); - if (method == 'z') return gzip.gunzipString(Base64Order.enhancedCoder.decode(encoded)); + if (method == 'z') return Gzip.gunzipString(Base64Order.enhancedCoder.decode(encoded)); if (method == 'c') return descrambleString(key, encoded); return null; } diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index 8fadc7319..b3f6d9e83 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -54,10 +54,8 @@ import com.google.common.io.Files; import net.yacy.cora.date.GenericFormatter; import net.yacy.cora.document.encoding.UTF8; -import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.document.id.MultiProtocolURL; import net.yacy.cora.federate.solr.instance.RemoteInstance; -import net.yacy.cora.federate.yacy.CacheStrategy; import net.yacy.cora.order.Digest; import net.yacy.cora.protocol.ClientIdentification; import net.yacy.cora.protocol.ConnectionInfo; @@ -66,10 +64,8 @@ import net.yacy.cora.protocol.TimeoutRequest; import net.yacy.cora.protocol.http.HTTPClient; import net.yacy.cora.sorting.Array; import net.yacy.cora.util.ConcurrentLog; -import net.yacy.crawler.retrieval.Response; import net.yacy.data.TransactionManager; import net.yacy.data.Translator; -import net.yacy.document.Document; import net.yacy.gui.YaCyApp; import net.yacy.gui.framework.Browser; import net.yacy.http.Jetty9HttpServerImpl; diff --git a/test/java/net/yacy/peers/NewsPoolTest.java b/test/java/net/yacy/peers/NewsPoolTest.java index 3fa45ef22..43e5b4c33 100644 --- a/test/java/net/yacy/peers/NewsPoolTest.java +++ b/test/java/net/yacy/peers/NewsPoolTest.java @@ -45,7 +45,7 @@ public class NewsPoolTest { Seed myseed = new Seed(ASCII.String(hash), dna); // generate 3 test messages and simulate publish (put in outgoing queuq - Map msgattr = new HashMap(); + Map msgattr = new HashMap<>(); for (int i = 1; i <= 3; i++) { msgattr.put("text", "message " + Integer.toString(i)); msgattr.put("#", Integer.toString(i)); // use id modificator attribute (to generate unique id for same creation second, used in id) @@ -53,7 +53,7 @@ public class NewsPoolTest { } // test the distribution process - Set resultmemory = new LinkedHashSet(); + Set resultmemory = new LinkedHashSet<>(); NewsDB.Record rec = newsPool.myPublication(); int cnt = 3 * 30 + 5; // end condition (3 msg * 30 distribution) for loop (+5 > as expected count) while (rec != null && cnt > 0) {