Skip to content

Commit

Permalink
CCS-4351-bugfixes_NullPointerException (#579)
Browse files Browse the repository at this point in the history
* fix null pointer exception
  • Loading branch information
xdavidson committed Apr 22, 2021
1 parent b826f54 commit 0d6bcc4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class KeycloakFilter extends KeycloakOIDCFilter implements Filter {

private static final Logger log = LoggerFactory.getLogger(KeycloakFilter.class.getName());
private static final String KARAF_ETC = "karaf.etc";
private static final String KEYCLOAKOIDCFILTER_CONFIG_FILE_NAME = "keycloak.json";
private static final String KEYCLOAKOIDCFILTER_CONFIG_FILE_NAME = "keycloak.json";
protected KeycloakDeployment keycloakDeployment;
private PathBasedKeycloakConfigResolver keycloakConfigResolver;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
}
// FIXME - need to rework document preview servlets to support latest suffix (variant preview servlet already works)
String forwardString = firstResource.get().getPath() + ".preview/" + mode;
XrefValidationHelper.initList();
new XrefValidationHelper().initList();
request.getRequestDispatcher(forwardString).forward(request, response);
} catch (RepositoryException e) {
throw new ServletException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected void versionUpload(SlingHttpServletRequest request,
resolver.commit();

Map<String, Object> context = asciidoctorService.buildContextFromRequest(request);
XrefValidationHelper.initList();
new XrefValidationHelper().initList();
asciidoctorService.getDocumentHtml(document, localeObj, document.getWorkspace().getCanonicalVariantName(),
true, context, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@

public class XrefValidationHelper {

private static List<String> xRefs;
private List<String> xRefs;

public XrefValidationHelper() {
initList();
}

public List<String> getObjectsToValidate() {

public static List<String> getObjectsToValidate() {
return xRefs;
}

public static void initList() {
public void initList() {
xRefs = new ArrayList<>();
}

public static void setObjectsToValidate(List<String> objectsToValidate) {
public void setObjectsToValidate(List<String> objectsToValidate) {
if(objectsToValidate.size()>0){
xRefs.addAll(objectsToValidate);
xRefs.addAll(objectsToValidate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ private Violations checkIfXrefValid(Violations violations) {
private ErrorDetails checkXref() {
ErrorDetails errorDetails = new ErrorDetails();
try {
List<String> xrefTargets = XrefValidationHelper.getObjectsToValidate();
XrefValidationHelper xrefValidationHelper = new XrefValidationHelper();
List<String> xrefTargets = xrefValidationHelper.getObjectsToValidate();
if(null == xrefTargets || xrefTargets.size()==0){
return errorDetails;
}
Expand Down

0 comments on commit 0d6bcc4

Please sign in to comment.