Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.day.cq.commons.jcr.JcrConstants;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

public class ComponentDataImpl implements FormComponentData {

Expand All @@ -41,7 +42,25 @@ public class ComponentDataImpl implements FormComponentData {

protected final Resource resource;

/**
* Creates a new ComponentDataImpl instance.
*
* Note: This constructor stores references to FormComponent and Resource objects.
* These objects are designed to be immutable and shared across the system.
* The FormComponent interface provides read-only access to form component data,
* and the Resource interface represents an immutable JCR resource.
*
* @param component The form component (immutable, read-only interface)
* @param resource The JCR resource (immutable, read-only interface)
*/
@SuppressFBWarnings(
value = "EI_EXPOSE_REP2",
justification = "This constructor stores references to FormComponent and Resource objects. These objects are designed to be immutable and shared across the system. The FormComponent interface provides read-only access to form component data, and the Resource interface represents an immutable JCR resource. This is safe from a security perspective as these objects cannot be modified through the stored references.")
public ComponentDataImpl(FormComponent component, Resource resource) {
// Both FormComponent and Resource are interfaces designed to be immutable
// and shared across the system. They provide read-only access to data.
// This is safe from a security perspective as these objects cannot be
// modified through the stored references.
this.component = component;
this.resource = resource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ private static Set<String> aggregateReservedProperties() {
}

public static Set<String> getReservedProperties() {
return reservedProperties;
return new HashSet<>(reservedProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.adobe.cq.forms.core.components.internal.models.v1.form;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -104,7 +105,7 @@ public String getFragmentPath() {
if (itemModels == null) {
itemModels = getChildrenModels(request, ComponentExporter.class);
}
return itemModels;
return new LinkedHashMap<>(itemModels);
}

protected <T> Map<String, T> getChildrenModels(@Nullable SlingHttpServletRequest request, @NotNull Class<T> modelClass) {
Expand Down Expand Up @@ -136,7 +137,7 @@ public List<Resource> getFragmentChildren() {
if (filteredChildComponents == null) {
filteredChildComponents = getFilteredChildrenResources(fragmentContainer);
}
return filteredChildComponents;
return new ArrayList<>(filteredChildComponents);
}

@JsonIgnore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected String getConstraintMessage(ConstraintType type) {
putConstraintMessage(ConstraintType.VALIDATION_EXPRESSION, msgs.getValidationExpressionConstraintMessage());
putConstraintMessage(ConstraintType.UNIQUE_ITEMS, msgs.getUniqueItemsConstraintMessage());
}
return constraintMessages;
return new LinkedHashMap<>(constraintMessages);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public List<? extends ComponentExporter> getItems() {
if (childrenModels == null) {
childrenModels = new ArrayList<>(getChildrenModels(request, ComponentExporter.class).values());
}
return childrenModels;
return new ArrayList<>(childrenModels);
}

@NotNull
Expand Down Expand Up @@ -178,7 +178,7 @@ protected <T> Map<String, T> getChildrenModels(@Nullable SlingHttpServletRequest
if (itemModels == null) {
itemModels = getChildrenModels(request, ComponentExporter.class);
}
return itemModels;
return new LinkedHashMap<>(itemModels);
}

protected List<Resource> getFilteredChildrenResources() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -545,7 +544,7 @@ private boolean isAllowedType(Object value) {
* @return {@code Map<String, String>} returns all custom property key value pairs associated with the resource
*/
private Map<String, Object> getCustomProperties() {
Map<String, Object> customProperties = new HashMap<>();
Map<String, Object> customProperties = new LinkedHashMap<>();
Map<String, String> templateBasedCustomProperties;
List<String> excludedPrefixes = Arrays.asList("fd:", "jcr:", "sling:");
Set<String> reservedProperties = ReservedProperties.getReservedProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.adobe.cq.forms.core.components.internal.models.v1.formsportal;

import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -192,7 +193,7 @@ public void setFormThumbnail(String formThumbnail) {
}

public void setOperations(List<Operation> operations) {
this.operations = operations;
this.operations = operations != null ? new ArrayList<>(operations) : null;
}

public void setId(String id) {
Expand All @@ -205,7 +206,7 @@ public void setLastModified(String timeInfo) {

@Override
public List<Operation> getOperations() {
return operations;
return operations != null ? new ArrayList<>(operations) : null;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Map<String, Object> getAttributes() {
}
}
}
return attributes;
return new LinkedHashMap<>(attributes);
}

private void addAttributes(String name, String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected void init() {
}
}
}
return htmlPageItems;
return htmlPageItems != null ? new LinkedList<>(htmlPageItems) : null;
}

@JsonIgnore
Expand Down
2 changes: 1 addition & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>4.0.4</version>
<version>4.8.3.0</version>
<configuration>
<effort>Max</effort>
<xmlOutput>true</xmlOutput>
Expand Down
Loading