private def checkDispatcherConfig()

in jdbc/src/main/scala/org/apache/pekko/projection/jdbc/internal/JdbcSettings.scala [72:106]


  private def checkDispatcherConfig(system: ActorSystem[_]) = {

    val dispatcherConfigPath = system.settings.config.getString(dispatcherPath)
    val config = system.settings.config.getConfig(dispatcherConfigPath)
    val pathToPoolSize = "thread-pool-executor.fixed-pool-size"

    def isEmptyString = {
      config.getValue(pathToPoolSize).valueType() == ConfigValueType.STRING &&
      config.getString(pathToPoolSize).trim.isEmpty
    }

    // the reference config has a thread-pool-executor configured
    // with a invalid pool size. We need to check if users configured it correctly
    // it's also possible that user decide to not use a thread-pool-executor
    // in which case, we have nothing else to check
    if (config.getString("executor") == "thread-pool-executor") {

      // empty string can't be parsed to Int, users probably forgot to configure the pool-size
      if (isEmptyString)
        throw new IllegalArgumentException(
          s"Config value for '$dispatcherConfigPath.$pathToPoolSize' is not configured. " +
          "The thread pool size must be integer and be as large as the JDBC connection pool.")

      try {
        // not only explicit Int, but also Int defined as String are valid, eg: 10 and "10"
        config.getInt(pathToPoolSize)
      } catch {
        case _: ConfigException.WrongType =>
          throw new IllegalArgumentException(
            s"Value [${config.getValue(pathToPoolSize).render()}] is not a valid value for settings '$dispatcherConfigPath.$pathToPoolSize'. " +
            s"Current value is [${config.getValue(pathToPoolSize)}]. " +
            "The thread pool size must be integer and be as large as the JDBC connection pool.")
      }
    }
  }