AAF-892- move the variable to follow rules
[aaf/authz.git] / cadi / core / src / main / java / org / onap / aaf / cadi / PropAccess.java
index 4737880..6e11c3c 100644 (file)
@@ -3,6 +3,8 @@
  * org.onap.aaf
  * ===========================================================================
  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * 
+ * Modifications Copyright (C) 2018 IBM.
  * ===========================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,11 +44,16 @@ import org.onap.aaf.cadi.util.Split;
 
 public class PropAccess implements Access {
     // Sonar says cannot be static... it's ok.  not too many PropAccesses created.
-    private final static SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+    private final SimpleDateFormat iso8601 = newISO8601();
+    private Symm symm;
+               
+    public static SimpleDateFormat newISO8601() {
+       return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
+    }
 
     public static final Level DEFAULT = Level.AUDIT;
     
-    private Symm symm;
+    
     private int level;
     private Properties props;
     private List<String> recursionProtection = null;
@@ -104,7 +111,6 @@ public class PropAccess implements Access {
     protected synchronized void init(Properties p) {
         // Make sure these two are set before any changes in Logging
         name = "cadi";
-        level=DEFAULT.maskOf();
         
         props = new Properties();
         // First, load related System Properties
@@ -123,16 +129,14 @@ public class PropAccess implements Access {
         
         // Preset LogLevel
         String sLevel = props.getProperty(Config.CADI_LOGLEVEL); 
-        if (sLevel!=null) {
-            level=Level.valueOf(sLevel).maskOf(); 
-        }
-        
         // Third, load any Chained Property Files
         load(props.getProperty(Config.CADI_PROP_FILES));
         
         if(sLevel==null) { // if LogLev wasn't set before, check again after Chained Load
                sLevel = props.getProperty(Config.CADI_LOGLEVEL); 
-               if (sLevel!=null) {
+               if (sLevel==null) {
+                       level=DEFAULT.maskOf();
+               } else {
                    level=Level.valueOf(sLevel).maskOf(); 
                }
         }
@@ -258,14 +262,13 @@ public class PropAccess implements Access {
         }
     }
 
-    protected StringBuilder buildMsg(Level level, Object[] elements) {
+    public StringBuilder buildMsg(Level level, Object[] elements) {
         return buildMsg(name,iso8601,level,elements);
     }
-
-    public static StringBuilder buildMsg(final String name, Level level, Object[] elements) {
-       return buildMsg(name,iso8601,level,elements);
-    }
     
+    /*
+     * Need to pass in DateFormat per thread, because not marked as thread safe
+     */
     public static StringBuilder buildMsg(final String name, final DateFormat sdf, Level level, Object[] elements) {
        final StringBuilder sb;
         int end = elements.length;