details:   https://code.openbravo.com/erp/devel/pi/rev/08518044d2b0
changeset: 32420:08518044d2b0
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Fri Jul 07 10:16:07 2017 +0200
summary:   fixed 36437: Avoid using Vector<Object> when only single type of 
data is used

  In the cases when a single type of data is used, define Vector with the more
  specific type.

details:   https://code.openbravo.com/erp/devel/pi/rev/a91838c63b77
changeset: 32421:a91838c63b77
user:      Asier Lostalé <asier.lostale <at> openbravo.com>
date:      Fri Jul 07 10:21:47 2017 +0200
summary:   related to bug 36429: printStackTrace on sqlc queries

  Fixed cases that do not directly use generated classes but a static
  copy of them.

diffstat:

 src-core/src/org/openbravo/data/Sqlc.java                            |   2 +-
 src/org/openbravo/erpCommon/ad_actionButton/ActionButtonUtility.java |   8 +-
 src/org/openbravo/erpCommon/ad_forms/SQLExecutor_Query.java          |   4 +-
 src/org/openbravo/erpCommon/ad_forms/ShowSessionVariables.java       |  50 
++++-----
 src/org/openbravo/erpCommon/ad_process/AlertProcess.java             |  14 +-
 src/org/openbravo/erpCommon/businessUtility/Buscador.java            |   2 +-
 src/org/openbravo/erpCommon/businessUtility/TabFilter.java           |   8 +-
 7 files changed, 41 insertions(+), 47 deletions(-)

diffs (truncated from 371 to 300 lines):

