Skip to content

Commit 0609931

Browse files
author
astroshim
committed
update credentialsMap
1 parent 0f503fd commit 0609931

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

zeppelin-interpreter/src/main/java/org/apache/zeppelin/user/Credentials.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.slf4j.LoggerFactory;
2525

2626
import java.io.*;
27+
import java.util.HashMap;
2728
import java.util.Map;
2829
import java.util.concurrent.ConcurrentHashMap;
2930

@@ -33,7 +34,8 @@
3334
public class Credentials {
3435
private static final Logger LOG = LoggerFactory.getLogger(Credentials.class);
3536

36-
private Map<String, UserCredentials> credentialsMap = new ConcurrentHashMap<>();;
37+
//private Map<String, UserCredentials> credentialsMap = new ConcurrentHashMap<>();
38+
private Map<String, UserCredentials> credentialsMap;
3739
private Gson gson;
3840
private Boolean credentialsPersist = true;
3941
File credentialsFile;
@@ -43,6 +45,8 @@ public Credentials(Boolean credentialsPersist, String credentialsPath) {
4345
if (credentialsPath != null) {
4446
credentialsFile = new File(credentialsPath);
4547
}
48+
credentialsMap = new HashMap<>();
49+
4650
if (credentialsPersist) {
4751
GsonBuilder builder = new GsonBuilder();
4852
builder.setPrettyPrinting();
@@ -119,9 +123,11 @@ private void loadFromFile() {
119123
private void saveToFile() throws IOException {
120124
String jsonString;
121125

122-
CredentialsInfoSaving info = new CredentialsInfoSaving();
123-
info.credentialsMap = credentialsMap;
124-
jsonString = gson.toJson(info);
126+
synchronized (credentialsMap) {
127+
CredentialsInfoSaving info = new CredentialsInfoSaving();
128+
info.credentialsMap = credentialsMap;
129+
jsonString = gson.toJson(info);
130+
}
125131

126132
try {
127133
if (!credentialsFile.exists()) {

0 commit comments

Comments
 (0)