Permalink
Browse files

Close MongoDB connections when appender is closed

  • Loading branch information...
1 parent 36b541a commit bcb9f98ab87224cb6df79e12ba147c816113971e @RobertStewart committed Oct 12, 2010
Showing with 8 additions and 5 deletions.
  1. +4 −3 MAINTAINERS
  2. +4 −2 src/main/java/com/google/code/log4mongo/MongoDbAppender.java
View
@@ -1,7 +1,8 @@
+Robert Stewart
+E-mail: robert@wombatnation.com
+Userid: RobertStewart
+
Peter Monks
E-mail: pmonks@gmail.com
Userid: pmonks
-Robert Stewart
-E-mail: robert@wombatnation.com
-Userid: RobertStewart
@@ -52,6 +52,7 @@
private String userName = null;
private String password = null;
+ private Mongo mongo = null;
private DBCollection collection = null;
/**
@@ -70,8 +71,8 @@ public void activateOptions()
{
try
{
- Mongo mongo = new Mongo(hostname, port);
- DB database = mongo.getDB(databaseName);
+ mongo = new Mongo(hostname, port);
+ DB database = mongo.getDB(databaseName);
if (userName != null && userName.trim().length() > 0)
{
@@ -112,6 +113,7 @@ public void setCollection(final DBCollection collection)
public void close()
{
collection = null;
+ mongo.close();
}
/**

0 comments on commit bcb9f98

Please sign in to comment.