VirtusLab / akka-serialization-helper

Serialization toolbox for Akka messages, events and persistent state that helps achieve compile-time guarantee on serializability. No more errors in the runtime!
MIT License
26 stars 5 forks source link

Fix false-negatives for codec registration checker plugin #184

Open LukaszKontowski opened 2 years ago

LukaszKontowski commented 2 years ago

In specific scenarios, codec registration checker plugin does not find missing codec registrations - i.e. when using sbt incremental compilation. Example scenario with explanation - steps to be performed on a project that uses ASH:

  1. sbt compile on existing code (fresh compilation on all files) - compilation succeeds - OK
  2. add new top level serializable class (in a separate file) and do not register it in serializer
  3. sbt compile - compilation succeeds - NOT OK

If we would perform only steps 2. and 3. - sbt compile would end in an error (which is what we want) saying that there are missing codec registrations. So, this is an issue with incremental compilation. The reason of this issue is to fix such "false negatives". Compilation should never succeed for situations as described above - whether this is full compilation on all sources - or just an incremental compilation on one or more added files.

LukaszKontowski commented 2 years ago

This issue is related to the way CirceAkkaSerializer (CAS) works. For CAS the problem is that:

In fact - we would need to force compilation of the A.scala file in such situations to catch such errors.

PawelLipski commented 2 years ago

org.virtuslab.ash.circe.enable-missing-codecs-check config key can be removed if this is done, right?

LukaszKontowski commented 2 years ago

Yes, and connected part of logic - method checkSerializableTypesForMissingCodec