Skip to content

Commit 1cbb059

Browse files
author
Vladimir Kotal
authored
revise auth framework locking in RuntimeEnvironment (#2934)
fixes #2932
1 parent 71b3793 commit 1cbb059

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ private RuntimeEnvironment() {
131131
lzSearchExecutor = LazilyInstantiate.using(() -> newSearchExecutor());
132132
}
133133

134-
/** Instance of authorization framework.*/
134+
// Instance of authorization framework and its lock.
135135
private AuthorizationFramework authFramework;
136+
private final Object authFrameworkLock = new Object();
136137

137138
/** Gets the thread pool used for multi-project searches. */
138139
public ExecutorService getSearchExecutor() {
@@ -1593,11 +1594,13 @@ public void setStatisticsFilePath(String path) {
15931594
*
15941595
* @return the framework
15951596
*/
1596-
public synchronized AuthorizationFramework getAuthorizationFramework() {
1597-
if (authFramework == null) {
1598-
authFramework = new AuthorizationFramework(getPluginDirectory(), getPluginStack());
1597+
public AuthorizationFramework getAuthorizationFramework() {
1598+
synchronized (authFrameworkLock) {
1599+
if (authFramework == null) {
1600+
authFramework = new AuthorizationFramework(getPluginDirectory(), getPluginStack());
1601+
}
1602+
return authFramework;
15991603
}
1600-
return authFramework;
16011604
}
16021605

16031606
/**
@@ -1606,11 +1609,13 @@ public synchronized AuthorizationFramework getAuthorizationFramework() {
16061609
*
16071610
* @param fw the new framework
16081611
*/
1609-
public synchronized void setAuthorizationFramework(AuthorizationFramework fw) {
1610-
if (this.authFramework != null) {
1611-
this.authFramework.removeAll();
1612+
public void setAuthorizationFramework(AuthorizationFramework fw) {
1613+
synchronized (authFrameworkLock) {
1614+
if (this.authFramework != null) {
1615+
this.authFramework.removeAll();
1616+
}
1617+
this.authFramework = fw;
16121618
}
1613-
this.authFramework = fw;
16141619
}
16151620

16161621
/**

0 commit comments

Comments
 (0)