GH-8643: Replace synchronized with Lock
Fixes https://github.com/spring-projects/spring-integration/issues/8643 * First pass - trivial synchronized blocks - Convert the "trivial" `synchronized` block into `ReentrantLock`. * fix checkstyle * use blocking lock * Secon pass - handle multi-lock cases * javadoc + year * addres first batch of review suggestions * fix checkstyle issues * fix the mqtt parent/child lock monitor sharing * fix the mqtt parent/child lock monitor sharing, v2 * patch the stomp test
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
* Copyright 2017-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
@@ -71,6 +73,7 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||
* @author Wallace Wadge
|
||||
* @author Shiliang Li
|
||||
* @author Florian Schöffl
|
||||
* @author Christian Tzolov
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -81,6 +84,8 @@ public abstract class AbstractHttpRequestExecutingMessageHandler extends Abstrac
|
||||
|
||||
protected final DefaultUriBuilderFactory uriFactory = new DefaultUriBuilderFactory(); // NOSONAR - final
|
||||
|
||||
private final Lock lock = new ReentrantLock();
|
||||
|
||||
private final Map<String, Expression> uriVariableExpressions = new HashMap<>();
|
||||
|
||||
private final Expression uriExpression;
|
||||
@@ -226,10 +231,14 @@ public abstract class AbstractHttpRequestExecutingMessageHandler extends Abstrac
|
||||
* @param uriVariableExpressions The URI variable expressions.
|
||||
*/
|
||||
public void setUriVariableExpressions(Map<String, Expression> uriVariableExpressions) {
|
||||
synchronized (this.uriVariableExpressions) {
|
||||
this.lock.lock();
|
||||
try {
|
||||
this.uriVariableExpressions.clear();
|
||||
this.uriVariableExpressions.putAll(uriVariableExpressions);
|
||||
}
|
||||
finally {
|
||||
this.lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user