From 71d209070ac60a58e528d079e8d84843f0c7f08f Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 20 Feb 2012 11:13:49 -0500 Subject: [PATCH] add some missing serialVersionUID All the most-derived classes need to have it, not just base classes. Update expected serializations in the tests to reflect new serialVersionUID. --- .../config/impl/ConfigDelayedMerge.java | 2 + .../config/impl/ConfigDelayedMergeObject.java | 4 +- .../config/impl/SimpleConfigList.java | 2 + .../config/impl/ConfigSubstitutionTest.scala | 2 +- .../config/impl/ConfigValueTest.scala | 6 +-- .../com/typesafe/config/impl/TestUtils.scala | 42 ++++++++++++------- 6 files changed, 37 insertions(+), 21 deletions(-) diff --git a/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java b/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java index b64712eb..49eae37c 100644 --- a/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java +++ b/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMerge.java @@ -25,6 +25,8 @@ import com.typesafe.config.ConfigValueType; final class ConfigDelayedMerge extends AbstractConfigValue implements Unmergeable { + private static final long serialVersionUID = 1L; + // earlier items in the stack win final private List stack; final private boolean ignoresFallbacks; diff --git a/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java b/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java index c290c47f..23d5b994 100644 --- a/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java +++ b/config/src/main/java/com/typesafe/config/impl/ConfigDelayedMergeObject.java @@ -18,9 +18,11 @@ import com.typesafe.config.ConfigValue; // This is just like ConfigDelayedMerge except we know statically // that it will turn out to be an object. -class ConfigDelayedMergeObject extends AbstractConfigObject implements +final class ConfigDelayedMergeObject extends AbstractConfigObject implements Unmergeable { + private static final long serialVersionUID = 1L; + final private List stack; final private boolean ignoresFallbacks; diff --git a/config/src/main/java/com/typesafe/config/impl/SimpleConfigList.java b/config/src/main/java/com/typesafe/config/impl/SimpleConfigList.java index 9c31dbf0..50d361f3 100644 --- a/config/src/main/java/com/typesafe/config/impl/SimpleConfigList.java +++ b/config/src/main/java/com/typesafe/config/impl/SimpleConfigList.java @@ -18,6 +18,8 @@ import com.typesafe.config.ConfigValueType; final class SimpleConfigList extends AbstractConfigValue implements ConfigList { + private static final long serialVersionUID = 1L; + final private List value; final private boolean resolved; diff --git a/config/src/test/scala/com/typesafe/config/impl/ConfigSubstitutionTest.scala b/config/src/test/scala/com/typesafe/config/impl/ConfigSubstitutionTest.scala index 430f0064..91137f62 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ConfigSubstitutionTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ConfigSubstitutionTest.scala @@ -365,7 +365,7 @@ class ConfigSubstitutionTest extends TestUtils { "257400046f626a427371007e00177371007e000700000007000000077071007e000c71007e000f70" + "00000000007371007e001a7704000000017371007e001c007371007e001f740001617371007e001f" + "74000162707874000361727273720029636f6d2e74797065736166652e636f6e6669672e696d706c" + - "2e53696d706c65436f6e6669674c697374ef9443c7c6af330d0200025a00087265736f6c7665644c" + + "2e53696d706c65436f6e6669674c69737400000000000000010200025a00087265736f6c7665644c" + "000576616c756571007e00087871007e00047371007e00070000000a0000000a7071007e000c7100" + "7e000f70007371007e001a7704000000067371007e00177371007e00070000000a0000000a707100" + "7e000c71007e000f7000000000007371007e001a7704000000017371007e001c007371007e001f74" + diff --git a/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala b/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala index a89d14bf..4423be77 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala @@ -204,7 +204,7 @@ class ConfigValueTest extends TestUtils { def configListSerializable() { val expectedSerialization = "" + "aced000573720029636f6d2e74797065736166652e636f6e6669672e696d706c2e53696d706c6543" + - "6f6e6669674c697374ef9443c7c6af330d0200025a00087265736f6c7665644c000576616c756574" + + "6f6e6669674c69737400000000000000010200025a00087265736f6c7665644c000576616c756574" + "00104c6a6176612f7574696c2f4c6973743b7872002c636f6d2e74797065736166652e636f6e6669" + "672e696d706c2e4162737472616374436f6e66696756616c756500000000000000010200014c0006" + "6f726967696e74002d4c636f6d2f74797065736166652f636f6e6669672f696d706c2f53696d706c" + @@ -288,7 +288,7 @@ class ConfigValueTest extends TestUtils { def configDelayedMergeSerializable() { val expectedSerialization = "" + "aced00057372002b636f6d2e74797065736166652e636f6e6669672e696d706c2e436f6e66696744" + - "656c617965644d657267656d8c8e0e0c0145760200025a001069676e6f72657346616c6c6261636b" + + "656c617965644d6572676500000000000000010200025a001069676e6f72657346616c6c6261636b" + "734c0005737461636b7400104c6a6176612f7574696c2f4c6973743b7872002c636f6d2e74797065" + "736166652e636f6e6669672e696d706c2e4162737472616374436f6e66696756616c756500000000" + "000000010200014c00066f726967696e74002d4c636f6d2f74797065736166652f636f6e6669672f" + @@ -338,7 +338,7 @@ class ConfigValueTest extends TestUtils { def configDelayedMergeObjectSerializable() { val expectedSerialization = "" + "aced000573720031636f6d2e74797065736166652e636f6e6669672e696d706c2e436f6e66696744" + - "656c617965644d657267654f626a65637401fa1552304cae900200025a001069676e6f7265734661" + + "656c617965644d657267654f626a65637400000000000000010200025a001069676e6f7265734661" + "6c6c6261636b734c0005737461636b7400104c6a6176612f7574696c2f4c6973743b7872002d636f" + "6d2e74797065736166652e636f6e6669672e696d706c2e4162737472616374436f6e6669674f626a" + "65637400000000000000010200014c0006636f6e6669677400274c636f6d2f74797065736166652f" + diff --git a/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala b/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala index 74580284..ea7562b0 100644 --- a/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala +++ b/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala @@ -116,30 +116,40 @@ abstract trait TestUtils { val why = failure.map({ e => ": " + e.getClass.getSimpleName + ": " + e.getMessage }).getOrElse("") - assertEquals("Can no longer deserialize the old format of " + o.getClass.getSimpleName + why, - o, deserialized) - assertFalse(failure.isDefined) // should have thrown if we had a failure - val byteStream = new ByteArrayOutputStream() val objectStream = new ObjectOutputStream(byteStream) objectStream.writeObject(o) objectStream.close() val hex = Hex.encodeHexString(byteStream.toByteArray()) - if (expectedHex != hex) { - @tailrec - def outputStringLiteral(s: String): Unit = { - if (s.nonEmpty) { - val (head, tail) = s.splitAt(80) - val plus = if (tail.isEmpty) "" else " +" - System.err.println("\"" + head + "\"" + plus) - outputStringLiteral(tail) + def showCorrectResult(): Unit = { + if (expectedHex != hex) { + @tailrec + def outputStringLiteral(s: String): Unit = { + if (s.nonEmpty) { + val (head, tail) = s.splitAt(80) + val plus = if (tail.isEmpty) "" else " +" + System.err.println("\"" + head + "\"" + plus) + outputStringLiteral(tail) + } } + System.err.println("Correct result literal for " + o.getClass.getSimpleName + " serialization:") + System.err.println("\"\" + ") // line up all the lines by using empty string on first line + outputStringLiteral(hex) } - System.err.println("Correct result literal for " + o.getClass.getSimpleName + " serialization:") - System.err.println("\"\" + ") // line up all the lines by using empty string on first line - outputStringLiteral(hex) } - assertEquals(o.getClass.getSimpleName + " serialization has changed (though we still deserialized the old serialization)", expectedHex, hex) + + try { + assertEquals("Can no longer deserialize the old format of " + o.getClass.getSimpleName + why, + o, deserialized) + assertFalse(failure.isDefined) // should have thrown if we had a failure + + assertEquals(o.getClass.getSimpleName + " serialization has changed (though we still deserialized the old serialization)", + expectedHex, hex) + } catch { + case e: Throwable => + showCorrectResult() + throw e + } } protected def checkSerializable[T: Manifest](expectedHex: String, o: T): T = {