Commit 900f094d authored by Raphaël OUAZANA's avatar Raphaël OUAZANA
Browse files

Force connection to be closed, even if GC is not called (references #695)

parent 58cb22f9
......@@ -113,6 +113,13 @@ public class SimpleSynchronize extends AbstractSynchronize {
LOGGER.error("Error while closing service.");
}
}
if (task.getDestinationService() instanceof Closeable) {
try {
((Closeable)task.getDestinationService()).close();
} catch (IOException e) {
LOGGER.error("Error while closing service.");
}
}
}
}
......
......@@ -45,6 +45,7 @@
*/
package org.lsc.jndi;
import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -79,7 +80,7 @@ import org.slf4j.LoggerFactory;
*
* @author Sebastien Bahloul <seb@lsc-project.org>
*/
public abstract class AbstractSimpleJndiService {
public abstract class AbstractSimpleJndiService implements Closeable {
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSimpleJndiService.class);
/**
......@@ -256,6 +257,14 @@ public abstract class AbstractSimpleJndiService {
return getJndiServices().getEntry(baseDn, searchString, _filteredSc);
}
public void close() throws IOException {
try {
jndiServices.finalize();
} catch (Throwable e) {
throw new IOException(e);
}
}
/**
* LDAP Services getter to fit to the context - source or destination.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment