Index: log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/NoSqlDatabaseManagerTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/NoSqlDatabaseManagerTest.java	(date 1407418017000)
+++ log4j-nosql/src/test/java/org/apache/logging/log4j/nosql/appender/NoSqlDatabaseManagerTest.java	(revision )
@@ -117,7 +117,7 @@
         try {
             replay(this.provider, this.connection);
 
-            manager.startup();
+            manager.start();
 
             verify(this.provider, this.connection);
             reset(this.provider, this.connection);
@@ -155,7 +155,7 @@
         try {
             replay(this.provider, this.connection);
 
-            manager.startup();
+            manager.start();
 
             verify(this.provider, this.connection);
             reset(this.provider, this.connection);
@@ -242,7 +242,7 @@
         try {
             replay(this.provider, this.connection);
 
-            manager.startup();
+            manager.start();
 
             verify(this.provider, this.connection);
             reset(this.provider, this.connection);
@@ -377,7 +377,7 @@
         try {
             replay(this.provider, this.connection);
 
-            manager.startup();
+            manager.start();
 
             verify(this.provider, this.connection);
             reset(this.provider, this.connection);
Index: log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java	(date 1407418017000)
+++ log4j-core/src/test/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManagerTest.java	(revision )
@@ -47,7 +47,7 @@
         replay(this.manager);
 
         assertEquals("The name is not correct.", "testName01", this.manager.getName());
-        assertFalse("The manager should not have started.", this.manager.isRunning());
+        assertFalse("The manager should not have started.", this.manager.isStarted());
 
         verify(this.manager);
         reset(this.manager);
@@ -55,8 +55,8 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.startup();
-        assertTrue("The manager should be running now.", this.manager.isRunning());
+        this.manager.start();
+        assertTrue("The manager should be running now.", this.manager.isStarted());
 
         verify(this.manager);
         reset(this.manager);
@@ -64,8 +64,8 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.shutdown();
-        assertFalse("The manager should not be running anymore.", this.manager.isRunning());
+        this.manager.stop();
+        assertFalse("The manager should not be running anymore.", this.manager.isStarted());
     }
 
     @Test
@@ -75,7 +75,7 @@
         replay(this.manager);
 
         assertEquals("The name is not correct.", "anotherName02", this.manager.getName());
-        assertFalse("The manager should not have started.", this.manager.isRunning());
+        assertFalse("The manager should not have started.", this.manager.isStarted());
 
         verify(this.manager);
         reset(this.manager);
@@ -83,8 +83,8 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.startup();
-        assertTrue("The manager should be running now.", this.manager.isRunning());
+        this.manager.start();
+        assertTrue("The manager should be running now.", this.manager.isStarted());
 
         verify(this.manager);
         reset(this.manager);
@@ -93,7 +93,7 @@
         replay(this.manager);
 
         this.manager.releaseSub();
-        assertFalse("The manager should not be running anymore.", this.manager.isRunning());
+        assertFalse("The manager should not be running anymore.", this.manager.isStarted());
     }
 
     @Test
@@ -126,7 +126,7 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.startup();
+        this.manager.start();
 
         verify(this.manager);
         reset(this.manager);
@@ -178,7 +178,7 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.startup();
+        this.manager.start();
 
         this.manager.write(event1);
         this.manager.write(event2);
@@ -215,7 +215,7 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.startup();
+        this.manager.start();
 
         this.manager.write(event1);
         this.manager.write(event2);
@@ -250,7 +250,7 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.startup();
+        this.manager.start();
 
         this.manager.write(event1);
         this.manager.write(event2);
@@ -272,6 +272,6 @@
         expectLastCall();
         replay(this.manager);
 
-        this.manager.shutdown();
+        this.manager.stop();
     }
 }
