From cc72cb6668ac0b81acff97793d5f340060a10074 Mon Sep 17 00:00:00 2001
From: Raman Arora <raman@basistech.com>
Date: Wed, 7 Apr 2021 00:14:50 -0400
Subject: [PATCH] 4274: OsAccount thread safety  - made getters/setters
 synchronized.

---
 bindings/java/src/org/sleuthkit/datamodel/OsAccount.java | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
index a2c77045c..4652057d5 100644
--- a/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
+++ b/bindings/java/src/org/sleuthkit/datamodel/OsAccount.java
@@ -20,10 +20,8 @@
 
 import java.util.Collections;
 import java.util.List;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.ResourceBundle;
-import org.apache.commons.lang3.StringUtils;
 
 /**
  * Abstracts an OS user account. OS Accounts have a scope, which is defined by
@@ -246,7 +244,7 @@ public static OsAccountType fromID(int typeId) {
 	 *
 	 * @param osAccountAttribute The osAccount Attribute that is to be added.
 	 */
-	void setAttributesInternal(List<OsAccountAttribute> osAccountAttributes) {
+	synchronized void  setAttributesInternal(List<OsAccountAttribute> osAccountAttributes) {
 		this.osAccountAttributes = osAccountAttributes;
 	}
 
@@ -350,7 +348,7 @@ public OsAccountDbStatus getOsAccountDbStatus() {
 	 *
 	 * @throws TskCoreException
 	 */
-	public List<OsAccountAttribute> getExtendedOsAccountAttributes() throws TskCoreException {
+	public synchronized List<OsAccountAttribute> getExtendedOsAccountAttributes() throws TskCoreException {
 		if (osAccountAttributes == null) {
 			osAccountAttributes = sleuthkitCase.getOsAccountManager().getOsAccountAttributes(this);
 		}
@@ -364,7 +362,7 @@ public List<OsAccountAttribute> getExtendedOsAccountAttributes() throws TskCoreE
 	 *
 	 * @throws TskCoreException
 	 */
-	public List<OsAccountInstance> getOsAccountInstances() throws TskCoreException {
+	public synchronized List<OsAccountInstance> getOsAccountInstances() throws TskCoreException {
 		if (osAccountInstances == null) {
 			osAccountInstances = sleuthkitCase.getOsAccountManager().getOsAccountInstances(this);
 		}
-- 
GitLab