Github user mmiklavc commented on a diff in the pull request:

    https://github.com/apache/metron/pull/1251#discussion_r230560963
  
    --- Diff: 
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/resolver/BaseFunctionResolver.java
 ---
    @@ -94,6 +95,16 @@ public void initialize(Context context) {
         this.context = context;
       }
     
    +  /**
    +   * Close the Stellar functions.
    +   */
    +  @Override
    +  public void close() throws IOException {
    +    for (StellarFunctionInfo info : getFunctionInfo()) {
    --- End diff --
    
    What about something like this?
    ```
    public void close() throws IOException {
        Map<String, Throwable> errors = new HashMap();
        for (StellarFunctionInfo info : getFunctionInfo()) {
          try {
            info.getFunction().close();
          } catch (Throwable t) {
            errors.put(info.getName(), t);
          }
        }
        if (!errors.isEmpty()) {
          StringBuilder sb = new StringBuilder();
          sb.append("Unable to close Stellar functions:");
          for (Map.Entry<String, Throwable> e : errors.entrySet()) {
            Throwable throwable = e.getValue();
            String eText = String
                .format("Exception - Function: %s; Message: %s; Cause: %s", 
e.getKey(), throwable .getMessage(),
                    throwable .getCause());
            sb.append(System.lineSeparator());
            sb.append(eText);
          }
          throw new IOException(sb.toString());
        }
      }
    ```


---

Reply via email to