Repository: corona-warn-app/cwa-server
File: services/distribution/src/main/java/app/coronawarn/server/services/distribution/assembly/component/BusinessRulesArchiveBuilder.java (Java)

Code before:
    this.distributionServiceConfig = distributionServiceConfig;
  }

  /**
   * Builds a archive on disk containing business rules.
   *
   * @return - optional archive on disk
   */
  public Optional<Writable<WritableOnDisk>> build() {
    checkFields();
    ArchiveOnDisk rulesArchive = new ArchiveOnDisk(
        ObjectUtils.isEmpty(archiveName) ? distributionServiceConfig.getDefaultArchiveName() : archiveName);
    try {
      rulesArchive
          .addWritable(new FileOnDisk(exportBinaryFilename,
              dgcToCborMapping.constructCborRules(ruleType, businessRuleItemSupplier, businessRuleSupplier)));
      logger.info("{} archive has been added to the DGC distribution folder", archiveName);

      reset();
      return Optional.of(
          new DistributionArchiveSigningDecorator(rulesArchive, cryptoProvider, distributionServiceConfig));
    } catch (DigitalCovidCertificateException e) {
      logger.error("{} archive was not overwritten because of: {}", archiveName, e.toString());
    } catch (FetchBusinessRulesException e) {
      logger.error("{} archive was not overwritten because business rules could not been fetched: {}", archiveName,
          e.toString());
    }

    reset();
    return Optional.empty();
  }

  /**
   * Resets each field of the builder.
   */
  public void reset() {
    this.archiveName = null;
    this.exportBinaryFilename = null;
    this.ruleType = null;
    this.businessRuleSupplier = null;
    this.businessRuleItemSupplier = null;
  }

  public BusinessRulesArchiveBuilder setArchiveName(String archiveName) {
    this.archiveName = archiveName;
    return this;
  }

  public BusinessRulesArchiveBuilder setRuleType(RuleType ruleType) {
    this.ruleType = ruleType;
    return this;

Review comment (suggestion):
this swallows the complete stack trace, because of the different method signature, which is used here
see:
```
void error(String format, Object... arguments)
vs.
void error(String msg, Throwable t)
```

I would highly recommend to use the second one with only one string and as second argument the throwable object!!! otherwise you'll lose valuable information in the logs, when those exceptions are raised 

Code after:
    this.distributionServiceConfig = distributionServiceConfig;
  }

  /**
   * Builds a archive on disk containing business rules.
   *
   * @return - optional archive on disk
   */
  public Optional<Writable<WritableOnDisk>> build() {
    checkFields();
    ArchiveOnDisk rulesArchive = new ArchiveOnDisk(
        ObjectUtils.isEmpty(archiveName) ? distributionServiceConfig.getDefaultArchiveName() : archiveName);
    try {
      rulesArchive
          .addWritable(new FileOnDisk(exportBinaryFilename,
              dgcToCborMapping.constructCborRules(ruleType, businessRuleItemSupplier, businessRuleSupplier)));
      logger.info("{} archive has been added to the DGC distribution folder", archiveName);

      reset();
      return Optional.of(
          new DistributionArchiveSigningDecorator(rulesArchive, cryptoProvider, distributionServiceConfig));
    } catch (DigitalCovidCertificateException e) {
      logger.error(String.format("%s archive was not overwritten because of: ", archiveName), e);
    } catch (FetchBusinessRulesException e) {
      logger.error(String
          .format("%s archive was not overwritten because business rules could not been fetched: ", archiveName), e);
    }

    reset();
    return Optional.empty();
  }

  /**
   * Resets each field of the builder.
   */
  public void reset() {
    this.archiveName = null;
    this.exportBinaryFilename = null;
    this.ruleType = null;
    this.businessRuleSupplier = null;
    this.businessRuleItemSupplier = null;
  }

  public BusinessRulesArchiveBuilder setArchiveName(String archiveName) {
    this.archiveName = archiveName;
    return this;
  }

  public BusinessRulesArchiveBuilder setRuleType(RuleType ruleType) {
    this.ruleType = ruleType;
    return this;