Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixes Scala 2.11 warnings, try without a catch
  • Loading branch information
Luc Bourlier committed Sep 4, 2015
commit 20622d60e2efb32085c4e810b2b33511679825fd
Original file line number Diff line number Diff line change
Expand Up @@ -79,32 +79,30 @@ private[spark] class RollingFileAppender(
val rolloverSuffix = rollingPolicy.generateRolledOverFileSuffix()
val rolloverFile = new File(
activeFile.getParentFile, activeFile.getName + rolloverSuffix).getAbsoluteFile
try {
logDebug(s"Attempting to rollover file $activeFile to file $rolloverFile")
if (activeFile.exists) {
if (!rolloverFile.exists) {
Files.move(activeFile, rolloverFile)
logInfo(s"Rolled over $activeFile to $rolloverFile")
} else {
// In case the rollover file name clashes, make a unique file name.
// The resultant file names are long and ugly, so this is used only
// if there is a name collision. This can be avoided by the using
// the right pattern such that name collisions do not occur.
var i = 0
var altRolloverFile: File = null
do {
altRolloverFile = new File(activeFile.getParent,
s"${activeFile.getName}$rolloverSuffix--$i").getAbsoluteFile
i += 1
} while (i < 10000 && altRolloverFile.exists)

logWarning(s"Rollover file $rolloverFile already exists, " +
s"rolled over $activeFile to file $altRolloverFile")
Files.move(activeFile, altRolloverFile)
}
logDebug(s"Attempting to rollover file $activeFile to file $rolloverFile")
if (activeFile.exists) {
if (!rolloverFile.exists) {
Files.move(activeFile, rolloverFile)
logInfo(s"Rolled over $activeFile to $rolloverFile")
} else {
logWarning(s"File $activeFile does not exist")
// In case the rollover file name clashes, make a unique file name.
// The resultant file names are long and ugly, so this is used only
// if there is a name collision. This can be avoided by the using
// the right pattern such that name collisions do not occur.
var i = 0
var altRolloverFile: File = null
do {
altRolloverFile = new File(activeFile.getParent,
s"${activeFile.getName}$rolloverSuffix--$i").getAbsoluteFile
i += 1
} while (i < 10000 && altRolloverFile.exists)

logWarning(s"Rollover file $rolloverFile already exists, " +
s"rolled over $activeFile to file $altRolloverFile")
Files.move(activeFile, altRolloverFile)
}
} else {
logWarning(s"File $activeFile does not exist")
}
}

Expand Down