Memory import fix: prevent MySQL connection time out waiting for the corpus to be imported
@@ -217,14 +217,17 @@ public class MemoryFacade {
Connection connection = null;
Database db = ModernMT.getNode().getDatabase();
+ Memory memory;
try {
connection = db.getConnection();
MemoryDAO memoryDAO = db.getMemoryDAO(connection);
- Memory memory = memoryDAO.retrieve(memoryId);
+ memory = memoryDAO.retrieve(memoryId);
- if (memory == null)
- return null;
+ if (memory == null) return null;
+ } finally {
+ IOUtils.closeQuietly(connection);
+ }
corpus = CorporaCleaning.wrap(corpus, CorporaCleaning.Options.defaultOptionsForMemoryImport());
@@ -234,6 +237,8 @@ public class MemoryFacade {
if (job == null)
throw new EmptyCorpusException();
+ try {
+ connection = db.getConnection();
ImportJobDAO jobDAO = db.getImportJobDAO(connection);
job = jobDAO.store(job);