Index: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java	(date 1407418017000)
+++ log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java	(revision )
@@ -86,7 +86,7 @@
     protected void writeInternal(final LogEvent event) {
         StringReader reader = null;
         try {
-            if (!this.isRunning() || this.connection == null || this.connection.isClosed() || this.statement == null
+            if (!this.isStarted() || this.connection == null || this.connection.isClosed() || this.statement == null
                     || this.statement.isClosed()) {
                 throw new AppenderLoggingException(
                         "Cannot write logging event; JDBC manager not connected to the database.");
Index: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java	(date 1407418017000)
+++ log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseManager.java	(revision )
@@ -17,7 +17,9 @@
 package org.apache.logging.log4j.core.appender.db;
 
 import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.logging.log4j.core.LifeCycle;
 import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.appender.AbstractManager;
 import org.apache.logging.log4j.core.appender.ManagerFactory;
@@ -25,11 +27,12 @@
 /**
  * Manager that allows database appenders to have their configuration reloaded without losing events.
  */
-public abstract class AbstractDatabaseManager extends AbstractManager {
+public abstract class AbstractDatabaseManager extends AbstractManager implements LifeCycle {
+    // @GuardedBy("this")
     private final ArrayList<LogEvent> buffer;
     private final int bufferSize;
 
-    private boolean running = false;
+    private final AtomicReference<State> state = new AtomicReference<State>(State.INITIALIZED);
 
     /**
      * Instantiates the base manager.
@@ -56,14 +59,18 @@
      * This method is called within the appender when the appender is started. If it has not already been called, it
      * calls {@link #startupInternal()} and catches any exceptions it might throw.
      */
-    public final synchronized void startup() {
-        if (!this.isRunning()) {
+    @Override
+    public final void start() {
+        if (this.state.compareAndSet(State.INITIALIZED, State.STARTING)
+            || this.state.compareAndSet(State.STOPPED, State.STARTING)) {
             try {
                 this.startupInternal();
-                this.running = true;
+                this.state.set(State.STARTED);
             } catch (final Exception e) {
                 LOGGER.error("Could not perform database startup operations using logging manager [{}].",
                         this.getName(), e);
+                // FIXME: should this go to STOPPED, INITIALIZED, or add a new State type?
+                this.state.set(State.STOPPED);
             }
         }
     }
@@ -81,30 +88,37 @@
      * is replaced. If it has not already been called, it calls {@link #shutdownInternal()} and catches any exceptions
      * it might throw.
      */
-    public final synchronized void shutdown() {
+    @Override
+    public final void stop() {
         this.flush();
-        if (this.isRunning()) {
+        if (this.state.compareAndSet(State.STARTED, State.STOPPING)) {
             try {
                 this.shutdownInternal();
             } catch (final Exception e) {
                 LOGGER.warn("Error while performing database shutdown operations using logging manager [{}].",
                         this.getName(), e);
             } finally {
-                this.running = false;
+                this.state.set(State.STOPPED);
             }
         }
     }
 
     /**
-     * Indicates whether the manager is currently connected {@link #startup()} has been called and {@link #shutdown()}
+     * Indicates whether the manager is currently connected {@link #start()} has been called and {@link #stop()}
      * has not been called).
      *
      * @return {@code true} if the manager is connected.
      */
-    public final boolean isRunning() {
-        return this.running;
+    @Override
+    public final boolean isStarted() {
+        return this.state.get() == State.STARTED;
     }
 
+    @Override
+    public boolean isStopped() {
+        return this.state.get() == State.STOPPED;
+    }
+
     /**
      * Connects to the database and starts a transaction (if applicable). With buffering enabled, this is called when
      * flushing the buffer begins, before the first call to {@link #writeInternal}. With buffering disabled, this is
@@ -130,10 +144,10 @@
 
     /**
      * This method is called automatically when the buffer size reaches its maximum or at the beginning of a call to
-     * {@link #shutdown()}. It can also be called manually to flush events to the database.
+     * {@link #stop()}. It can also be called manually to flush events to the database.
      */
     public final synchronized void flush() {
-        if (this.isRunning() && this.buffer.size() > 0) {
+        if (this.isStarted() && this.buffer.size() > 0) {
             this.connectAndStart();
             try {
                 for (final LogEvent event : this.buffer) {
@@ -170,7 +184,7 @@
 
     @Override
     public final void releaseSub() {
-        this.shutdown();
+        this.stop();
     }
 
     @Override
Index: log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/NoSqlDatabaseManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/NoSqlDatabaseManager.java	(date 1407418017000)
+++ log4j-nosql/src/main/java/org/apache/logging/log4j/nosql/appender/NoSqlDatabaseManager.java	(revision )
@@ -66,7 +66,7 @@
 
     @Override
     protected void writeInternal(final LogEvent event) {
-        if (!this.isRunning() || this.connection == null || this.connection.isClosed()) {
+        if (!this.isStarted() || this.connection == null || this.connection.isClosed()) {
             throw new AppenderLoggingException(
                     "Cannot write logging event; NoSQL manager not connected to the database.");
         }
@@ -144,6 +144,7 @@
 
         final Marker[] parents = marker.getParents();
         if (parents != null) {
+            // TODO: this should be allowed to use List instead of an array (Mongo supports it at least)
             @SuppressWarnings("unchecked")
             final NoSqlObject<W>[] parentEntities = new NoSqlObject[parents.length];
             for (int i = 0; i < parents.length; i++) {
Index: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppender.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppender.java	(date 1407418017000)
+++ log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/AbstractDatabaseAppender.java	(revision )
@@ -84,7 +84,7 @@
         }
         super.start();
         if (this.getManager() != null) {
-            this.getManager().startup();
+            this.getManager().start();
         }
     }
 
@@ -125,8 +125,8 @@
         this.writeLock.lock();
         try {
             final T old = this.getManager();
-            if (!manager.isRunning()) {
-                manager.startup();
+            if (!manager.isStarted()) {
+                manager.start();
             }
             this.manager = manager;
             old.release();
Index: log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JpaDatabaseManager.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JpaDatabaseManager.java	(date 1407418017000)
+++ log4j-core/src/main/java/org/apache/logging/log4j/core/appender/db/jpa/JpaDatabaseManager.java	(revision )
@@ -83,7 +83,7 @@
 
     @Override
     protected void writeInternal(final LogEvent event) {
-        if (!this.isRunning() || this.entityManagerFactory == null || this.entityManager == null
+        if (!this.isStarted() || this.entityManagerFactory == null || this.entityManager == null
                 || this.transaction == null) {
             throw new AppenderLoggingException(
                     "Cannot write logging event; JPA manager not connected to the database.");
