[logback-dev] svn commit: r1910 - logback/trunk/logback-core/src/main/java/ch/qos/logback/core

noreply.ceki at qos.ch noreply.ceki at qos.ch
Wed Oct 29 20:07:39 CET 2008


Author: ceki
Date: Wed Oct 29 20:07:39 2008
New Revision: 1910

Modified:
   logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java

Log:
LBCORE-35

Added a setter for the StatusManager.

Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java	(original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java	Wed Oct 29 20:07:39 2008
@@ -17,17 +17,36 @@
 public class ContextBase implements Context {
 
   private String name;
-  StatusManager sm = new BasicStatusManager();
+  private StatusManager sm = new BasicStatusManager();
   // TODO propertyMap should be observable so that we can be notified
   // when it changes so that a new instance of propertyMap can be
   // serialized. For the time being, we ignore this shortcoming.
   Map<String, String> propertyMap = new HashMap<String, String>();
   Map<String, Object> objectMap = new HashMap<String, Object>();
-  
+
   public StatusManager getStatusManager() {
     return sm;
   }
 
+  /**
+   * Set the {@link StatusManager} for this context. Note that by default this
+   * context is initialized with a {@link BasicStatusManager}. A null value for
+   * the 'statusManager' argument is not allowed.
+   * 
+   * <p>
+   * A malicious attacker can set the status manager to a dummy instance,
+   * disabling internal error reporting.
+   * 
+   * @param statusManager
+   *                the new status manager
+   */
+  public void setStatusManager(StatusManager statusManager) {
+    if (sm == null) {
+      throw new IllegalArgumentException("null StatusManager not allowed");
+    }
+    this.sm = statusManager;
+  }
+
   public Map<String, String> getCopyOfPropertyMap() {
     return new HashMap<String, String>(propertyMap);
   }
@@ -48,7 +67,6 @@
     objectMap.put(key, value);
   }
 
-  
   public String getName() {
     return name;
   }


More information about the logback-dev mailing list