Skip to content

Add explicit serialVersionUID to exception classes #533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions core/common/src/Exceptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class DateTimeArithmeticException: RuntimeException {
public constructor(message: String): super(message)
public constructor(cause: Throwable): super(cause)
public constructor(message: String, cause: Throwable): super(message, cause)

private companion object {
private const val serialVersionUID: Long = -3207806170214997982L
}
}

/**
Expand All @@ -23,11 +27,19 @@ public class IllegalTimeZoneException: IllegalArgumentException {
public constructor(message: String): super(message)
public constructor(cause: Throwable): super(cause)
public constructor(message: String, cause: Throwable): super(message, cause)

private companion object {
private const val serialVersionUID: Long = 1159315966274264801L
}
}

internal class DateTimeFormatException: IllegalArgumentException {
constructor(): super()
constructor(message: String): super(message)
constructor(cause: Throwable): super(cause)
constructor(message: String, cause: Throwable): super(message, cause)

private companion object {
private const val serialVersionUID: Long = 4231196759387994100L
}
}
8 changes: 7 additions & 1 deletion core/common/src/internal/format/parser/Parser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,13 @@ internal value class Parser<Output : Copyable<Output>>(
)
}

internal class ParseException(errors: List<ParseError>) : Exception(formatError(errors))
// note that the message of this exception could be anything (even null) after deserialization of a manually constructed
// or corrupted stream (via Java Object Serialization)
internal class ParseException(errors: List<ParseError>) : Exception(formatError(errors)) {
private companion object {
private const val serialVersionUID: Long = 5691186997393344103L
}
}

private fun formatError(errors: List<ParseError>): String {
if (errors.size == 1) {
Expand Down