Skip to content

Commit

Permalink
Improved: Enforce noninstantiability to ConfigXMLReader Class (#178)
Browse files Browse the repository at this point in the history
(OFBIZ-11746)

Made class as final, added private constructor and corrected private data members as per naming convention.
  • Loading branch information
surajkhurana committed Jun 6, 2020
1 parent 347ea63 commit 924df4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -61,15 +61,21 @@
/**
* 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 {
Expand Down
Expand Up @@ -508,7 +508,7 @@ public void doRequest(HttpServletRequest request, HttpServletResponse response,

// 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
Expand All @@ -532,7 +532,7 @@ public void doRequest(HttpServletRequest request, HttpServletResponse response,
} else {
eventReturnBasedRequestResponse = requestMap.requestResponseMap.get(eventReturn);
if (eventReturnBasedRequestResponse == null && "none".equals(eventReturn)) {
eventReturnBasedRequestResponse = ConfigXMLReader.emptyNoneRequestResponse;
eventReturnBasedRequestResponse = ConfigXMLReader.getEmptyNoneRequestResponse();
}
}
if (eventReturnBasedRequestResponse != null) {
Expand Down

0 comments on commit 924df4b

Please sign in to comment.