svn commit: r1811468 - in /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine: GenericEngineFactory.java GroovyEngine.java HttpEngine.java SOAPClientEngine.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1811468 - in /ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine: GenericEngineFactory.java GroovyEngine.java HttpEngine.java SOAPClientEngine.java

mbrohl
Author: mbrohl
Date: Sun Oct  8 10:39:01 2017
New Revision: 1811468

URL: http://svn.apache.org/viewvc?rev=1811468&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package
org.apache.ofbiz.service.engine.
(OFBIZ-9688)

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GenericEngineFactory.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/HttpEngine.java
    ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/SOAPClientEngine.java

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GenericEngineFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GenericEngineFactory.java?rev=1811468&r1=1811467&r2=1811468&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GenericEngineFactory.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GenericEngineFactory.java Sun Oct  8 10:39:01 2017
@@ -38,7 +38,7 @@ public class GenericEngineFactory {
 
     public GenericEngineFactory(ServiceDispatcher dispatcher) {
         this.dispatcher = dispatcher;
-        engines = new HashMap<String, GenericEngine>();
+        engines = new HashMap<>();
     }
 
     /**

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java?rev=1811468&r1=1811467&r2=1811468&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/GroovyEngine.java Sun Oct  8 10:39:01 2017
@@ -48,11 +48,11 @@ import groovy.lang.Script;
 public final class GroovyEngine extends GenericAsyncEngine {
 
     public static final String module = GroovyEngine.class.getName();
-    protected static final Object[] EMPTY_ARGS = {};
+    private static final Object[] EMPTY_ARGS = {};
     private static final Set<String> protectedKeys = createProtectedKeys();
 
     private static Set<String> createProtectedKeys() {
-        Set<String> newSet = new HashSet<String>();
+        Set<String> newSet = new HashSet<>();
         /* Commenting out for now because some scripts write to the parameters Map - which should not be allowed.
         newSet.add(ScriptUtil.PARAMETERS_KEY);
         */
@@ -87,10 +87,10 @@ public final class GroovyEngine extends
         if (UtilValidate.isEmpty(modelService.location)) {
             throw new GenericServiceException("Cannot run Groovy service with empty location");
         }
-        Map<String, Object> params = new HashMap<String, Object>();
+        Map<String, Object> params = new HashMap<>();
         params.putAll(context);
 
-        Map<String, Object> gContext = new HashMap<String, Object>();
+        Map<String, Object> gContext = new HashMap<>();
         gContext.putAll(context);
         gContext.put(ScriptUtil.PARAMETERS_KEY, params);
 

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/HttpEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/HttpEngine.java?rev=1811468&r1=1811467&r2=1811468&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/HttpEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/HttpEngine.java Sun Oct  8 10:39:01 2017
@@ -65,7 +65,7 @@ public class HttpEngine extends GenericA
             throw new GenericServiceException("Cannot serialize context.", e);
         }
 
-        Map<String, Object> parameters = new HashMap<String, Object>();
+        Map<String, Object> parameters = new HashMap<>();
         parameters.put("serviceName", modelService.invoke);
         if (xmlContext != null)
             parameters.put("serviceContext", xmlContext);
@@ -114,7 +114,7 @@ public class HttpEngine extends GenericA
         String serviceMode = request.getParameter("serviceMode");
         String xmlContext = request.getParameter("serviceContext");
 
-        Map<String, Object> result = new HashMap<String, Object>();
+        Map<String, Object> result = new HashMap<>();
         Map<String, Object> context = null;
 
         if (serviceName == null)
@@ -182,10 +182,10 @@ public class HttpEngine extends GenericA
             response.setContentType("plain/text");
 
             if (errorMessage.length() > 0) {
-                response.setContentLength(errorMessage.toString().getBytes().length);
+                response.setContentLength(errorMessage.toString().getBytes("UTF-8").length);
                 out.write(errorMessage.toString());
             } else {
-                response.setContentLength(resultString.getBytes().length);
+                response.setContentLength(resultString.getBytes("UTF-8").length);
                 out.write(resultString);
             }
 

Modified: ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/SOAPClientEngine.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/SOAPClientEngine.java?rev=1811468&r1=1811467&r2=1811468&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/SOAPClientEngine.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/service/src/main/java/org/apache/ofbiz/service/engine/SOAPClientEngine.java Sun Oct  8 10:39:01 2017
@@ -114,7 +114,7 @@ public final class SOAPClientEngine exte
 
         int i = 0;
 
-        Map<String, Object> parameterMap = new HashMap<String, Object>();
+        Map<String, Object> parameterMap = new HashMap<>();
         for (ModelParam p: inModelParamList) {
             if (Debug.infoOn()) Debug.logInfo("[SOAPClientEngine.invoke} : Parameter: " + p.name + " (" + p.mode + ") - " + i, module);