Skip to content

Commit dbf19d3

Browse files
authored
dotCMS#32137 adding a defensive cast to integer (dotCMS#32138)
Adding a defensive casting since a client is throwing casting error from long to int
1 parent 279495a commit dbf19d3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dotCMS/src/main/java/com/dotmarketing/startup/runonce/Task241015ReplaceLanguagesWithLocalesPortlet.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.dotmarketing.startup.runonce;
22

3+
import com.dotcms.util.ConversionUtils;
34
import com.dotmarketing.business.CacheLocator;
45
import com.dotmarketing.common.db.DotConnect;
56
import com.dotmarketing.exception.DotDataException;
@@ -51,7 +52,7 @@ public void executeUpgrade() throws DotDataException, DotRuntimeException {
5152
if (!workflowLayoutPortlets.isEmpty()) {
5253
final Map<String, Object> row = workflowLayoutPortlets.get(0);
5354
final String layoutId = (String) row.get("layout_id");
54-
final int portletOrder = Optional.ofNullable((Integer) row.get("portlet_order")).orElse(0) + 1;
55+
final int portletOrder = Optional.ofNullable(ConversionUtils.toInt(row.get("portlet_order"), 0)).orElse(0) + 1;
5556
insertLocalesPortlet(layoutId, portletOrder);
5657
}
5758
} else {
@@ -63,7 +64,7 @@ public void executeUpgrade() throws DotDataException, DotRuntimeException {
6364

6465
private void replaceLanguage(final Map<String, Object> row) {
6566
final String layoutId = (String) row.get("layout_id");
66-
final int portletOrder = Optional.ofNullable((Integer) row.get("portlet_order")).orElse(1);
67+
final int portletOrder = Optional.ofNullable(ConversionUtils.toInt(row.get("portlet_order"), 0)).orElse(1);
6768
insertLocalesPortlet(layoutId, portletOrder);
6869

6970
final String id = (String) row.get("id");

0 commit comments

Comments
 (0)