public static String getTaskClassVersion(Config config) {
    try {
      Optional<String> appClass = Optional.ofNullable(new ApplicationConfig(config).getAppClass());
      if (appClass.isPresent()) {
        return Optional.ofNullable(Class.forName(appClass.get()).getPackage().getImplementationVersion())
            .orElse(FALLBACK_VERSION);
      } else {
        Optional<String> taskClass = new TaskConfig(config).getTaskClass();
        if (taskClass.isPresent()) {
          return Optional.ofNullable(Class.forName(taskClass.get()).getPackage().getImplementationVersion())
              .orElse(FALLBACK_VERSION);
        } else {
          LOG.warn("Unable to find app class or task class. Defaulting to {}", FALLBACK_VERSION);
          return FALLBACK_VERSION;
        }
      }
    } catch (Exception e) {
      LOG.warn(String.format("Ran into exception while trying to get version of app or task. Defaulting to %s",
          FALLBACK_VERSION), e);
      return FALLBACK_VERSION;
    }
  }
Make an environment variable string safe to pass.
samza-core/src/main/java/org/apache/samza/util/Util.java