@@ -538,8 +538,8 @@ private Environment(final PropertySource propertySource) {
538
538
}
539
539
540
540
private void addPropertySource (final PropertySource propertySource ) {
541
+ sourceWriteLock .lock ();
541
542
try {
542
- sourceWriteLock .lock ();
543
543
if (!sources .contains (propertySource )) {
544
544
sources .add (propertySource );
545
545
sources .sort (Comparator .INSTANCE );
@@ -550,8 +550,8 @@ private void addPropertySource(final PropertySource propertySource) {
550
550
}
551
551
552
552
private void removePropertySource (final PropertySource propertySource ) {
553
+ sourceWriteLock .lock ();
553
554
try {
554
- sourceWriteLock .lock ();
555
555
sources .remove (propertySource );
556
556
} finally {
557
557
sourceWriteLock .unlock ();
@@ -561,8 +561,8 @@ private void removePropertySource(final PropertySource propertySource) {
561
561
private void reload () {
562
562
literal .clear ();
563
563
tokenized .clear ();
564
+ sourceWriteLock .lock ();
564
565
try {
565
- sourceWriteLock .lock ();
566
566
// 1. Collects all property keys from enumerable sources.
567
567
final Set <String > keys = new HashSet <>();
568
568
sources .stream ().map (PropertySource ::getPropertyNames ).forEach (keys ::addAll );
@@ -598,8 +598,8 @@ private String get(final String key) {
598
598
}
599
599
final List <CharSequence > tokens = PropertySource .Util .tokenize (key );
600
600
final boolean hasTokens = !tokens .isEmpty ();
601
+ sourceReadLock .lock ();
601
602
try {
602
- sourceReadLock .lock ();
603
603
for (final PropertySource source : sources ) {
604
604
if (hasTokens ) {
605
605
final String normalKey = Objects .toString (source .getNormalForm (tokens ), null );
@@ -637,8 +637,8 @@ private String sourceGetProperty(final PropertySource source, final String key)
637
637
638
638
private boolean containsKey (final String key ) {
639
639
final List <CharSequence > tokens = PropertySource .Util .tokenize (key );
640
+ sourceReadLock .lock ();
640
641
try {
641
- sourceReadLock .lock ();
642
642
return literal .containsKey (key )
643
643
|| tokenized .containsKey (tokens )
644
644
|| sources .stream ().anyMatch (s -> {
0 commit comments