Skip to content

Commit

Permalink
Merge pull request #99 from nitin-ebi/internalservererror
Browse files Browse the repository at this point in the history
EVA-2911 - Handle exception when trying to disconnect
  • Loading branch information
nitin-ebi authored Jun 30, 2022
2 parents 3a5c3c8 + e0a1512 commit eeaa806
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import uk.ac.ebi.eva.contigalias.entities.ChromosomeEntity;
import uk.ac.ebi.eva.contigalias.entities.ScaffoldEntity;
import uk.ac.ebi.eva.contigalias.entities.SequenceEntity;
import uk.ac.ebi.eva.contigalias.service.AssemblyService;

import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -70,7 +69,11 @@ public Optional<AssemblyEntity> getAssemblyByAccession(String accession) throws
ENAAssemblyReportReader reader = readerFactory.build(stream);
assemblyEntity = reader.getAssemblyEntity();
} finally {
enaBrowser.disconnect();
try {
enaBrowser.disconnect();
} catch (IOException e){
logger.warn("Error while trying to disconnect - enaBrowser (assembly: " + accession + ") : " + e);
}
}
return Optional.of(assemblyEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package uk.ac.ebi.eva.contigalias.datasource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

Expand All @@ -32,6 +34,8 @@
@Repository("NCBIDataSource")
public class NCBIAssemblyDataSource implements AssemblyDataSource {

private final Logger logger = LoggerFactory.getLogger(NCBIAssemblyDataSource.class);

private final NCBIBrowserFactory factory;

private final NCBIAssemblyReportReaderFactory readerFactory;
Expand All @@ -57,7 +61,11 @@ public Optional<AssemblyEntity> getAssemblyByAccession(
NCBIAssemblyReportReader reader = readerFactory.build(stream);
assemblyEntity = reader.getAssemblyEntity();
} finally {
ncbiBrowser.disconnect();
try {
ncbiBrowser.disconnect();
} catch (IOException e) {
logger.warn("Error while trying to disconnect - ncbiBrowser (assembly: " + accession + ") : " + e);
}
}
return Optional.of(assemblyEntity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public void connect(String address, int port) throws IOException {
logger.info("Connected successfully to {}", address);
} catch (Exception e) {
logger.error("Could not connect to FTP server '{}'. {}.", address, getStatusString());
this.disconnect();
try {
this.disconnect();
} catch (IOException ex) {
logger.warn("Error while trying to disconnect : " + ex);
}
throw e;
}
}
Expand Down

0 comments on commit eeaa806

Please sign in to comment.