Skip to content

Commit 452973f

Browse files
committed
Consistent Lock field declaration (instead of ReentrantLock field type)
(cherry picked from commit b415361)
1 parent 7ec5c99 commit 452973f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import java.util.Properties;
2828
import java.util.concurrent.ConcurrentHashMap;
2929
import java.util.concurrent.ConcurrentMap;
30+
import java.util.concurrent.locks.Lock;
3031
import java.util.concurrent.locks.ReentrantLock;
3132

3233
import org.springframework.context.ResourceLoaderAware;
@@ -143,7 +144,7 @@ public void setConcurrentRefresh(boolean concurrentRefresh) {
143144

144145
/**
145146
* Set the PropertiesPersister to use for parsing properties files.
146-
* <p>The default is ResourcePropertiesPersister.
147+
* <p>The default is {@code ResourcePropertiesPersister}.
147148
* @see ResourcePropertiesPersister#INSTANCE
148149
*/
149150
public void setPropertiesPersister(@Nullable PropertiesPersister propertiesPersister) {
@@ -401,7 +402,7 @@ protected PropertiesHolder getProperties(String filename) {
401402

402403
/**
403404
* Refresh the PropertiesHolder for the given bundle filename.
404-
* The holder can be {@code null} if not cached before, or a timed-out cache entry
405+
* <p>The holder can be {@code null} if not cached before, or a timed-out cache entry
405406
* (potentially getting re-validated against the current last-modified timestamp).
406407
* @param filename the bundle filename (basename + Locale)
407408
* @param propHolder the current PropertiesHolder for the bundle
@@ -562,7 +563,7 @@ protected class PropertiesHolder {
562563

563564
private volatile long refreshTimestamp = -2;
564565

565-
private final ReentrantLock refreshLock = new ReentrantLock();
566+
private final Lock refreshLock = new ReentrantLock();
566567

567568
/** Cache to hold already generated MessageFormats per message code. */
568569
private final ConcurrentMap<String, Map<Locale, MessageFormat>> cachedMessageFormats =

spring-web/src/main/java/org/springframework/web/server/session/InMemoryWebSessionStore.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
import java.util.Map;
2727
import java.util.concurrent.ConcurrentHashMap;
2828
import java.util.concurrent.atomic.AtomicReference;
29+
import java.util.concurrent.locks.Lock;
2930
import java.util.concurrent.locks.ReentrantLock;
3031

3132
import reactor.core.publisher.Mono;
@@ -310,12 +311,10 @@ private class ExpiredSessionChecker {
310311
/** Max time between expiration checks. */
311312
private static final int CHECK_PERIOD = 60 * 1000;
312313

313-
314-
private final ReentrantLock lock = new ReentrantLock();
314+
private final Lock lock = new ReentrantLock();
315315

316316
private Instant checkTime = clock.instant().plus(CHECK_PERIOD, ChronoUnit.MILLIS);
317317

318-
319318
public void checkIfNecessary(Instant now) {
320319
if (this.checkTime.isBefore(now)) {
321320
removeExpiredSessions(now);

spring-websocket/src/main/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandler.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import java.util.TreeMap;
2626
import java.util.concurrent.ConcurrentHashMap;
2727
import java.util.concurrent.atomic.AtomicInteger;
28+
import java.util.concurrent.locks.Lock;
2829
import java.util.concurrent.locks.ReentrantLock;
2930

3031
import org.apache.commons.logging.Log;
@@ -98,7 +99,7 @@ public class SubProtocolWebSocketHandler
9899

99100
private volatile long lastSessionCheckTime = System.currentTimeMillis();
100101

101-
private final ReentrantLock sessionCheckLock = new ReentrantLock();
102+
private final Lock sessionCheckLock = new ReentrantLock();
102103

103104
private final DefaultStats stats = new DefaultStats();
104105

@@ -268,7 +269,7 @@ public Stats getStats() {
268269

269270
@Override
270271
public final void start() {
271-
Assert.isTrue(this.defaultProtocolHandler != null || !this.protocolHandlers.isEmpty(), "No handlers");
272+
Assert.state(this.defaultProtocolHandler != null || !this.protocolHandlers.isEmpty(), "No handlers");
272273

273274
synchronized (this.lifecycleMonitor) {
274275
this.clientOutboundChannel.subscribe(this);

0 commit comments

Comments
 (0)