Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

code maintenance - removed warnings and replaced deprecated functions

Michael Peter Christen6ef3a0fca56e
diff --git a/.gitignore b/.gitignore
index 1c2c3d3a4..aec19e156 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,8 @@ classes/
RELEASE/
/yacy.pid
.DS_Store
+/yacy/source/.DS_Store
+/htroot/.DS_Store
/DATA.bkp
/DATA.1
/gen
diff --git a/source/net/yacy/cora/date/ISO8601Formatter.java b/source/net/yacy/cora/date/ISO8601Formatter.java
index a16d80ca4..959781dd2 100644
--- a/source/net/yacy/cora/date/ISO8601Formatter.java
+++ b/source/net/yacy/cora/date/ISO8601Formatter.java
@@ -29,7 +29,6 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
-import java.util.NoSuchElementException;
import java.util.StringTokenizer;
public class ISO8601Formatter extends AbstractFormatter implements DateFormatter {
diff --git a/source/net/yacy/cora/document/id/MultiProtocolURL.java b/source/net/yacy/cora/document/id/MultiProtocolURL.java
index 27e9bc205..653d65eba 100644
--- a/source/net/yacy/cora/document/id/MultiProtocolURL.java
+++ b/source/net/yacy/cora/document/id/MultiProtocolURL.java
@@ -36,6 +36,7 @@ import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
@@ -2368,7 +2369,11 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
*/
public java.net.URL getURL() throws MalformedURLException {
if (!(isHTTP() || isHTTPS() || isFTP())) throw new MalformedURLException();
- return new java.net.URL(this.toNormalform(false));
+ try {
+ return new java.net.URI(this.toNormalform(false)).toURL();
+ } catch (URISyntaxException e) {
+ throw new MalformedURLException(e.getMessage());
+ }
}
/**
@@ -2655,6 +2660,7 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
return splitpattern.split(normalizedURL.toLowerCase()); // word components of the url
}
+ @SuppressWarnings("deprecation")
public static void main(final String[] args) {
final String[][] test = new String[][]{
new String[]{null, "file://y:/"},
@@ -2722,7 +2728,7 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
url = element[1];
try {aURL = MultiProtocolURL.newURL(environment, url);} catch (final MalformedURLException e) {e.printStackTrace(); aURL = null;}
if (environment == null) {
- try {jURL = new java.net.URL(url);} catch (final MalformedURLException e) {jURL = null;}
+ try {jURL = new java.net.URI(url).toURL();} catch (final MalformedURLException | URISyntaxException e) {jURL = null;}
} else {
try {jURL = new java.net.URL(new java.net.URL(environment), url);} catch (final MalformedURLException e) {jURL = null;}
}
diff --git a/source/net/yacy/cora/federate/FederateSearchManager.java b/source/net/yacy/cora/federate/FederateSearchManager.java
index e4fdb6458..54e4dc606 100644
--- a/source/net/yacy/cora/federate/FederateSearchManager.java
+++ b/source/net/yacy/cora/federate/FederateSearchManager.java
@@ -22,6 +22,8 @@ package net.yacy.cora.federate;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashSet;
@@ -366,8 +368,8 @@ public class FederateSearchManager {
final String hrefurltxt = sdoc.getFieldValue(WebgraphSchema.target_protocol_s.getSolrFieldName()) + "://" + sdoc.getFieldValue(WebgraphSchema.target_urlstub_s.getSolrFieldName());
URL url;
try {
- url = new URL(hrefurltxt);
- } catch (final MalformedURLException ex) {
+ url = new URI(hrefurltxt).toURL();
+ } catch (final MalformedURLException | URISyntaxException ex) {
LOG.warn("OpenSearch description URL is malformed : " + hrefurltxt);
continue;
}
diff --git a/source/net/yacy/cora/federate/solr/connector/ShardSelection.java b/source/net/yacy/cora/federate/solr/connector/ShardSelection.java
index 7c07124a5..67503081b 100644
--- a/source/net/yacy/cora/federate/solr/connector/ShardSelection.java
+++ b/source/net/yacy/cora/federate/solr/connector/ShardSelection.java
@@ -21,6 +21,8 @@
package net.yacy.cora.federate.solr.connector;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@@ -82,8 +84,8 @@ public class ShardSelection implements Iterable<SolrClient> {
if (sif != null) {
final String url = (String) sif.getValue();
if (url != null && url.length() > 0) try {
- return server4write(new URL(url));
- } catch (final IOException e) {
+ return server4write(new URI(url).toURL());
+ } catch (final IOException | URISyntaxException e) {
ConcurrentLog.logException(e);
return this.server.get(0);
}
@@ -97,7 +99,11 @@ public class ShardSelection implements Iterable<SolrClient> {
public SolrClient server4write(final String host) throws IOException {
if (host == null) throw new IOException("sharding - host url, host empty: " + host);
- if (host.indexOf("://") >= 0) return server4write(new URL(host)); // security catch for accidantly using the wrong method
+ if (host.indexOf("://") >= 0) try {
+ return server4write(new URI(host).toURL()); // security catch for accidently using the wrong method
+ } catch (URISyntaxException e) {
+ throw new IOException("sharding - host url, host invalid: " + host);
+ }
if (this.method == Method.MODULO_HOST_MD5) {
try {
final MessageDigest digest = MessageDigest.getInstance("MD5");
diff --git a/source/net/yacy/cora/federate/solr/embedded/EmbeddedSolrServer.java b/source/net/yacy/cora/federate/solr/embedded/EmbeddedSolrServer.java
index 1606775aa..027084313 100644
--- a/source/net/yacy/cora/federate/solr/embedded/EmbeddedSolrServer.java
+++ b/source/net/yacy/cora/federate/solr/embedded/EmbeddedSolrServer.java
@@ -66,7 +66,6 @@ import org.apache.solr.servlet.SolrRequestParsers;
*
* @since solr 1.3
*/
-@SuppressWarnings("deprecation")
public class EmbeddedSolrServer extends SolrClient {
private static final long serialVersionUID = -6657217211811383651L;
diff --git a/source/net/yacy/cora/plugin/ClassProvider.java b/source/net/yacy/cora/plugin/ClassProvider.java
index 4beafdd29..a494c69ca 100644
--- a/source/net/yacy/cora/plugin/ClassProvider.java
+++ b/source/net/yacy/cora/plugin/ClassProvider.java
@@ -27,6 +27,8 @@ package net.yacy.cora.plugin;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
@@ -46,11 +48,11 @@ public class ClassProvider {
if (!path.startsWith("/")) path = "/" + path;
URL[] urls;
try {
- urls = new URL[]{new URL("file", "", path)};
+ urls = new URL[]{new URI("file", "", path).toURL()};
final URLClassLoader cl = new URLClassLoader(urls);
c = cl.loadClass(classname);
cl.close();
- } catch (ClassNotFoundException | IOException e) {
+ } catch (ClassNotFoundException | IOException | URISyntaxException e) {
e.printStackTrace();
}
}
diff --git a/source/net/yacy/cora/protocol/RequestHeader.java b/source/net/yacy/cora/protocol/RequestHeader.java
index ccc8be808..5a4494cdf 100644
--- a/source/net/yacy/cora/protocol/RequestHeader.java
+++ b/source/net/yacy/cora/protocol/RequestHeader.java
@@ -729,7 +729,7 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
return _request.getLocale();
} else if (super.containsKey(HeaderFramework.ACCEPT_LANGUAGE)) {
final String lng = super.get(HeaderFramework.ACCEPT_LANGUAGE);
- return new Locale(lng);
+ return Locale.forLanguageTag(lng);
}
return Locale.getDefault(); // to avoid dependency on Switchboard just use system default
}
diff --git a/source/net/yacy/cora/protocol/ftp/FTPClient.java b/source/net/yacy/cora/protocol/ftp/FTPClient.java
index fa04ac341..8d5bf185c 100644
--- a/source/net/yacy/cora/protocol/ftp/FTPClient.java
+++ b/source/net/yacy/cora/protocol/ftp/FTPClient.java
@@ -119,7 +119,7 @@ public class FTPClient {
private final Map<String, entryInfo> infoCache = new HashMap<String, entryInfo>();
// date-format in LIST (english month names)
- private static final SimpleDateFormat lsDateFormat = new SimpleDateFormat("MMM d y H:m", new Locale("en"));
+ private static final SimpleDateFormat lsDateFormat = new SimpleDateFormat("MMM d y H:m", Locale.forLanguageTag("en"));
// TODO: implement RFC 2640 Internationalization
diff --git a/source/net/yacy/data/list/XMLBlacklistImporter.java b/source/net/yacy/data/list/XMLBlacklistImporter.java
index 64f239ec0..4bb3289d9 100644
--- a/source/net/yacy/data/list/XMLBlacklistImporter.java
+++ b/source/net/yacy/data/list/XMLBlacklistImporter.java
@@ -56,7 +56,6 @@ public class XMLBlacklistImporter extends DefaultHandler {
@SuppressWarnings("deprecation")
public synchronized ListAccumulator parse(InputSource input) throws IOException, SAXException {
- @SuppressWarnings("deprecation")
final XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
reader.setContentHandler(this);
reader.parse(input);
diff --git a/source/net/yacy/document/TextParser.java b/source/net/yacy/document/TextParser.java
index 7584ad6dc..e7087c85b 100644
--- a/source/net/yacy/document/TextParser.java
+++ b/source/net/yacy/document/TextParser.java
@@ -330,7 +330,7 @@ public final class TextParser {
for(final Parser parser : idioms) {
/* Wrap in a CloseShieldInputStream to prevent SAX parsers closing the sourceStream
* and so let us eventually reuse the same opened stream with other parsers on parser failure */
- CloseShieldInputStream nonCloseInputStream = new CloseShieldInputStream(markableStream);
+ CloseShieldInputStream nonCloseInputStream = CloseShieldInputStream.wrap(markableStream);
try {
return parseSource(location, mimeType, parser, charset, defaultValency, valencySwitchTagNames, scraper, timezoneOffset,
@@ -351,7 +351,7 @@ public final class TextParser {
* (see RFC 7231 section 3.1.2.2 for "Content-Encoding" header specification https://tools.ietf.org/html/rfc7231#section-3.1.2.2)*/
final gzipParser gzParser = (gzipParser)parser;
- nonCloseInputStream = new CloseShieldInputStream(markableStream);
+ nonCloseInputStream = CloseShieldInputStream.wrap(markableStream);
final Document maindoc = gzipParser.createMainDocument(location, mimeType, charset, gzParser);
diff --git a/source/net/yacy/document/parser/GenericXMLParser.java b/source/net/yacy/document/parser/GenericXMLParser.java
index 25d429143..b6205e2b0 100644
--- a/source/net/yacy/document/parser/GenericXMLParser.java
+++ b/source/net/yacy/document/parser/GenericXMLParser.java
@@ -112,7 +112,8 @@ public class GenericXMLParser extends AbstractParser implements Parser {
/* Use commons-io XmlStreamReader advanced rules to help with charset detection when source contains no BOM or XML declaration
* (detection algorithm notably also include ContentType transmitted by HTTP headers, here eventually present as mimeType and charset parameters), */
- final XmlStreamReader reader = new XmlStreamReader(source, mimeType, true, charset);
+ final XmlStreamReader reader = XmlStreamReader.builder().setInputStream(source).setHttpContentType(mimeType).setLenient(true).setCharset(charset).get();
+ //final XmlStreamReader reader = new XmlStreamReader(source, mimeType, true, charset);
final InputSource saxSource = new InputSource(reader);
final String detectedCharset = reader.getEncoding();
@@ -176,7 +177,8 @@ public class GenericXMLParser extends AbstractParser implements Parser {
/* Use commons-io XmlStreamReader advanced rules to help with charset detection when source contains no BOM or XML declaration
* (detection algorithm notably also include ContentType transmitted by HTTP headers, here eventually present as mimeType and charset parameters), */
- final XmlStreamReader reader = new XmlStreamReader(limitedSource, mimeType, true, charsetName);
+ final XmlStreamReader reader = XmlStreamReader.builder().setInputStream(limitedSource).setHttpContentType(mimeType).setLenient(true).setCharset(charsetName).get();
+ //final XmlStreamReader reader = new XmlStreamReader(limitedSource, mimeType, true, charsetName);
final InputSource saxSource = new InputSource(reader);
final String detectedCharset = reader.getEncoding();
diff --git a/source/net/yacy/document/parser/XZParser.java b/source/net/yacy/document/parser/XZParser.java
index c1fc20cad..a49dffcd3 100644
--- a/source/net/yacy/document/parser/XZParser.java
+++ b/source/net/yacy/document/parser/XZParser.java
@@ -60,7 +60,7 @@ public class XZParser extends AbstractCompressorParser {
@Override
protected String getUncompressedFilename(final String filename) {
- return XZUtils.getUncompressedFilename(filename);
+ return XZUtils.getUncompressedFileName(filename);
}
}
diff --git a/source/net/yacy/document/parser/bzipParser.java b/source/net/yacy/document/parser/bzipParser.java
index 5eaed9a1d..b1b376cd9 100644
--- a/source/net/yacy/document/parser/bzipParser.java
+++ b/source/net/yacy/document/parser/bzipParser.java
@@ -125,7 +125,7 @@ public class bzipParser extends AbstractParser implements Parser {
// create maindoc for this bzip container, register with supplied url & mime
maindoc = createMainDocument(location, mimeType, charset, this);
// creating a new parser class to parse the unzipped content
- final String contentfilename = BZip2Utils.getUncompressedFilename(location.getFileName());
+ final String contentfilename = BZip2Utils.getUncompressedFileName(location.getFileName());
final String mime = TextParser.mimeOf(MultiProtocolURL.getFileExtension(contentfilename));
final Document[] docs = TextParser.parseSource(location, mime, null, defaultValency, valencySwitchTagNames, scraper, timezoneOffset, 999, tempFile);
if (docs != null) maindoc.addSubDocuments(docs);
@@ -197,7 +197,7 @@ public class bzipParser extends AbstractParser implements Parser {
final InputStream compressedInStream, final int maxLinks, final long maxBytes) throws Failure {
// creating a new parser class to parse the unzipped content
final String compressedFileName = location.getFileName();
- final String contentfilename = BZip2Utils.getUncompressedFilename(compressedFileName);
+ final String contentfilename = BZip2Utils.getUncompressedFileName(compressedFileName);
final String mime = TextParser.mimeOf(MultiProtocolURL.getFileExtension(contentfilename));
try {
/* Use the uncompressed file name for sub parsers to not unnecessarily use again the gzipparser */
@@ -212,6 +212,7 @@ public class bzipParser extends AbstractParser implements Parser {
}
}
+ @SuppressWarnings("resource")
@Override
public Document[] parseWithLimits(final DigestURL location, final String mimeType, final String charset, final VocabularyScraper scraper,
final int timezoneOffset, final InputStream source, final int maxLinks, final long maxBytes)
@@ -221,7 +222,6 @@ public class bzipParser extends AbstractParser implements Parser {
try {
// BZip2CompressorInputStream checks filecontent (magic start-bytes "BZh") and throws ioexception if no match
zippedContent = new BZip2CompressorInputStream(source);
-
} catch(Exception e) {
throw new Parser.Failure("Unexpected error while parsing bzip file. " + e.getMessage(), location);
}
diff --git a/source/net/yacy/document/parser/docParser.java b/source/net/yacy/document/parser/docParser.java
index 79223f908..56c8aad85 100644
--- a/source/net/yacy/document/parser/docParser.java
+++ b/source/net/yacy/document/parser/docParser.java
@@ -146,6 +146,7 @@ public class docParser extends AbstractParser implements Parser {
* @return an array containing one Document
* @throws net.yacy.document.Parser.Failure
*/
+ @SuppressWarnings("resource")
public Document[] parseOldWordDoc(
final DigestURL location,
final String mimeType,
diff --git a/source/net/yacy/document/parser/gzipParser.java b/source/net/yacy/document/parser/gzipParser.java
index dc4b58ae6..de081eb7e 100644
--- a/source/net/yacy/document/parser/gzipParser.java
+++ b/source/net/yacy/document/parser/gzipParser.java
@@ -128,7 +128,7 @@ public class gzipParser extends AbstractParser implements Parser {
try {
maindoc = createMainDocument(location, mimeType, charset, this);
// creating a new parser class to parse the unzipped content
- final String contentfilename = GzipUtils.getUncompressedFilename(location.getFileName());
+ final String contentfilename = GzipUtils.getUncompressedFileName(location.getFileName());
final String mime = TextParser.mimeOf(MultiProtocolURL.getFileExtension(contentfilename));
Document[] docs = TextParser.parseSource(location, mime, null, defaultValency, valencySwitchTagNames, scraper, timezoneOffset, DEFAULT_DEPTH, tempFile);
if (docs != null) maindoc.addSubDocuments(docs);
@@ -195,7 +195,7 @@ public class gzipParser extends AbstractParser implements Parser {
final InputStream compressedInStream, final int maxLinks, final long maxBytes) throws Failure {
// creating a new parser class to parse the unzipped content
final String compressedFileName = location.getFileName();
- final String contentfilename = GzipUtils.getUncompressedFilename(compressedFileName);
+ final String contentfilename = GzipUtils.getUncompressedFileName(compressedFileName);
final String mime = TextParser.mimeOf(MultiProtocolURL.getFileExtension(contentfilename));
try {
/* Use the uncompressed file name for sub parsers to not unnecessarily use again the gzipparser */
diff --git a/source/net/yacy/document/parser/images/genericImageParser.java b/source/net/yacy/document/parser/images/genericImageParser.java
index eabbc920e..511349b14 100644
--- a/source/net/yacy/document/parser/images/genericImageParser.java
+++ b/source/net/yacy/document/parser/images/genericImageParser.java
@@ -57,7 +57,6 @@ import com.drew.metadata.exif.GpsDirectory;
import net.yacy.cora.document.id.AnchorURL;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.document.id.MultiProtocolURL;
-import net.yacy.cora.federate.solr.connector.SolrServerConnector;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.document.AbstractParser;
import net.yacy.document.Document;
diff --git a/source/net/yacy/document/parser/odtParser.java b/source/net/yacy/document/parser/odtParser.java
index 68c7e0955..601f397ab 100644
--- a/source/net/yacy/document/parser/odtParser.java
+++ b/source/net/yacy/document/parser/odtParser.java
@@ -109,6 +109,7 @@ public class odtParser extends AbstractParser implements Parser {
return parser;
}
+ @SuppressWarnings("resource")
private Document[] parse(final DigestURL location, final String mimeType, @SuppressWarnings("unused") final String charset, final File dest)
throws Parser.Failure, InterruptedException {
diff --git a/source/net/yacy/document/parser/pdfParser.java b/source/net/yacy/document/parser/pdfParser.java
index f02577244..ebee13c2e 100644
--- a/source/net/yacy/document/parser/pdfParser.java
+++ b/source/net/yacy/document/parser/pdfParser.java
@@ -221,6 +221,7 @@ public class pdfParser extends AbstractParser implements Parser {
/**
* Clean up cache resources allocated by PDFBox that would otherwise not be released.
*/
+ @SuppressWarnings("deprecation")
public static void clearPdfBoxCaches() {
/*
* Prior to pdfbox 2.0.0 font cache occupied > 80MB RAM for a single pdf and
diff --git a/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java b/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java
index 5eec59681..1f2ebffb0 100644
--- a/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java
+++ b/source/net/yacy/document/parser/rdfa/impl/RDFaParser.java
@@ -9,6 +9,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
@@ -169,8 +171,8 @@ public class RDFaParser extends AbstractParser implements Parser {
}
} else {
try {
- aURL = new URL(args[0]);
- } catch (final MalformedURLException e) {
+ aURL = new URI(args[0]).toURL();
+ } catch (final MalformedURLException | URISyntaxException e) {
System.err.println("URL is malformed.");
}
diff --git a/source/net/yacy/document/parser/tarParser.java b/source/net/yacy/document/parser/tarParser.java
index d8840c639..df530fc2f 100644
--- a/source/net/yacy/document/parser/tarParser.java
+++ b/source/net/yacy/document/parser/tarParser.java
@@ -97,7 +97,7 @@ public class tarParser extends AbstractParser implements Parser {
while (true) {
try {
File tmp = null;
- entry = tis.getNextTarEntry();
+ entry = tis.getNextEntry();
if (entry == null) break;
if (entry.isDirectory() || entry.getSize() <= 0) continue;
final String name = entry.getName();
@@ -154,7 +154,7 @@ TarArchiveEntry entry;
int totalProcessedLinks = 0;
while (true) {
try {
-entry = tis.getNextTarEntry();
+entry = tis.getNextEntry();
if (entry == null) {
break;
}
diff --git a/source/net/yacy/gui/Tray.java b/source/net/yacy/gui/Tray.java
index 3fbf245b1..efa7a303a 100644
--- a/source/net/yacy/gui/Tray.java
+++ b/source/net/yacy/gui/Tray.java
@@ -38,7 +38,6 @@ import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import javax.imageio.ImageIO;
diff --git a/source/net/yacy/htroot/ConfigParser_p.java b/source/net/yacy/htroot/ConfigParser_p.java
index 943279382..80e756f53 100644
--- a/source/net/yacy/htroot/ConfigParser_p.java
+++ b/source/net/yacy/htroot/ConfigParser_p.java
@@ -30,8 +30,6 @@ package net.yacy.htroot;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.document.Parser;
import net.yacy.document.TextParser;
-import net.yacy.document.parser.pdfParser;
-import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -42,8 +40,6 @@ public class ConfigParser_p {
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
// return variable that accumulates replacements
final serverObjects prop = new serverObjects();
- final Switchboard sb = (Switchboard) env;
-
if (post != null) {
diff --git a/source/net/yacy/htroot/IndexImportJsonList_p.java b/source/net/yacy/htroot/IndexImportJsonList_p.java
index fce17f270..81344a4e5 100644
--- a/source/net/yacy/htroot/IndexImportJsonList_p.java
+++ b/source/net/yacy/htroot/IndexImportJsonList_p.java
@@ -22,6 +22,8 @@ package net.yacy.htroot;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.nio.channels.Channels;
@@ -83,7 +85,7 @@ public class IndexImportJsonList_p {
*/
if (urlstr != null && urlstr.length() > 0) {
try {
- final URL url = new URL(urlstr);
+ final URL url = new URI(urlstr).toURL();
final String tempfilename = "jsonlistimporter";
final boolean gz = urlstr.endsWith(".gz");
final File tempfile = File.createTempFile(tempfilename, "");
@@ -93,7 +95,7 @@ public class IndexImportJsonList_p {
final JsonListImporter wi = new JsonListImporter(tempfile, gz, true);
wi.start();
prop.put("import_thread", "started");
- } catch (final IOException ex) {
+ } catch (final IOException | URISyntaxException ex) {
prop.put("import_thread", ex.getMessage());
}
prop.put("import", 1);
diff --git a/source/net/yacy/htroot/api/ynetSearch.java b/source/net/yacy/htroot/api/ynetSearch.java
index d9c756d8a..0eb8fb937 100644
--- a/source/net/yacy/htroot/api/ynetSearch.java
+++ b/source/net/yacy/htroot/api/ynetSearch.java
@@ -3,6 +3,7 @@ package net.yacy.htroot.api;
import java.io.IOException;
import java.io.InputStream;
+import java.net.URI;
import java.net.URL;
import java.util.Iterator;
import java.util.Map;
@@ -46,7 +47,7 @@ public class ynetSearch {
s = s + "&" + k.getKey() + "=" + k.getValue();
}
// final String s = searchaddress+"&query="+post.get("search")+"&maximumRecords="+post.get("maximumRecords")+"&startRecord="+post.get("startRecord");
- final URL url = new URL(s);
+ final URL url = new URI(s).toURL();
is = url.openStream();
Scanner scanner = new Scanner(is);
final String httpout = scanner.useDelimiter( "\\Z" ).next();
diff --git a/source/net/yacy/http/InetPathAccessHandler.java b/source/net/yacy/http/InetPathAccessHandler.java
index 822a518ff..f49145cbe 100644
--- a/source/net/yacy/http/InetPathAccessHandler.java
+++ b/source/net/yacy/http/InetPathAccessHandler.java
@@ -102,7 +102,7 @@ public class InetPathAccessHandler extends InetAccessHandler {
final String path = (idx > 0 && (pattern.length() > idx + 1)) ? pattern.substring(idx + 1) : "/*";
if (!addr.isEmpty()) {
- final PathSpec pathSpec = PathMappings.asPathSpec(path);
+ final PathSpec pathSpec = PathSpec.from(path);
InetAddressSet addresses = pathMappings.get(pathSpec);
if (addresses == null) {
addresses = new InetAddressSet();
diff --git a/source/net/yacy/http/servlets/RAGProxyServlet.java b/source/net/yacy/http/servlets/RAGProxyServlet.java
index 3dba3cd97..e7de7d61d 100644
--- a/source/net/yacy/http/servlets/RAGProxyServlet.java
+++ b/source/net/yacy/http/servlets/RAGProxyServlet.java
@@ -24,7 +24,6 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-import net.yacy.ai.OllamaClient;
import net.yacy.ai.OpenAIClient;
import net.yacy.cora.federate.solr.connector.EmbeddedSolrConnector;
import net.yacy.search.Switchboard;
@@ -51,12 +50,8 @@ import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
-import java.util.AbstractMap;
-import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
/**
* This class implements a Retrieval Augmented Generation ("RAG") proxy which uses a YaCy search index
@@ -66,11 +61,11 @@ public class RAGProxyServlet extends HttpServlet {
private static final long serialVersionUID = 3411544789759603107L;
- private static Boolean LLM_ENABLED = false;
- private static Boolean LLM_CONTROL_OLLAMA = true;
- private static Boolean LLM_ATTACH_QUERY = false; // instructs the proxy to attach the prompt generated to do the RAG search
- private static Boolean LLM_ATTACH_REFERENCES = false; // instructs the proxy to attach a list of sources that had been used in RAG
- private static String LLM_LANGUAGE = "en"; // used to select proper language in RAG augmentation
+ //private static Boolean LLM_ENABLED = false;
+ //private static Boolean LLM_CONTROL_OLLAMA = true;
+ //private static Boolean LLM_ATTACH_QUERY = false; // instructs the proxy to attach the prompt generated to do the RAG search
+ //private static Boolean LLM_ATTACH_REFERENCES = false; // instructs the proxy to attach a list of sources that had been used in RAG
+ //private static String LLM_LANGUAGE = "en"; // used to select proper language in RAG augmentation
private static String LLM_SYSTEM_PREFIX = "\n\nYou may receive additional expert knowledge in the user prompt after a 'Additional Information' headline to enhance your knowledge. Use it only if applicable.";
private static String LLM_USER_PREFIX = "\n\nAdditional Information:\n\nbelow you find a collection of texts that might be useful to generate a response. Do not discuss these documents, just use them to answer the question above.\n\n";
private static String LLM_API_HOST = "http://localhost:11434"; // Ollama port; install ollama from https://ollama.com/
diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
index d543bfd4e..7e3cc93f5 100644
--- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
+++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java
@@ -37,7 +37,6 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.regex.Pattern;
@@ -58,7 +57,6 @@ import net.yacy.cora.util.ConcurrentLog;
import net.yacy.crawler.retrieval.Response;
import net.yacy.document.SentenceReader;
import net.yacy.document.Tokenizer;
-import net.yacy.document.parser.pdfParser;
import net.yacy.document.parser.html.ContentScraper;
import net.yacy.document.parser.html.IconEntry;
import net.yacy.document.parser.html.IconLinkRelations;
diff --git a/source/net/yacy/kelondro/index/RowHandleMap.java b/source/net/yacy/kelondro/index/RowHandleMap.java
index 555bb0d61..9505345d2 100644
--- a/source/net/yacy/kelondro/index/RowHandleMap.java
+++ b/source/net/yacy/kelondro/index/RowHandleMap.java
@@ -86,6 +86,7 @@ public final class RowHandleMap implements HandleMap, Iterable<Map.Entry<byte[],
* @throws IOException
* @throws SpaceExceededException
*/
+ @SuppressWarnings("resource")
public RowHandleMap(final int keylength, final ByteOrder objectOrder, final int idxbytes, final File file) throws IOException, SpaceExceededException {
this(keylength, objectOrder, idxbytes, (int) (file.length() / (keylength + idxbytes)), file.getAbsolutePath());
// read the index dump and fill the index
@@ -95,10 +96,11 @@ public final class RowHandleMap implements HandleMap, Iterable<Map.Entry<byte[],
fis = new FileInputStream(file);
is = new BufferedInputStream(fis, 1024 * 1024);
} catch (final OutOfMemoryError e) {
- if(fis != null) {
+ if (fis != null) {
/* Reuse if possible the already created FileInputStream */
is = fis;
} else {
+ // fis is null, no resource to close
is = new FileInputStream(file);
}
}
diff --git a/source/net/yacy/kelondro/logging/ThreadDump.java b/source/net/yacy/kelondro/logging/ThreadDump.java
index a4d842d02..19ed27ef2 100644
--- a/source/net/yacy/kelondro/logging/ThreadDump.java
+++ b/source/net/yacy/kelondro/logging/ThreadDump.java
@@ -236,7 +236,7 @@ public class ThreadDump extends HashMap<ThreadDump.StackTrace, List<String>> imp
while (tracename.length() < 20) tracename = tracename + "_";
tracename = "[" + tracename + "] ";
}
- final String threadtitle = tracename + "Thread= " + thread.getName() + " " + (thread.isDaemon()?"daemon":"") + " id=" + thread.getId() + " " + thread.getState().toString();
+ final String threadtitle = tracename + "Thread= " + thread.getName() + " " + (thread.isDaemon()?"daemon":"") + " id=" + thread.threadId() + " " + thread.getState().toString();
String className;
boolean cutcore = true;
for (int i = 0; i < stackTraceElements.length; i++) {
diff --git a/source/net/yacy/kelondro/util/Formatter.java b/source/net/yacy/kelondro/util/Formatter.java
index 07ee3401e..5a7987c2e 100644
--- a/source/net/yacy/kelondro/util/Formatter.java
+++ b/source/net/yacy/kelondro/util/Formatter.java
@@ -42,7 +42,7 @@ import java.util.Locale;
public final class Formatter {
// default formatter
- private static Locale locale = new Locale("en");
+ private static Locale locale = Locale.forLanguageTag("en");
/**
* use ThreadLocal to generate new formatter for each Thread since NumberFormat is not synchronized
*/
@@ -78,7 +78,7 @@ public final class Formatter {
*/
public static void setLocale(final String lang) {
final String l = (lang.equalsIgnoreCase("default") ? "en" : lang.toLowerCase(Locale.ROOT));
- setLocale(l.equals("none") ? null : new Locale(l));
+ setLocale(l.equals("none") ? null : Locale.forLanguageTag(l));
}
diff --git a/source/net/yacy/kelondro/util/OS.java b/source/net/yacy/kelondro/util/OS.java
index 7ca735e45..838c64fe1 100644
--- a/source/net/yacy/kelondro/util/OS.java
+++ b/source/net/yacy/kelondro/util/OS.java
@@ -122,7 +122,7 @@ public final class OS {
FileUtils.copy(UTF8.getBytes(theScript), scriptFile);
if(!isWindows){ // set executable
try {
- Runtime.getRuntime().exec("chmod 755 " + scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
+ Runtime.getRuntime().exec(new String[]{"chmod", "755", scriptFile.getAbsolutePath().replaceAll(" ", "\\ ")}).waitFor();
} catch (final InterruptedException e) {
ConcurrentLog.severe("DEPLOY", "deploy of script file failed. file = " + scriptFile.getAbsolutePath(), e);
throw new IOException(e.getMessage());
@@ -155,7 +155,7 @@ public final class OS {
final File starterFile = new File(scriptFile.getAbsolutePath().replaceAll(" ", "\\ ") + starterFileExtension);
deployScript(starterFile, script);
try {
- Runtime.getRuntime().exec(starterFile.getAbsolutePath().replaceAll(" ", "\\ ")).waitFor();
+ Runtime.getRuntime().exec(new String[] {starterFile.getAbsolutePath().replaceAll(" ", "\\ ")}).waitFor();
} catch (final InterruptedException e) {
throw new IOException(e.getMessage());
}
diff --git a/source/net/yacy/peers/Seed.java b/source/net/yacy/peers/Seed.java
index 7ef4f5ead..ad1976cc2 100644
--- a/source/net/yacy/peers/Seed.java
+++ b/source/net/yacy/peers/Seed.java
@@ -47,6 +47,8 @@ import java.io.IOException;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.text.ParseException;
import java.time.DateTimeException;
@@ -1358,7 +1360,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
return "wrong protocol for seedURL";
}
try {
- final URL url = new URL(seedURL);
+ final URL url = new URI(seedURL).toURL();
final String host = url.getHost();
if (Domains.isIntranet(host)) {
// network.unit.domain = any returns isIntranet() always true (because noLocalCheck is set true)
@@ -1371,7 +1373,7 @@ public class Seed implements Cloneable, Comparable<Seed>, Comparator<Seed>
return "seedURL in local network rejected ("+host+")";
}
}
- } catch (final MalformedURLException e ) {
+ } catch (final MalformedURLException | URISyntaxException e ) {
return "seedURL malformed";
}
}
diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java
index 30cc728dd..159dd2d29 100644
--- a/source/net/yacy/search/Switchboard.java
+++ b/source/net/yacy/search/Switchboard.java
@@ -728,7 +728,7 @@ public final class Switchboard extends serverSwitch {
// Set jvm default locale to match UI language (
String lng = this.getConfig("locale.language", "en");
if (!"browser".equals(lng) && !"default".equals(lng)) {
- Locale.setDefault(new Locale(lng));
+ Locale.setDefault(Locale.forLanguageTag(lng));
} else {
lng = "en"; // default = English
}
diff --git a/source/net/yacy/search/index/SingleDocumentMatcher.java b/source/net/yacy/search/index/SingleDocumentMatcher.java
index cb98f7c3e..312bd3ee0 100644
--- a/source/net/yacy/search/index/SingleDocumentMatcher.java
+++ b/source/net/yacy/search/index/SingleDocumentMatcher.java
@@ -63,7 +63,8 @@ public abstract class SingleDocumentMatcher {
final SolrQueryRequestBase solrRequest = new SolrQueryRequestBase(targetCore, solrQuery) {
};
- final LuceneQParserPlugin luceneParserPlugin = new LuceneQParserPlugin();
+ @SuppressWarnings("resource")
+ final LuceneQParserPlugin luceneParserPlugin = new LuceneQParserPlugin();
final QParser solrParser = luceneParserPlugin.createParser(query, null, solrRequest.getParams(), solrRequest);
return solrParser.parse();
}
diff --git a/source/net/yacy/search/schema/CollectionSchema.java b/source/net/yacy/search/schema/CollectionSchema.java
index 4b9e1d8b9..8440fb978 100644
--- a/source/net/yacy/search/schema/CollectionSchema.java
+++ b/source/net/yacy/search/schema/CollectionSchema.java
@@ -24,7 +24,7 @@ import java.util.Date;
import java.util.List;
import java.util.Locale;
-import org.apache.poi.ss.formula.atp.DateParser;
+import org.apache.poi.ss.util.DateParser;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.solr.common.SolrInputDocument;
diff --git a/source/net/yacy/utils/tarTools.java b/source/net/yacy/utils/tarTools.java
index 9deb1ddb3..94f4e0ae4 100644
--- a/source/net/yacy/utils/tarTools.java
+++ b/source/net/yacy/utils/tarTools.java
@@ -126,7 +126,7 @@ public class tarTools {
if (new File(untarDir).exists()) {
final TarArchiveInputStream tin = new TarArchiveInputStream(in);
try {
- TarArchiveEntry tarEntry = tin.getNextTarEntry();
+ TarArchiveEntry tarEntry = tin.getNextEntry();
if (tarEntry == null) {
throw new IOException("tar archive is empty or corrupted");
}
@@ -143,7 +143,7 @@ public class tarTools {
} else {
destPath.mkdir();
}
- tarEntry = tin.getNextTarEntry();
+ tarEntry = tin.getNextEntry();
}
} finally {
try {
diff --git a/source/org/openzim/ZIMReader.java b/source/org/openzim/ZIMReader.java
index 14bc47dfd..6ecdb4a9d 100644
--- a/source/org/openzim/ZIMReader.java
+++ b/source/org/openzim/ZIMReader.java
@@ -446,6 +446,7 @@ public class ZIMReader {
return this.blobs.get(i);
}
+ @SuppressWarnings("unused")
public int getSize() {
return this.blobs.size();
}