[fineoffsetweatherstation] Fix java.lang.IllegalMonitorStateException (#14326)
This fix ensures, that the `ReentrantLock::unlock` method is only called, when the Thread is owning the lock. resolves: #14322 Signed-off-by: Andreas Berger <andreas@berger-freelancer.com>
This commit is contained in:
parent
fc57f02fca
commit
bd6fe9008a
|
@ -73,14 +73,20 @@ public abstract class GatewayQueryService implements AutoCloseable {
|
||||||
|
|
||||||
protected byte @Nullable [] executeCommand(String command, byte[] request,
|
protected byte @Nullable [] executeCommand(String command, byte[] request,
|
||||||
Function<byte[], Boolean> validateResponse) {
|
Function<byte[], Boolean> validateResponse) {
|
||||||
|
try {
|
||||||
|
if (!REQUEST_LOCK.tryLock(30, TimeUnit.SECONDS)) {
|
||||||
|
logger.debug("executeCommand({}): timed out while getting the lock", command);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
logger.debug("executeCommand({}): was interrupted while getting the lock", command);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] buffer = new byte[2028];
|
byte[] buffer = new byte[2028];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!REQUEST_LOCK.tryLock(30, TimeUnit.SECONDS)) {
|
|
||||||
logger.trace("executeCommand({}): time out while getting lock", command);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Socket socket = getConnection();
|
Socket socket = getConnection();
|
||||||
if (socket == null) {
|
if (socket == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue