removed warnings

This commit is contained in:
Michael Christen 2022-10-04 22:05:32 +02:00
parent 7bf5f6c7ad
commit 867f96a32b
22 changed files with 57 additions and 24 deletions

View File

@ -2553,8 +2553,14 @@ public class MultiProtocolURL implements Serializable, Comparable<MultiProtocolU
}
public byte[] get(final ClientIdentification.Agent agent, final String username, final String pass) throws IOException {
if (isFile()) return read(new FileInputStream(getFSFile()));
if (isSMB()) return read(new SmbFileInputStream(getSmbFile()));
if (isFile()) {
byte[] b = read(new FileInputStream(getFSFile()));
return b;
}
if (isSMB()) {
byte[] b = read(new SmbFileInputStream(getSmbFile()));
return b;
}
if (isFTP()) {
final FTPClient client = new FTPClient();
client.open(this.host, this.port < 0 ? 21 : this.port);

View File

@ -94,6 +94,7 @@ public class GeonamesLocation implements Locations {
final ZipEntry ze = zf.getEntry(entryName);
final InputStream is = zf.getInputStream(ze);
reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
zf.close();
} catch (final IOException e ) {
log.warn(e);
return;

View File

@ -25,8 +25,8 @@
package net.yacy.cora.plugin;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@ -47,11 +47,12 @@ public class ClassProvider {
URL[] urls;
try {
urls = new URL[]{new URL("file", "", path)};
final ClassLoader cl = new URLClassLoader(urls);
final URLClassLoader cl = new URLClassLoader(urls);
c = cl.loadClass(classname);
} catch (final MalformedURLException e) {
} catch (final ClassNotFoundException e) {
}
cl.close();
} catch (ClassNotFoundException | IOException e) {
e.printStackTrace();
}
}
return c;
}

View File

@ -135,6 +135,7 @@ public class TimeoutRequest<E> {
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();

View File

@ -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();
}
}

View File

@ -138,5 +138,6 @@ public class ZIPReader extends AbstractMap<String, ZipEntry> implements Map<Stri
}
}
}
zfile.close();
}
}

View File

@ -282,6 +282,7 @@ public class LibraryProvider {
try {
final ZipFile zip = new ZipFile(file);
derewoTxtEntry = zip.getInputStream(zip.getEntry("derewo-v-100000t-2009-04-30-0.1"));
zip.close();
} catch (final ZipException e ) {
ConcurrentLog.logException(e);
return list;

View File

@ -153,7 +153,8 @@ public class MediawikiImporter extends Thread implements Importer {
return (System.currentTimeMillis() - this.start) / 1000L;
}
@Override
@SuppressWarnings("resource")
@Override
public void run() {
this.start = System.currentTimeMillis();
final int threads = Math.max(2, Runtime.getRuntime().availableProcessors() - 1);

View File

@ -108,7 +108,8 @@ public class WarcImporter extends Thread implements Importer {
* @param f inputstream for the warc file
* @throws IOException
*/
public void indexWarcRecords(InputStream f) throws IOException {
@SuppressWarnings("resource")
public void indexWarcRecords(InputStream f) throws IOException {
byte[] content;
job = this;
@ -146,6 +147,7 @@ public class WarcImporter extends Thread implements Importer {
bbuffer.append(c);
}
content = bbuffer.getBytes();
bbuffer.close();
} else {
content = new byte[(int) http.getPayloadLength()];
istream.read(content, 0, content.length);

View File

@ -478,6 +478,7 @@ public class apkParser extends AbstractParser implements Parser {
for (String s: resources) {
System.out.println(s);
}
jf.close();
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -27,6 +27,7 @@
package net.yacy.document.parser;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
@ -87,6 +88,7 @@ public class docParser extends AbstractParser implements Parser {
try {
contents.append(extractor.getText()); // extractor gets all text incl. headers/footers
} 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();
@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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());
}

View File

@ -117,6 +117,7 @@ public class xlsParser extends AbstractParser implements Parser {
false,
sumInfo.getLastSaveDateTime())};
exceldoc.close();
return retdocs;
} catch (IOException ex1) {

View File

@ -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());
}
}

View File

@ -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();

View File

@ -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!");

View File

@ -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();

View File

@ -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");

View File

@ -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);
}

View File

@ -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);