mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
fix null pointer in PortLock#lock (#6941)
java.lang.NullPointerException: at com.daml.ports.PortLock$Locked.unlock(PortLock.scala:55) at com.daml.ports.PortLock$.lock(PortLock.scala:41) at com.daml.ports.LockedFreePort$.find(LockedFreePort.scala:15) at com.daml.lf.engine.trigger.TriggerServiceFixture$.$anonfun$withTriggerService$1(TriggerServiceFixture.scala:65) CHANGELOG_BEGIN CHANGELOG_END
This commit is contained in:
parent
e972872128
commit
3a0a3228ec
@ -33,14 +33,13 @@ object PortLock {
|
||||
val file = new RandomAccessFile(portLockFile.toFile, "rw")
|
||||
val channel = file.getChannel
|
||||
try {
|
||||
val lock = channel.tryLock()
|
||||
val locked = new Locked(port, lock, channel, file)
|
||||
if (lock != null) {
|
||||
Right(locked)
|
||||
} else {
|
||||
locked.unlock()
|
||||
Left(FailedToLock(port))
|
||||
}
|
||||
Option(channel.tryLock())
|
||||
.map(lock => new Locked(port, lock, channel, file))
|
||||
.toRight {
|
||||
channel.close()
|
||||
file.close()
|
||||
FailedToLock(port)
|
||||
}
|
||||
} catch {
|
||||
case _: OverlappingFileLockException =>
|
||||
channel.close()
|
||||
|
Loading…
Reference in New Issue
Block a user