Skip to content

Commit 5e64bc4

Browse files
rismehtaShivam Agarwal
authored andcommitted
FORMS-23027 updating dependencies to support java 21 (#1695)
* Upgrading spot bugs * Formatting code * FORMS-23027 adding java 21 in circle ci build * FORMS-23027 updating dependencies to support java 8, 11 and 21 tests --------- Co-authored-by: Shivam Agarwal <[email protected]>
1 parent c989bdf commit 5e64bc4

File tree

13 files changed

+76
-19
lines changed

13 files changed

+76
-19
lines changed

.circleci/config.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ executors:
136136
forms_executor_java8:
137137
docker:
138138
- image: cimg/openjdk:8.0-browsers
139+
forms_executor_java21:
140+
docker:
141+
- image: cimg/openjdk:21.0-browsers
139142
test_executor_cloudready:
140143
machine:
141144
image: ubuntu-2204:2024.01.1
@@ -187,6 +190,30 @@ jobs:
187190
conf: .circleci/codecov.yml
188191
flags: unittests
189192

193+
build-java-21:
194+
executor: forms_executor_java21
195+
working_directory: /home/circleci/build
196+
steps:
197+
- checkout
198+
- restore_cache:
199+
keys:
200+
- maven-repo-java21-v1-{{ checksum "pom.xml" }}
201+
- maven-repo-java21-v1-
202+
- run:
203+
name: Update permissions
204+
command: sudo chown -R circleci /usr/local/lib/node_modules
205+
- run:
206+
name: Build with Java 21
207+
command: node .circleci/ci/build.js
208+
- save_cache:
209+
paths:
210+
- ~/.m2
211+
key: maven-repo-java21-v1-{{ .Branch }}-{{ checksum "pom.xml" }}
212+
- store_test_results:
213+
path: bundles/core/target/surefire-reports
214+
- store_artifacts:
215+
path: bundles/core/target/surefire-reports
216+
190217
# cypress-chrome-cloudready-with-addon:
191218
# executor: test_executor_cloudready
192219
# environment:
@@ -398,6 +425,10 @@ workflows:
398425
filters:
399426
tags:
400427
only: /.*/
428+
- build-java-21:
429+
filters:
430+
tags:
431+
only: /.*/
401432
# - cypress-chrome-cloudready-with-addon:
402433
# filters:
403434
# tags:

bundles/af-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@
551551
<dependency>
552552
<groupId>org.junit.platform</groupId>
553553
<artifactId>junit-platform-commons</artifactId>
554-
<version>1.5.2</version>
554+
<version>1.10.2</version>
555555
<scope>test</scope>
556556
</dependency>
557557
<!--

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/datalayer/ComponentDataImpl.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import com.day.cq.commons.jcr.JcrConstants;
3333
import com.fasterxml.jackson.core.JsonProcessingException;
3434
import com.fasterxml.jackson.databind.ObjectMapper;
35+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
3536

3637
public class ComponentDataImpl implements FormComponentData {
3738

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

4243
protected final Resource resource;
4344

45+
/**
46+
* Creates a new ComponentDataImpl instance.
47+
*
48+
* Note: This constructor stores references to FormComponent and Resource objects.
49+
* These objects are designed to be immutable and shared across the system.
50+
* The FormComponent interface provides read-only access to form component data,
51+
* and the Resource interface represents an immutable JCR resource.
52+
*
53+
* @param component The form component (immutable, read-only interface)
54+
* @param resource The JCR resource (immutable, read-only interface)
55+
*/
56+
@SuppressFBWarnings(
57+
value = "EI_EXPOSE_REP2",
58+
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.")
4459
public ComponentDataImpl(FormComponent component, Resource resource) {
60+
// Both FormComponent and Resource are interfaces designed to be immutable
61+
// and shared across the system. They provide read-only access to data.
62+
// This is safe from a security perspective as these objects cannot be
63+
// modified through the stored references.
4564
this.component = component;
4665
this.resource = resource;
4766
}

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/form/ReservedProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,6 @@ private static Set<String> aggregateReservedProperties() {
205205
}
206206

207207
public static Set<String> getReservedProperties() {
208-
return reservedProperties;
208+
return new HashSet<>(reservedProperties);
209209
}
210210
}

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/form/FragmentImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.adobe.cq.forms.core.components.internal.models.v1.form;
1717

1818
import java.util.ArrayList;
19+
import java.util.LinkedHashMap;
1920
import java.util.List;
2021
import java.util.Locale;
2122
import java.util.Map;
@@ -118,7 +119,7 @@ public String getFragmentPath() {
118119
if (itemModels == null) {
119120
itemModels = getChildrenModels(request, ComponentExporter.class);
120121
}
121-
return itemModels;
122+
return new LinkedHashMap<>(itemModels);
122123
}
123124

124125
protected <T> Map<String, T> getChildrenModels(@Nullable SlingHttpServletRequest request, @NotNull Class<T> modelClass) {
@@ -195,7 +196,7 @@ public List<Resource> getFragmentChildren() {
195196
if (filteredChildComponents == null) {
196197
filteredChildComponents = getFilteredChildrenResources(fragmentContainer);
197198
}
198-
return filteredChildComponents;
199+
return new ArrayList<>(filteredChildComponents);
199200
}
200201

201202
@JsonIgnore

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractBaseImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ protected String getConstraintMessage(ConstraintType type) {
282282
putConstraintMessage(ConstraintType.VALIDATION_EXPRESSION, msgs.getValidationExpressionConstraintMessage());
283283
putConstraintMessage(ConstraintType.UNIQUE_ITEMS, msgs.getUniqueItemsConstraintMessage());
284284
}
285-
return constraintMessages;
285+
return new LinkedHashMap<>(constraintMessages);
286286
}
287287

288288
/**

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractContainerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public List<? extends ComponentExporter> getItems() {
116116
if (childrenModels == null) {
117117
childrenModels = new ArrayList<>(getChildrenModels(request, ComponentExporter.class).values());
118118
}
119-
return childrenModels;
119+
return new ArrayList<>(childrenModels);
120120
}
121121

122122
@NotNull
@@ -179,7 +179,7 @@ protected <T> Map<String, T> getChildrenModels(@Nullable SlingHttpServletRequest
179179
if (itemModels == null) {
180180
itemModels = getChildrenModels(request, ComponentExporter.class);
181181
}
182-
return itemModels;
182+
return new LinkedHashMap<>(itemModels);
183183
}
184184

185185
protected List<Resource> getFilteredChildrenResources() {

bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractFormComponentImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Arrays;
2323
import java.util.Calendar;
2424
import java.util.Collections;
25-
import java.util.HashMap;
2625
import java.util.HashSet;
2726
import java.util.LinkedHashMap;
2827
import java.util.List;
@@ -582,7 +581,7 @@ private boolean isAllowedType(Object value) {
582581
* @return {@code Map<String, String>} returns all custom property key value pairs associated with the resource
583582
*/
584583
private Map<String, Object> getCustomProperties() {
585-
Map<String, Object> customProperties = new HashMap<>();
584+
Map<String, Object> customProperties = new LinkedHashMap<>();
586585
Map<String, String> templateBasedCustomProperties;
587586
List<String> excludedPrefixes = Arrays.asList("fd:", "jcr:", "sling:");
588587
Set<String> reservedProperties = ReservedProperties.getReservedProperties();

bundles/core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@
556556
<dependency>
557557
<groupId>org.junit.platform</groupId>
558558
<artifactId>junit-platform-commons</artifactId>
559-
<version>1.5.2</version>
559+
<version>1.10.2</version>
560560
<scope>test</scope>
561561
</dependency>
562562
<!--

bundles/core/src/main/java/com/adobe/cq/forms/core/components/internal/models/v1/formsportal/PortalListerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.adobe.cq.forms.core.components.internal.models.v1.formsportal;
1717

1818
import java.net.URISyntaxException;
19+
import java.util.ArrayList;
1920
import java.util.Collections;
2021
import java.util.HashMap;
2122
import java.util.List;
@@ -192,7 +193,7 @@ public void setFormThumbnail(String formThumbnail) {
192193
}
193194

194195
public void setOperations(List<Operation> operations) {
195-
this.operations = operations;
196+
this.operations = operations != null ? new ArrayList<>(operations) : null;
196197
}
197198

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

206207
@Override
207208
public List<Operation> getOperations() {
208-
return operations;
209+
return operations != null ? new ArrayList<>(operations) : null;
209210
}
210211

211212
@Override

0 commit comments

Comments
 (0)