Skip to content

Commit

Permalink
+rem #24265 protobuf serializer for Address and UniqueAddress in akka… (
Browse files Browse the repository at this point in the history
#24267)

* +rem #24265 protobuf serializer for Address and UniqueAddress in akka-remote

* remove the duplication, by using previously existing type

* fixed doc link

* make it easier to enable the additional no-java-serialization bindings

* fixed akka-actor failure due to changes

* cleanup

* Update reference.conf

* Update serialization.md

* Update reference.conf
  • Loading branch information
ktoso committed Jan 10, 2018
1 parent eba7473 commit 59a48c7
Show file tree
Hide file tree
Showing 8 changed files with 1,454 additions and 1,349 deletions.
122 changes: 63 additions & 59 deletions akka-actor/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ akka {
# Loggers to register at boot time (akka.event.Logging$DefaultLogger logs
# to STDOUT)
loggers = ["akka.event.Logging$DefaultLogger"]
# Filter of log events that is used by the LoggingAdapter before

# Filter of log events that is used by the LoggingAdapter before
# publishing log events to the eventStream. It can perform
# fine grained filtering based on the log source. The default
# implementation filters on the `loglevel`.
# FQCN of the LoggingFilter. The Class of the FQCN must implement
# FQCN of the LoggingFilter. The Class of the FQCN must implement
# akka.event.LoggingFilter and have a public constructor with
# (akka.actor.ActorSystem.Settings, akka.event.EventStream) parameters.
logging-filter = "akka.event.DefaultLoggingFilter"
Expand Down Expand Up @@ -109,6 +109,10 @@ akka {
# this is only intended for testing.
serialize-messages = off

# Additional serialization bindings which are enabled automatically when allow-java-serialization is disabled.
# settings are provided
java-serialization-disabled-additional-serialization-bindings = {}

# Serializes and deserializes creators (in Props) to ensure that they can be
# sent over the network, this is only intended for testing. Purely local deployments
# as marked with deploy.scope == LocalScope are exempt from verification.
Expand All @@ -123,7 +127,7 @@ akka {
# Default timeout for typed actor methods with non-void return type
timeout = 5s
}

# Mapping between ´deployment.router' short names to fully qualified class names
router.type-mapping {
from-code = "akka.routing.NoRouter"
Expand All @@ -147,7 +151,7 @@ akka {

# deployment id pattern - on the format: /parent/child etc.
default {

# The id of the dispatcher to use for this actor.
# If undefined or empty the dispatcher specified in code
# (Props.withDispatcher) is used, or default-dispatcher if not
Expand Down Expand Up @@ -204,9 +208,9 @@ akka {
# precedence over nr-of-instances
paths = []
}

# To use a dedicated dispatcher for the routees of the pool you can
# define the dispatcher configuration inline with the property name
# define the dispatcher configuration inline with the property name
# 'pool-dispatcher' in the deployment section of the router.
# For example:
# pool-dispatcher {
Expand All @@ -217,7 +221,7 @@ akka {
# Routers with dynamically resizable number of routees; this feature is
# enabled by including (parts of) this section in the deployment
resizer {

enabled = off

# The fewest number of routees the router should ever have.
Expand Down Expand Up @@ -455,20 +459,20 @@ akka {
thread-pool-executor {
# Keep alive time for threads
keep-alive-time = 60s

# Define a fixed thread pool size with this property. The corePoolSize
# and the maximumPoolSize of the ThreadPoolExecutor will be set to this
# value, if it is defined. Then the other pool-size properties will not
# be used.
#
# be used.
#
# Valid values are: `off` or a positive integer.
fixed-pool-size = off

# Min number of threads to cap factor-based corePoolSize number to
core-pool-size-min = 8

# The core-pool-size-factor is used to determine corePoolSize of the
# ThreadPoolExecutor using the following formula:
# The core-pool-size-factor is used to determine corePoolSize of the
# ThreadPoolExecutor using the following formula:
# ceil(available processors * factor).
# Resulting size is then bounded by the core-pool-size-min and
# core-pool-size-max values.
Expand All @@ -480,7 +484,7 @@ akka {
# Minimum number of threads to cap factor-based maximumPoolSize number to
max-pool-size-min = 8

# The max-pool-size-factor is used to determine maximumPoolSize of the
# The max-pool-size-factor is used to determine maximumPoolSize of the
# ThreadPoolExecutor using the following formula:
# ceil(available processors * factor)
# The maximumPoolSize will not be less than corePoolSize.
Expand Down Expand Up @@ -628,7 +632,7 @@ akka {
# com.typesafe.config.Config) parameters.
mailbox-type = "akka.dispatch.BoundedControlAwareMailbox"
}

# The LoggerMailbox will drain all messages in the mailbox
# when the system is shutdown and deliver them to the StandardOutLogger.
# Do not change this unless you know what you are doing.
Expand Down Expand Up @@ -661,28 +665,28 @@ akka {
# enable WARN logging of misconfigured routers
router-misconfiguration = off
}
# SECURITY BEST-PRACTICE is to disable java serialization for its multiple
# known attack surfaces.
#

# SECURITY BEST-PRACTICE is to disable java serialization for its multiple
# known attack surfaces.
#
# This setting is a short-cut to
# - using DisabledJavaSerializer instead of JavaSerializer
# - enable-additional-serialization-bindings = on
#
# Completely disable the use of `akka.serialization.JavaSerialization` by the
# Akka Serialization extension, instead DisabledJavaSerializer will
# Completely disable the use of `akka.serialization.JavaSerialization` by the
# Akka Serialization extension, instead DisabledJavaSerializer will
# be inserted which will fail explicitly if attempts to use java serialization are made.
#
# The log messages emitted by such serializer SHOULD be treated as potential
# attacks which the serializer prevented, as they MAY indicate an external operator
#
# The log messages emitted by such serializer SHOULD be treated as potential
# attacks which the serializer prevented, as they MAY indicate an external operator
# attempting to send malicious messages intending to use java serialization as attack vector.
# The attempts are logged with the SECURITY marker.
#
#
# Please note that this option does not stop you from manually invoking java serialization
#
#
# The default value for this might be changed to off in future versions of Akka.
allow-java-serialization = on

# Entries for pluggable serializers and their bindings.
serializers {
java = "akka.serialization.JavaSerializer"
Expand All @@ -700,18 +704,18 @@ akka {
"[B" = bytes
"java.io.Serializable" = java
}

# Additional serialization-bindings that are replacing Java serialization are
# defined in this section for backwards compatibility reasons. They are included
# defined in this section for backwards compatibility reasons. They are included
# by default but can be excluded for backwards compatibility with Akka 2.4.x.
# They can be disabled with enable-additional-serialization-bindings=off.
#
#
# This should only be needed for backwards compatibility reasons.
enable-additional-serialization-bindings = on

# Additional serialization-bindings that are replacing Java serialization are
# defined in this section for backwards compatibility reasons. They are included
# by default but can be excluded for backwards compatibility with Akka 2.4.x.
# by default but can be excluded for backwards compatibility with Akka 2.4.x.
# They can be disabled with enable-additional-serialization-bindings=off.
additional-serialization-bindings {
}
Expand Down Expand Up @@ -838,7 +842,7 @@ akka {
# The maximum number of bytes delivered by a `Received` message. Before
# more data is read from the network the connection actor will try to
# do other work.
# The purpose of this setting is to impose a smaller limit than the
# The purpose of this setting is to impose a smaller limit than the
# configured receive buffer size. When using value 'unlimited' it will
# try to read all from the receive buffer.
max-received-message-size = unlimited
Expand Down Expand Up @@ -980,7 +984,7 @@ akka {
# The maximal number of direct buffers kept in the direct buffer pool for
# reuse.
direct-buffer-pool-limit = 1000

# Enable fine grained logging of what goes on inside the implementation.
# Be aware that this may log more than once per message sent to the actors
# of the tcp implementation.
Expand Down Expand Up @@ -1036,31 +1040,31 @@ akka {
# - JVM shutdown hook will by default run CoordinatedShutdown
# - Cluster node will automatically run CoordinatedShutdown when it
# sees itself as Exiting
# - A management console or other application specific command can
# - A management console or other application specific command can
# run CoordinatedShutdown
coordinated-shutdown {
# The timeout that will be used for a phase if not specified with
# The timeout that will be used for a phase if not specified with
# 'timeout' in the phase
default-phase-timeout = 5 s

# Terminate the ActorSystem in the last phase actor-system-terminate.
terminate-actor-system = on

# Exit the JVM (System.exit(0)) in the last phase actor-system-terminate
# if this is set to 'on'. It is done after termination of the
# ActorSystem if terminate-actor-system=on, otherwise it is done
# immediately when the last phase is reached.
# if this is set to 'on'. It is done after termination of the
# ActorSystem if terminate-actor-system=on, otherwise it is done
# immediately when the last phase is reached.
exit-jvm = off

# Run the coordinated shutdown when the JVM process exits, e.g.
# via kill SIGTERM signal (SIGINT ctrl-c doesn't work).
# This property is related to `akka.jvm-shutdown-hooks` above.
run-by-jvm-shutdown-hook = on

#//#coordinated-shutdown-phases
# CoordinatedShutdown will run the tasks that are added to these
# phases. The phases can be ordered as a DAG by defining the
# dependencies between the phases.
# phases. The phases can be ordered as a DAG by defining the
# dependencies between the phases.
# Each phase is defined as a named config section with the
# following optional properties:
# - timeout=15s: Override the default-phase-timeout for this phase.
Expand All @@ -1071,68 +1075,68 @@ akka {

# The first pre-defined phase that applications can add tasks to.
# Note that more phases can be added in the application's
# configuration by overriding this phase with an additional
# configuration by overriding this phase with an additional
# depends-on.
before-service-unbind {
}

# Stop accepting new incoming requests in for example HTTP.
service-unbind {
depends-on = [before-service-unbind]
}

# Wait for requests that are in progress to be completed.
service-requests-done {
depends-on = [service-unbind]
}

# Final shutdown of service endpoints.
service-stop {
depends-on = [service-requests-done]
}

# Phase for custom application tasks that are to be run
# after service shutdown and before cluster shutdown.
before-cluster-shutdown {
depends-on = [service-stop]
}

# Graceful shutdown of the Cluster Sharding regions.
cluster-sharding-shutdown-region {
timeout = 10 s
depends-on = [before-cluster-shutdown]
}

# Emit the leave command for the node that is shutting down.
cluster-leave {
depends-on = [cluster-sharding-shutdown-region]
}

# Shutdown cluster singletons
cluster-exiting {
timeout = 10 s
depends-on = [cluster-leave]
}

# Wait until exiting has been completed
cluster-exiting-done {
depends-on = [cluster-exiting]
}

# Shutdown the cluster extension
cluster-shutdown {
depends-on = [cluster-exiting-done]
}

# Phase for custom application tasks that are to be run
# after cluster shutdown and before ActorSystem termination.
before-actor-system-terminate {
depends-on = [cluster-shutdown]
}

# Last phase. See terminate-actor-system and exit-jvm above.
# Don't add phases that depends on this phase because the
# dispatcher and scheduler of the ActorSystem have been shutdown.
# Don't add phases that depends on this phase because the
# dispatcher and scheduler of the ActorSystem have been shutdown.
actor-system-terminate {
timeout = 10 s
depends-on = [before-actor-system-terminate]
Expand Down
12 changes: 10 additions & 2 deletions akka-actor/src/main/scala/akka/serialization/Serialization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,22 @@ object Serialization {
val Serializers: Map[String, String] = configToMap(config.getConfig("akka.actor.serializers"))
val SerializationBindings: Map[String, String] = {
val defaultBindings = config.getConfig("akka.actor.serialization-bindings")
val bindings =
val bindings = {
if (config.getBoolean("akka.actor.enable-additional-serialization-bindings") ||
!config.getBoolean("akka.actor.allow-java-serialization") ||
config.hasPath("akka.remote.artery.enabled") && config.getBoolean("akka.remote.artery.enabled")) {
defaultBindings.withFallback(config.getConfig("akka.actor.additional-serialization-bindings"))

val bs = defaultBindings.withFallback(config.getConfig("akka.actor.additional-serialization-bindings"))

// in addition to the additional settings, we also enable even more bindings if java serialization is disabled:
val additionalWhenJavaOffKey = "akka.actor.java-serialization-disabled-additional-serialization-bindings"
if (!config.getBoolean("akka.actor.allow-java-serialization")) {
bs.withFallback(config.getConfig(additionalWhenJavaOffKey))
} else bs
} else {
defaultBindings
}
}
configToMap(bindings)
}

Expand Down
Loading

0 comments on commit 59a48c7

Please sign in to comment.