Skip to content

Commit

Permalink
OAK-11233: Don't apply MongoDockerRule if the Mongo Docker image isn'…
Browse files Browse the repository at this point in the history
…t actually used. (apache#1837)

Implemented.
  • Loading branch information
mbaedke authored Nov 5, 2024
1 parent e0b0bd0 commit 02e77a1
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ public class MongoConnectionFactory extends ExternalResource {
@Override
public Statement apply(Statement base, Description description) {
Statement s = super.apply(base, description);
if (MongoDockerRule.isDockerAvailable()) {
MongoConnection c = null;
try {
c = MongoUtils.getConnection(MongoUtils.DB);
} finally {
try {
if (c != null) {
c.close();
}
} catch (IllegalStateException e) {
// may happen when connection is already closed (OAK-7447)
}
}
if (c == null && MongoDockerRule.isDockerAvailable()) {
s = mongo.apply(s, description);
}
return s;
Expand Down

0 comments on commit 02e77a1

Please sign in to comment.