File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
src/main/java/org/audit4j/core Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 27
27
28
28
/**
29
29
* The AuditManager. This class is used to submit audit events as well as
30
- * annotations. This is the only audit submition end point of the Audit4j.
30
+ * annotations. This is the only audit submission end point of the Audit4j.
31
31
*
32
32
* @author <a href="mailto:[email protected] ">Janith Bandara</a>
33
33
*
@@ -42,7 +42,7 @@ private AuditManager() {
42
42
}
43
43
44
44
/** The audit manager. */
45
- private static AuditManager auditManager ;
45
+ private static volatile AuditManager auditManager ;
46
46
47
47
/**
48
48
* Audit.
@@ -98,13 +98,17 @@ public boolean audit(AnnotationAuditEvent annotationEvent) {
98
98
* @return single instance of AuditHelper
99
99
*/
100
100
public static AuditManager getInstance () {
101
- synchronized (AuditManager .class ) {
102
- if (auditManager == null ) {
103
- Context .init ();
104
- auditManager = new AuditManager ();
101
+ AuditManager result = auditManager ;
102
+ if (result == null ) {
103
+ synchronized (AuditManager .class ) {
104
+ result = auditManager ;
105
+ if (result == null ) {
106
+ Context .init ();
107
+ auditManager = result = new AuditManager ();
108
+ }
105
109
}
106
110
}
107
- return auditManager ;
111
+ return result ;
108
112
}
109
113
110
114
/**
You can’t perform that action at this time.
0 commit comments