#3182 - Fixing a StackOverflow error in the FileBasedMailbox
This commit is contained in:
parent
3569886bbe
commit
a24cf76375
1 changed files with 20 additions and 16 deletions
|
|
@ -21,6 +21,7 @@ import java.io._
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
import akka.event.LoggingAdapter
|
import akka.event.LoggingAdapter
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import scala.annotation.tailrec
|
||||||
import akka.actor.mailbox.filebased.FileBasedMailboxSettings
|
import akka.actor.mailbox.filebased.FileBasedMailboxSettings
|
||||||
|
|
||||||
// a config value that's backed by a global setting but may be locally overridden
|
// a config value that's backed by a global setting but may be locally overridden
|
||||||
|
|
@ -413,25 +414,28 @@ class PersistentQueue(persistencePath: String, val name: String, val settings: F
|
||||||
}
|
}
|
||||||
|
|
||||||
final def discardExpired(): Int = {
|
final def discardExpired(): Int = {
|
||||||
if (queue.isEmpty || journal.isReplaying) {
|
@tailrec def internalDisard(discarded: Int): Int = {
|
||||||
0
|
if (queue.isEmpty || journal.isReplaying) {
|
||||||
} else {
|
discarded
|
||||||
val realExpiry = adjustExpiry(queue.front.addTime, queue.front.expiry)
|
|
||||||
if ((realExpiry != 0) && (realExpiry < System.currentTimeMillis)) {
|
|
||||||
_totalExpired += 1
|
|
||||||
val item = queue.dequeue
|
|
||||||
val len = item.data.length
|
|
||||||
queueSize -= len
|
|
||||||
_memoryBytes -= len
|
|
||||||
queueLength -= 1
|
|
||||||
fillReadBehind
|
|
||||||
if (keepJournal()) journal.remove()
|
|
||||||
expiredQueue().map { _.add(item.data, 0) }
|
|
||||||
1 + discardExpired()
|
|
||||||
} else {
|
} else {
|
||||||
0
|
val realExpiry = adjustExpiry(queue.front.addTime, queue.front.expiry)
|
||||||
|
if ((realExpiry != 0) && (realExpiry < System.currentTimeMillis)) {
|
||||||
|
_totalExpired += 1
|
||||||
|
val item = queue.dequeue
|
||||||
|
val len = item.data.length
|
||||||
|
queueSize -= len
|
||||||
|
_memoryBytes -= len
|
||||||
|
queueLength -= 1
|
||||||
|
fillReadBehind
|
||||||
|
if (keepJournal()) journal.remove()
|
||||||
|
expiredQueue().map { _.add(item.data, 0) }
|
||||||
|
internalDisard(discarded + 1)
|
||||||
|
} else {
|
||||||
|
discarded
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
internalDisard(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def _unremove(xid: Int) = {
|
private def _unremove(xid: Int) = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue