fixed BUG-44022: Not needed cast in BuildValidation java class
authorAsier Lostalé <asier.lostale@openbravo.com>
Fri, 15 May 2020 07:24:19 +0200
changeset 37353 45513b1727ec
parent 37352 ff64a1b5e0d9
child 37354 2a5eb79c1afb
fixed BUG 44022: Not needed cast in BuildValidation java class

The casting of the result of List<String> getErrors() method to
ArrayList was too restricitive and innecessary, causing runtime errors
in case the method returned any other List, which is allowed.

This casting has been removed.
src-core/src/org/openbravo/buildvalidation/BuildValidation.java
--- a/src-core/src/org/openbravo/buildvalidation/BuildValidation.java	Thu May 14 14:51:11 2020 +0530
+++ b/src-core/src/org/openbravo/buildvalidation/BuildValidation.java	Fri May 15 07:24:19 2020 +0200
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2012-2016 Openbravo S.L.U.
+ * Copyright (C) 2012-2020 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -12,6 +12,7 @@
 package org.openbravo.buildvalidation;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.openbravo.base.ExecutionLimitBaseProcess;
@@ -48,7 +49,7 @@
   @Override
   protected void doExecute() {
     log4j.info("Executing buildValidation: " + this.getClass().getName());
-    errors = (ArrayList<String>) execute();
+    errors = execute();
   }
 
   /**
@@ -82,13 +83,13 @@
    */
   public List<String> getErrors() {
     if (errors == null) {
-      errors = new ArrayList<String>();
+      errors = Collections.emptyList();
     }
     return errors;
   }
 
   protected List<String> handleError(Throwable t) {
-    ArrayList<String> exceptionErrors = new ArrayList<String>();
+    ArrayList<String> exceptionErrors = new ArrayList<>();
     exceptionErrors.add(
         "Error executing build-validation " + this.getClass().getName() + ": " + t.getMessage());
     exceptionErrors.add("The build validation couldn't be properly executed");