[ofbiz-framework] branch trunk updated: Improved: Enforce noninstantiability to ConfigXMLReader Class (#178)

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

[ofbiz-framework] branch trunk updated: Improved: Enforce noninstantiability to ConfigXMLReader Class (#178)

surajk
This is an automated email from the ASF dual-hosted git repository.

surajk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 924df4b  Improved: Enforce noninstantiability to ConfigXMLReader Class (#178)
924df4b is described below

commit 924df4b217d5d0284a691d5445cc06a45e2b47e4
Author: Suraj Khurana <[hidden email]>
AuthorDate: Sat Jun 6 10:01:55 2020 +0530

    Improved: Enforce noninstantiability to ConfigXMLReader Class (#178)
   
    (OFBIZ-11746)
   
    Made class as final, added private constructor and corrected private data members as per naming convention.
---
 .../org/apache/ofbiz/webapp/control/ConfigXMLReader.java     | 12 +++++++++---
 .../java/org/apache/ofbiz/webapp/control/RequestHandler.java |  4 ++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
index 38260f3..40058b5 100644
--- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
+++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/ConfigXMLReader.java
@@ -61,15 +61,21 @@ import org.w3c.dom.Element;
 /**
  * ConfigXMLReader.java - Reads and parses the XML site config files.
  */
-public class ConfigXMLReader {
+public final class ConfigXMLReader {
 
     private static final String MODULE = ConfigXMLReader.class.getName();
-    public static final Path CONTROLLERXMLFILENAME = Paths.get("WEB-INF", "controller.xml");
+    private static final Path CONTROLLERXMLFILENAME = Paths.get("WEB-INF", "controller.xml");
     private static final UtilCache<URL, ControllerConfig> CONTROLLERCACHE = UtilCache
             .createUtilCache("webapp.ControllerConfig");
     private static final UtilCache<String, List<ControllerConfig>> CONTROLLERSEARCHRESULTSCACHE = UtilCache
             .createUtilCache("webapp.ControllerSearchResults");
-    public static final RequestResponse emptyNoneRequestResponse = RequestResponse.createEmptyNoneRequestResponse();
+    private static final RequestResponse EMPTY_NONE_REQ_RES = RequestResponse.createEmptyNoneRequestResponse();
+
+    protected ConfigXMLReader() { }
+
+    public static RequestResponse getEmptyNoneRequestResponse() {
+        return EMPTY_NONE_REQ_RES;
+    }
 
     public static Set<String> findControllerFilesWithRequest(String requestUri, String controllerPartialPath)
             throws GeneralException {
diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
index e84ed38..72ee26d 100644
--- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
+++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
@@ -508,7 +508,7 @@ public class RequestHandler {
 
                     // set the default event return
                     if (eventReturn == null) {
-                        nextRequestResponse = ConfigXMLReader.emptyNoneRequestResponse;
+                        nextRequestResponse = ConfigXMLReader.getEmptyNoneRequestResponse();
                     }
                 } catch (EventHandlerException e) {
                     // check to see if there is an "error" response, if so go there and make an request error message
@@ -532,7 +532,7 @@ public class RequestHandler {
         } else {
             eventReturnBasedRequestResponse = requestMap.requestResponseMap.get(eventReturn);
             if (eventReturnBasedRequestResponse == null && "none".equals(eventReturn)) {
-                eventReturnBasedRequestResponse = ConfigXMLReader.emptyNoneRequestResponse;
+                eventReturnBasedRequestResponse = ConfigXMLReader.getEmptyNoneRequestResponse();
             }
         }
         if (eventReturnBasedRequestResponse != null) {