diff -r c4977d547166 -r a91838c63b77 src-core/src/org/openbravo/data/Sqlc.java
--- a/src-core/src/org/openbravo/data/Sqlc.java Thu Jul 06 16:36:53 2017 +0200
+++ b/src-core/src/org/openbravo/data/Sqlc.java Fri Jul 07 10:21:47 2017 +0200
@@ -1111,7 +1111,7 @@
     }
     if (sql.sqlReturn.equalsIgnoreCase("MULTIPLE")) {
       importJavaUtil = true;
-      out2.append("    Vector<java.lang.Object> vector = new 
Vector<java.lang.Object>(0);\n");
+      out2.append("    Vector<" + sqlcName + "> vector = new Vector<" + 
sqlcName + ">(0);\n");
     } else if (sql.sqlReturn.equalsIgnoreCase("SINGLE")) {
       out2.append("    " + sqlcName + " object" + sqlcName + " = new " + 
sqlcName + "();\n");
     } else if (sql.sqlReturn.equalsIgnoreCase("STRING")) {
diff -r c4977d547166 -r a91838c63b77 
src/org/openbravo/erpCommon/ad_actionButton/ActionButtonUtility.java
--- a/src/org/openbravo/erpCommon/ad_actionButton/ActionButtonUtility.java      
Thu Jul 06 16:36:53 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_actionButton/ActionButtonUtility.java      
Fri Jul 07 10:21:47 2017 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -85,7 +85,7 @@
     }
     SQLReturnObject[] data = null;
     if (ld != null) {
-      Vector<Object> v = new Vector<Object>();
+      Vector<SQLReturnObject> v = new Vector<>();
       SQLReturnObject data1 = new SQLReturnObject();
       if (!strProcessing.equals("") && strProcessing.equals("Y")) {
         data1.setData("ID", "XL");
@@ -164,7 +164,7 @@
       int ind1 = 0, ind2 = 0;
       while (ind1 < ld.length && ind2 < v.size()) {
         for (int j = 0; j < v.size(); j++) {
-          SQLReturnObject sqlro = (SQLReturnObject) v.get(j);
+          SQLReturnObject sqlro = v.get(j);
           if (sqlro.getField("ID").equals(ld[ind1].getField("ID"))) {
             if (log4j.isDebugEnabled())
               log4j.debug("DocAction - Element: " + ind1 + " - ID: " + 
sqlro.getField("ID"));
@@ -206,7 +206,7 @@
     }
     SQLReturnObject[] data = null;
     if (ld != null) {
-      Vector<Object> v = new Vector<Object>();
+      Vector<SQLReturnObject> v = new Vector<>();
       SQLReturnObject data1 = new SQLReturnObject();
       if (strProjectStatus.equals("NF") || strProjectStatus.equals("OP")) {
         data1.setData("ID", "OR");
diff -r c4977d547166 -r a91838c63b77 
src/org/openbravo/erpCommon/ad_forms/SQLExecutor_Query.java
--- a/src/org/openbravo/erpCommon/ad_forms/SQLExecutor_Query.java       Thu Jul 
06 16:36:53 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/SQLExecutor_Query.java       Fri Jul 
07 10:21:47 2017 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -58,7 +58,7 @@
 
     PreparedStatement st = null;
     ResultSet result;
-    Vector<Object> vector = new Vector<Object>(0);
+    Vector<SQLExecutor_Query> vector = new Vector<>(0);
 
     try {
       if (log4j.isDebugEnabled())
diff -r c4977d547166 -r a91838c63b77 
src/org/openbravo/erpCommon/ad_forms/ShowSessionVariables.java
--- a/src/org/openbravo/erpCommon/ad_forms/ShowSessionVariables.java    Thu Jul 
06 16:36:53 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_forms/ShowSessionVariables.java    Fri Jul 
07 10:21:47 2017 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo S.L.U.
+ * All portions are Copyright (C) 2001-2017 Openbravo S.L.U.
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -94,11 +94,11 @@
     }
   }
 
-  private boolean existsWindow(Vector<Object> windows, String windowId) {
+  private boolean existsWindow(Vector<String> windows, String windowId) {
     if (windows.size() == 0)
       return false;
     for (int i = 0; i < windows.size(); i++) {
-      String aux = (String) windows.elementAt(i);
+      String aux = windows.elementAt(i);
       if (aux.equals(windowId))
         return true;
     }
@@ -120,7 +120,7 @@
       boolean preferences, boolean global, boolean accounting, boolean 
windowGlobal, String window) {
     ShowSessionVariablesStructureData[] resData = null;
     try {
-      Vector<Object> vecPreferences = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecPreferences = new 
Vector<>();
       if (preferences && (window.equals("") || window.equals("0"))) {
         for (int i = 0; i < data.length; i++) {
           if (data[i].isPreference && (data[i].window == null || 
data[i].window.equals(""))) {
@@ -128,8 +128,7 @@
             data[i].window = "";
             data[i].windowName = "";
             for (int j = 0; j < vecPreferences.size() && !insertado; j++) {
-              ShowSessionVariablesStructureData element = 
(ShowSessionVariablesStructureData) vecPreferences
-                  .elementAt(j);
+              ShowSessionVariablesStructureData element = 
vecPreferences.elementAt(j);
               if (element.name.compareTo(data[i].name) >= 0) {
                 vecPreferences.insertElementAt(data[i], j);
                 insertado = true;
@@ -141,7 +140,7 @@
           }
         }
       }
-      Vector<Object> vecPreferencesW = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecPreferencesW = new 
Vector<>();
       if (preferences && !window.equals("")) {
         for (int i = 0; i < data.length; i++) {
           if (data[i].isPreference
@@ -150,8 +149,7 @@
             boolean insertado = false;
             data[i].windowName = windowName(windows, data[i].window);
             for (int j = 0; j < vecPreferencesW.size() && !insertado; j++) {
-              ShowSessionVariablesStructureData element = 
(ShowSessionVariablesStructureData) vecPreferencesW
-                  .elementAt(j);
+              ShowSessionVariablesStructureData element = 
vecPreferencesW.elementAt(j);
               if (element.windowName.compareTo(data[i].windowName) > 0) {
                 vecPreferencesW.insertElementAt(data[i], j);
                 insertado = true;
@@ -169,7 +167,7 @@
         }
       }
 
-      Vector<Object> vecGlobal = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecGlobal = new Vector<>();
       if (global) {
         for (int i = 0; i < data.length; i++) {
           if (data[i].isGlobal) {
@@ -177,8 +175,7 @@
             data[i].window = "";
             data[i].windowName = "";
             for (int j = 0; j < vecGlobal.size() && !insertado; j++) {
-              ShowSessionVariablesStructureData element = 
(ShowSessionVariablesStructureData) vecGlobal
-                  .elementAt(j);
+              ShowSessionVariablesStructureData element = 
vecGlobal.elementAt(j);
               if (element.name.compareTo(data[i].name) >= 0) {
                 vecGlobal.insertElementAt(data[i], j);
                 insertado = true;
@@ -191,7 +188,7 @@
         }
       }
 
-      Vector<Object> vecAccounting = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecAccounting = new Vector<>();
       if (accounting) {
         for (int i = 0; i < data.length; i++) {
           if (data[i].isAccounting) {
@@ -199,8 +196,7 @@
             data[i].window = "";
             data[i].windowName = "";
             for (int j = 0; j < vecAccounting.size() && !insertado; j++) {
-              ShowSessionVariablesStructureData element = 
(ShowSessionVariablesStructureData) vecAccounting
-                  .elementAt(j);
+              ShowSessionVariablesStructureData element = 
vecAccounting.elementAt(j);
               if (element.name.compareTo(data[i].name) >= 0) {
                 vecAccounting.insertElementAt(data[i], j);
                 insertado = true;
@@ -213,7 +209,7 @@
         }
       }
 
-      Vector<Object> vecWindowG = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecWindowG = new Vector<>();
       if (windowGlobal) {
         for (int i = 0; i < data.length; i++) {
           if (!data[i].isAccounting && !data[i].isGlobal && 
!data[i].isPreference
@@ -222,8 +218,7 @@
             data[i].window = "";
             data[i].windowName = "";
             for (int j = 0; j < vecWindowG.size() && !insertado; j++) {
-              ShowSessionVariablesStructureData element = 
(ShowSessionVariablesStructureData) vecWindowG
-                  .elementAt(j);
+              ShowSessionVariablesStructureData element = 
vecWindowG.elementAt(j);
               if (element.name.compareTo(data[i].name) >= 0) {
                 vecWindowG.insertElementAt(data[i], j);
                 insertado = true;
@@ -236,7 +231,7 @@
         }
       }
 
-      Vector<Object> vecWindow = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecWindow = new Vector<>();
       if (!window.equals("")) {
         for (int i = 0; i < data.length; i++) {
           if (!data[i].isAccounting
@@ -247,8 +242,7 @@
             boolean insertado = false;
             data[i].windowName = windowName(windows, data[i].window);
             for (int j = 0; j < vecWindow.size() && !insertado; j++) {
-              ShowSessionVariablesStructureData element = 
(ShowSessionVariablesStructureData) vecWindow
-                  .elementAt(j);
+              ShowSessionVariablesStructureData element = 
vecWindow.elementAt(j);
               if (element.windowName.compareTo(data[i].windowName) > 0) {
                 vecWindow.insertElementAt(data[i], j);
                 insertado = true;
@@ -266,7 +260,7 @@
         }
       }
 
-      Vector<Object> vecCompleto = new Vector<Object>();
+      Vector<ShowSessionVariablesStructureData> vecCompleto = new Vector<>();
       for (int i = 0; i < vecPreferences.size(); i++) {
         vecCompleto.addElement(vecPreferences.elementAt(i));
       }
@@ -302,12 +296,12 @@
   }
 
   private ShowSessionVariablesStructureData[] 
compoundSession(HttpServletRequest request,
-      VariablesSecureApp vars, Vector<Object> windows) {
+      VariablesSecureApp vars, Vector<String> windows) {
     if (log4j.isDebugEnabled())
       log4j.debug("ShowSession - compoundSession - view session");
     ShowSessionVariablesStructureData[] data = null;
     HttpSession session = request.getSession(true);
-    Vector<Object> texto = new Vector<Object>();
+    Vector<ShowSessionVariablesStructureData> texto = new Vector<>();
     try {
       String sessionName;
       Enumeration<?> e = session.getAttributeNames();
@@ -357,7 +351,7 @@
       log4j.debug("ShowSession - printPageDataSheet - Output: data sheet");
     response.setContentType("text/html; charset=UTF-8");
     PrintWriter out = response.getWriter();
-    Vector<Object> windows = new Vector<Object>();
+    Vector<String> windows = new Vector<>();
     ShowSessionVariablesStructureData[] data = compoundSession(request, vars, 
windows);
     XmlDocument xmlDocument;
     if (data == null || data.length == 0) {
@@ -369,11 +363,11 @@
           
"org/openbravo/erpCommon/ad_forms/ShowSessionVariables").createXmlDocument();
     }
     StringBuffer strWindows = new StringBuffer();
-    Vector<Object> vecWindows = new Vector<Object>();
+    Vector<ShowSessionVariablesData> vecWindows = new Vector<>();
     if (windows.size() != 0) {
       strWindows.append("(");
       for (int i = 0; i < windows.size(); i++) {
-        String aux = (String) windows.elementAt(i);
+        String aux = windows.elementAt(i);
         try {
           if (i > 0)
             strWindows.append(", ");
@@ -424,7 +418,7 @@
         .select(this, strWindows.toString()) : 
ShowSessionVariablesData.selectTrl(this,
         strWindows.toString(), vars.getLanguage()));
     {
-      Vector<Object> v = new Vector<Object>();
+      Vector<ShowSessionVariablesData> v = new Vector<>();
       ShowSessionVariablesData d = new ShowSessionVariablesData();
       d.id = "0";
       d.name = "All";
diff -r c4977d547166 -r a91838c63b77 
src/org/openbravo/erpCommon/ad_process/AlertProcess.java
--- a/src/org/openbravo/erpCommon/ad_process/AlertProcess.java  Thu Jul 06 
16:36:53 2017 +0200
+++ b/src/org/openbravo/erpCommon/ad_process/AlertProcess.java  Fri Jul 07 
10:21:47 2017 +0200
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2008-2014 Openbravo SLU 
+ * All portions are Copyright (C) 2008-2017 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -112,7 +112,7 @@
         .getProperty("dateTimeFormat.java");
 
     ResultSet result;
-    Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0);
+    Vector<AlertProcessData> vector = new Vector<>(0);
     PreparedStatement st = null;
 
     try {
@@ -149,8 +149,8 @@
       try {
         connectionProvider.getConnection().setReadOnly(false);
         connectionProvider.releasePreparedStatement(st);
-      } catch (Exception ignore) {
-        ignore.printStackTrace();
+      } catch (Exception e) {
+        log4j.error("Error during release*Statement of query: " + strSql, e);
       }
     }
     AlertProcessData objectAlertProcessData[] = new 
AlertProcessData[vector.size()];

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openbravo-commits mailing list
Openbravo-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to