=rem #13783 Make ProtobufSerializer independent of protobuf version

* well, as long as they provide the parseFrom and toByteArray
* it is using reflection to find the `parseFrom` and `toByteArray` methods to avoid
  dependency to `com.google.protobuf`.
* also special case com.google.protobuf when loading serialization binding
* migration guide
* mima filters for the serializers (all types changed)
* add real test for ProtobufSerializer
This commit is contained in:
Patrik Nordwall 2015-08-31 12:38:07 +02:00
parent c3ecb87a65
commit f8c1671903
7 changed files with 87 additions and 12 deletions

View file

@ -205,7 +205,15 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
* It is primarily ordered by the most specific classes first, and secondly in the configured order.
*/
private[akka] val bindings: immutable.Seq[ClassSerializer] =
sort(for ((k: String, v: String) settings.SerializationBindings if v != "none") yield (system.dynamicAccess.getClassFor[Any](k).get, serializers(v))).to[immutable.Seq]
sort(for ((k: String, v: String) settings.SerializationBindings if v != "none" && checkGoogleProtobuf(k))
yield (system.dynamicAccess.getClassFor[Any](k).get, serializers(v))).to[immutable.Seq]
// com.google.protobuf serialization binding is only used if the class can be loaded,
// i.e. com.google.protobuf dependency has been added in the application project.
// The reason for this special case is for backwards compatibility so that we still can
// include "com.google.protobuf.GeneratedMessage" = proto in configured serialization-bindings.
private def checkGoogleProtobuf(className: String): Boolean =
(!className.startsWith("com.google.protobuf") || system.dynamicAccess.getClassFor[Any](className).isSuccess)
/**
* Sort so that subtypes always precede their supertypes, but without