8000 Fix memory leak by dr0i · Pull Request #667 · metafacture/metafacture-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix memory leak #667

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.shared.PropertyNotFoundException;

import java.io.Closeable;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
Expand All @@ -56,7 +57,7 @@
*
* @see org.metafacture.metamorph.maps.FileMap
*/
public final class RdfMap extends AbstractReadOnlyMap<String, String> {
public final class RdfMap extends AbstractReadOnlyMap<String, String> implements Closeable {

public static final String SELECT = "select";
public static final String TARGET = "target";
Expand Down Expand Up @@ -394,6 +395,12 @@ private String read(final String url) throws IOException {
return conn.getURL().toString();
}

@Override
public void close() {
map.clear();
model.close();
}

private enum Select {
SUBJECT, OBJECT, DEFAULT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.metafacture.metamorph.api.helpers.AbstractReadOnlyMap;

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
Expand Down Expand Up @@ -60,7 +61,7 @@
*
* @author Markus Michael Geipel
*/
public final class FileMap extends AbstractReadOnlyMap<String, String> {
public final class FileMap extends AbstractReadOnlyMap<String, String> implements Closeable {

private final FileOpener fileOpener = new FileOpener();
private final Map<String, String> map = new HashMap<>();
Expand Down Expand Up @@ -290,4 +291,9 @@ public Set<String> keySet() {
return Collections.unmodifiableSet(map.keySet());
}

@Override
public void close() throws IOException {
map.clear();
fileOpener.closeStream();
}
}
0