You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2015/09/24 08:23:07 UTC

logging-log4j2 git commit: MongoDB docs say: @deprecated There should be no reason to use this method. The error message will be in the exception thrown for an unsuccessful write operation.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master 4de79c35d -> 9e3304738


MongoDB docs say: @deprecated There should be no reason to use this
method.  The error message will be in the exception thrown for an
unsuccessful write operation.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/9e330473
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/9e330473
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/9e330473

Branch: refs/heads/master
Commit: 9e3304738e62b1621b1df6497c0d99e14a2568bc
Parents: 4de79c3
Author: ggregory <gg...@apache.org>
Authored: Wed Sep 23 23:23:04 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Wed Sep 23 23:23:04 2015 -0700

----------------------------------------------------------------------
 .../appender/mongodb/MongoDbConnection.java     | 33 +++++++++++---------
 1 file changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/9e330473/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java
----------------------------------------------------------------------
diff --git a/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java b/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java
index 9703972..1b1f3ee 100644
--- a/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java
+++ b/log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/mongodb/MongoDbConnection.java
@@ -76,11 +76,7 @@ public final class MongoDbConnection implements NoSqlConnection<BasicDBObject, M
     @Override
     public void insertObject(final NoSqlObject<BasicDBObject> object) {
         try {
-            final WriteResult result = this.collection.insert(object.unwrap(), this.writeConcern);
-            if (Strings.isNotEmpty(result.getError())) {
-                throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " +
-                        result.getError() + '.');
-            }
+            this.collection.insert(object.unwrap(), this.writeConcern);
         } catch (final MongoException e) {
             throw new AppenderLoggingException("Failed to write log event to MongoDB due to error: " + e.getMessage(),
                     e);
@@ -89,7 +85,8 @@ public final class MongoDbConnection implements NoSqlConnection<BasicDBObject, M
 
     @Override
     public void close() {
-        // there's no need to call this.mongo.close() since that literally closes the connection
+        // there's no need to call this.mongo.close() since that literally
+        // closes the connection
         // MongoDBClient uses internal connection pooling
         // for more details, see LOG4J2-591
     }
@@ -100,16 +97,22 @@ public final class MongoDbConnection implements NoSqlConnection<BasicDBObject, M
     }
 
     /**
-     * To prevent class loading issues during plugin discovery, this code cannot live within MongoDbProvider. This
-     * is because of how Java treats references to Exception classes different from references to other classes. When
-     * Java loads a class, it normally won't load that class's dependent classes until and unless A) they are used, B)
-     * the class being loaded extends or implements those classes, or C) those classes are the types of static members
-     * in the class. However, exceptions that a class uses are always loaded when the class is loaded, even before
-     * they are actually used.
+     * To prevent class loading issues during plugin discovery, this code cannot
+     * live within MongoDbProvider. This is because of how Java treats
+     * references to Exception classes different from references to other
+     * classes. When Java loads a class, it normally won't load that class's
+     * dependent classes until and unless A) they are used, B) the class being
+     * loaded extends or implements those classes, or C) those classes are the
+     * types of static members in the class. However, exceptions that a class
+     * uses are always loaded when the class is loaded, even before they are
+     * actually used.
      *
-     * @param database The database to authenticate
-     * @param userName The username to authenticate with
-     * @param password The password to authenticate with
+     * @param database
+     *            The database to authenticate
+     * @param userName
+     *            The username to authenticate with
+     * @param password
+     *            The password to authenticate with
      */
     static void authenticate(final DB database, final String userName, final String password) {
         try {