Skip to content

Commit f92514e

Browse files
authored
no need to lock configuration for ctags validation (#4646)
fixes #4645
1 parent ced8af1 commit f92514e

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.configuration;
@@ -628,8 +628,7 @@ public String getCtags() {
628628
}
629629

630630
String value = syncReadConfiguration(Configuration::getCtags);
631-
return value != null ? value :
632-
System.getProperty(CtagsUtil.SYSTEM_CTAGS_PROPERTY, "ctags");
631+
return value != null ? value : System.getProperty(CtagsUtil.SYSTEM_CTAGS_PROPERTY, "ctags");
633632
}
634633

635634
/**
@@ -699,26 +698,20 @@ public void setHitsPerPage(int hitsPerPage) {
699698
* Validate that there is a Universal ctags program that can actually process input files
700699
* under source root.
701700
* <br>
702-
* As a side effect, this sets the set of ctags languages that is used by the ctags program.
701+
* As a side effect, this sets the set of ctags languages that is used by the <code>ctags</code> program.
703702
*
704703
* @return true if success, false otherwise
705704
*/
706-
public boolean validateUniversalCtags() {
705+
public synchronized boolean validateUniversalCtags() {
707706
if (ctagsFound == null) {
708-
try (ResourceLock resourceLock = configLock.writeLockAsResource()) {
709-
//noinspection ConstantConditions to avoid warning of no reference to auto-closeable
710-
assert resourceLock != null;
711-
if (ctagsFound == null) {
712-
String ctagsBinary = getCtags();
713-
if (ctagsLanguages.isEmpty()) {
714-
// The ctagsLanguages are necessary for the call to validate() below.
715-
Set<String> languages = CtagsUtil.getLanguages(ctagsBinary);
716-
ctagsLanguages.addAll(languages);
717-
}
718-
719-
ctagsFound = CtagsUtil.validate(ctagsBinary);
720-
}
707+
String ctagsBinary = getCtags();
708+
if (ctagsLanguages.isEmpty()) {
709+
// The ctagsLanguages are necessary for the call to validate() below.
710+
Set<String> languages = CtagsUtil.getLanguages(ctagsBinary);
711+
ctagsLanguages.addAll(languages);
721712
}
713+
714+
ctagsFound = CtagsUtil.validate(ctagsBinary);
722715
}
723716

724717
if (ctagsFound) {

0 commit comments

Comments
 (0)