diff --git a/source/net/yacy/cora/document/id/MultiProtocolURL.java b/source/net/yacy/cora/document/id/MultiProtocolURL.java index 92ab41a52..e9a46fc91 100644 --- a/source/net/yacy/cora/document/id/MultiProtocolURL.java +++ b/source/net/yacy/cora/document/id/MultiProtocolURL.java @@ -2553,8 +2553,14 @@ public class MultiProtocolURL implements Serializable, Comparable { return Boolean.TRUE; } //System.out.println("PING socket close = " + (System.currentTimeMillis() - time) + " ms (" + host + ":" + port + ")"); time = System.currentTimeMillis(); + socket.close(); return Boolean.FALSE; } catch (final UnknownHostException e) { //System.out.println("PING socket UnknownHostException = " + (System.currentTimeMillis() - time) + " ms (" + host + ":" + port + ")"); time = System.currentTimeMillis(); diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.java index abb583f80..0ca7eda55 100644 --- a/source/net/yacy/cora/protocol/http/HTTPClient.java +++ b/source/net/yacy/cora/protocol/http/HTTPClient.java @@ -1105,8 +1105,9 @@ public class HTTPClient implements Closeable { // } // Close out connection manager try { - HTTPClient.closeConnectionManager(); - } catch (final InterruptedException e) { + client.close(); + HTTPClient.closeConnectionManager(); + } catch (final InterruptedException | IOException e) { e.printStackTrace(); } } diff --git a/source/net/yacy/cora/storage/ZIPReader.java b/source/net/yacy/cora/storage/ZIPReader.java index ced9dfd76..8062be533 100644 --- a/source/net/yacy/cora/storage/ZIPReader.java +++ b/source/net/yacy/cora/storage/ZIPReader.java @@ -138,5 +138,6 @@ public class ZIPReader extends AbstractMap implements Map 240) ? contents.substring(0,240) : contents.toString().trim(); @@ -132,7 +134,7 @@ public class docParser extends AbstractParser implements Parser { false, extractor.getSummaryInformation().getLastSaveDateTime() // maybe null )}; - + try {extractor.close();} catch (IOException e1) {} return docs; } @@ -161,6 +163,7 @@ public class docParser extends AbstractParser implements Parser { try { contents.append(extractor.getText()); } catch (final Exception e) { + try {extractor.close();} catch (IOException e1) {} throw new Parser.Failure("error in docParser, getText: " + e.getMessage(), location); } String title = (contents.length() > 240) ? contents.substring(0,240) : contents.toString().trim(); @@ -206,7 +209,7 @@ public class docParser extends AbstractParser implements Parser { false, extractor.getSummaryInformation().getLastSaveDateTime() // maybe null )}; - + try {extractor.close();} catch (IOException e1) {} return docs; } } diff --git a/source/net/yacy/document/parser/html/CharacterCoding.java b/source/net/yacy/document/parser/html/CharacterCoding.java index 943cd2b4e..62def9c83 100644 --- a/source/net/yacy/document/parser/html/CharacterCoding.java +++ b/source/net/yacy/document/parser/html/CharacterCoding.java @@ -25,14 +25,10 @@ package net.yacy.document.parser.html; import net.yacy.search.Switchboard; -import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -import java.io.BufferedReader; -import java.io.File; import java.io.IOException; -import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; diff --git a/source/net/yacy/document/parser/pptParser.java b/source/net/yacy/document/parser/pptParser.java index 83a4d7221..281b50555 100644 --- a/source/net/yacy/document/parser/pptParser.java +++ b/source/net/yacy/document/parser/pptParser.java @@ -28,6 +28,7 @@ package net.yacy.document.parser; import java.io.BufferedInputStream; +import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -122,6 +123,7 @@ public class pptParser extends AbstractParser implements Parser { false, pptExtractor.getSummaryInformation().getLastSaveDateTime() // may be null )}; + try {pptExtractor.close();} catch (IOException e1) {} return docs; } catch (final Exception e) { if (e instanceof InterruptedException) throw (InterruptedException) e; diff --git a/source/net/yacy/document/parser/vsdParser.java b/source/net/yacy/document/parser/vsdParser.java index 3018c3429..7f195dfe7 100644 --- a/source/net/yacy/document/parser/vsdParser.java +++ b/source/net/yacy/document/parser/vsdParser.java @@ -85,6 +85,7 @@ public class vsdParser extends AbstractParser implements Parser { final VisioTextExtractor extractor = new VisioTextExtractor(source); contents = extractor.getText(); summary = extractor.getSummaryInformation(); + extractor.close(); } catch (final Exception e) { ConcurrentLog.warn("vsdParser", e.getMessage()); } diff --git a/source/net/yacy/document/parser/xlsParser.java b/source/net/yacy/document/parser/xlsParser.java index 2e0e9cb52..5aa104f18 100644 --- a/source/net/yacy/document/parser/xlsParser.java +++ b/source/net/yacy/document/parser/xlsParser.java @@ -117,6 +117,7 @@ public class xlsParser extends AbstractParser implements Parser { false, sumInfo.getLastSaveDateTime())}; + exceldoc.close(); return retdocs; } catch (IOException ex1) { diff --git a/source/net/yacy/htroot/Crawler_p.java b/source/net/yacy/htroot/Crawler_p.java index 490f963b7..6a6ebf55d 100644 --- a/source/net/yacy/htroot/Crawler_p.java +++ b/source/net/yacy/htroot/Crawler_p.java @@ -879,12 +879,15 @@ public class Crawler_p { if((crawlingFileContent == null || crawlingFileContent.isEmpty()) && crawlingFile != null) { /* Let's report here detailed error to help user when he selected a wrong file */ if(!crawlingFile.exists()) { + writer.close(); throw new FileNotFoundException(crawlingFile.getAbsolutePath() + " does not exists"); } if(!crawlingFile.isFile()) { + writer.close(); throw new FileNotFoundException(crawlingFile.getAbsolutePath() + " exists but is not a regular file"); } if(!crawlingFile.canRead()) { + writer.close(); throw new IOException("Can not read : " + crawlingFile.getAbsolutePath()); } } diff --git a/source/net/yacy/htroot/PerformanceQueues_p.java b/source/net/yacy/htroot/PerformanceQueues_p.java index 6b274edce..96fe5ae67 100644 --- a/source/net/yacy/htroot/PerformanceQueues_p.java +++ b/source/net/yacy/htroot/PerformanceQueues_p.java @@ -52,7 +52,8 @@ import net.yacy.server.serverSwitch; public class PerformanceQueues_p { - public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { + @SuppressWarnings("deprecation") + public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) { // return variable that accumulates replacements final Switchboard sb = (Switchboard) env; final serverObjects prop = new serverObjects(); diff --git a/source/net/yacy/htroot/api/ynetSearch.java b/source/net/yacy/htroot/api/ynetSearch.java index 84bd0f507..d9c756d8a 100644 --- a/source/net/yacy/htroot/api/ynetSearch.java +++ b/source/net/yacy/htroot/api/ynetSearch.java @@ -48,7 +48,9 @@ public class ynetSearch { // final String s = searchaddress+"&query="+post.get("search")+"&maximumRecords="+post.get("maximumRecords")+"&startRecord="+post.get("startRecord"); final URL url = new URL(s); is = url.openStream(); - final String httpout = new Scanner(is).useDelimiter( "\\Z" ).next(); + Scanner scanner = new Scanner(is); + final String httpout = scanner.useDelimiter( "\\Z" ).next(); + scanner.close(); prop.put("http", httpout); } catch (final Exception e ) { prop.put("url", "error!"); diff --git a/source/net/yacy/htroot/yacysearchitem.java b/source/net/yacy/htroot/yacysearchitem.java index fafa3959d..9dc1912e1 100644 --- a/source/net/yacy/htroot/yacysearchitem.java +++ b/source/net/yacy/htroot/yacysearchitem.java @@ -111,7 +111,7 @@ public class yacysearchitem { final boolean authenticated = adminAuthenticated || user != null; final boolean extendedSearchRights = adminAuthenticated || (user != null && user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT)); - final boolean bookmarkRights = adminAuthenticated || (user != null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT)); + //final boolean bookmarkRights = adminAuthenticated || (user != null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT)); final int item = post.getInt("item", -1); final RequestHeader.FileType fileType = header.fileType(); diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java index 054f8d905..1fd3d6c26 100644 --- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java +++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java @@ -280,6 +280,7 @@ public class YaCyDefaultServlet extends HttpServlet { if (!hasClass && (resource == null || !resource.exists()) && !pathInContext.contains("..")) { // try to get this in the alternative htDocsPath + if (resource != null) resource.close(); resource = Resource.newResource(new File(this._htDocsPath, pathInContext)); } @@ -1035,7 +1036,8 @@ public class YaCyDefaultServlet extends HttpServlet { submitted.contains("Crawler_p") || submitted.contains("ConfigBasic") || submitted.contains("Load_RSS_p");*/ - final boolean advanced_enabled = + @SuppressWarnings("unused") + final boolean advanced_enabled = crawler_enabled || submitted.contains("IndexImportMediawiki_p") || submitted.contains("CrawlStart"); diff --git a/source/net/yacy/utils/StartFromJava.java b/source/net/yacy/utils/StartFromJava.java index b272b0797..d11690556 100644 --- a/source/net/yacy/utils/StartFromJava.java +++ b/source/net/yacy/utils/StartFromJava.java @@ -47,7 +47,7 @@ public class StartFromJava { } while(!"STOP".equals(s)); run.stop(); - + sc.close(); } catch(Exception ex) { Logger.getLogger(StartFromJava.class.getName()).log(Level.SEVERE, null, ex); } diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index 5277323e0..c4ca1838d 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -195,13 +195,19 @@ public final class yacy { f = new File(dataHome, "DATA/yacy.running"); if (!f.createNewFile()) ConcurrentLog.severe("STARTUP", "WARNING: the file " + f + " can not be created!"); - try { new FileOutputStream(f).write(Integer.toString(OS.getPID()).getBytes()); } catch (final Exception e) { } // write PID + try { + FileOutputStream fos = new FileOutputStream(f); + fos.write(Integer.toString(OS.getPID()).getBytes()); + fos.close(); + } catch (final Exception e) { } // write PID f.deleteOnExit(); FileChannel channel = null; FileLock lock = null; try { - channel = new RandomAccessFile(f,"rw").getChannel(); + RandomAccessFile raf = new RandomAccessFile(f,"rw"); + channel = raf.getChannel(); lock = channel.tryLock(); // lock yacy.running + raf.close(); } catch (final Exception e) { } final String conf = "DATA/SETTINGS/yacy.conf".replace("/", File.separator);