Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pom.xml: Upgrade gson version to 2.10.1 #8756

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
63b80ca
pom.xml: Upgrade gson version to 2.10.1
weizhouapache Mar 7, 2024
63259cb
Update 8756: fix core/utils unit test
weizhouapache Mar 13, 2024
d3ee78c
Update 8756 server: fix NPE of unit test passEncRootPlannerHostSuppor…
weizhouapache Mar 14, 2024
eed4dce
Update 8756: fix AsyncJobResponse.java
weizhouapache Mar 14, 2024
1c17e11
Update 8756: fix NetworkResponse.java
weizhouapache Mar 14, 2024
44325ca
Update 8756: fix HostMetricsResponse and SystemVmResponse
weizhouapache Mar 15, 2024
4d838ad
gson: fix clover errors
weizhouapache Mar 19, 2024
e4ee9c3
Revert "gson: fix clover errors"
weizhouapache Mar 22, 2024
54a341a
gson: new fix on saml2 plugin
weizhouapache Mar 22, 2024
61d8883
gson: rename jobId/jobStatus to migrationJobId/migrationJobStatus
weizhouapache Mar 22, 2024
80ca088
gson2: fix conflicted SerializedName in ClusterDrsPlanMigrationResponse
weizhouapache Mar 22, 2024
f64aeb5
Merge branch 'main' into 4.19-upgrade-gson
weizhouapache Oct 17, 2024
3bcbb04
Update PR8756: ui changes for DRS
weizhouapache Oct 18, 2024
ddcf380
Update core/src/main/java/com/cloud/agent/transport/ArrayTypeAdaptor.…
weizhouapache Oct 25, 2024
a3c44b3
gson2: change CloudRuntimeException to JsonParseException
weizhouapache Oct 25, 2024
3a7f065
core: add unit test ResponseTest
weizhouapache Dec 6, 2024
9194370
Fixup alerting and logging error in BGPServiceImpl
vishesh92 Jan 23, 2025
5ced50b
Merge remote-tracking branch 'apache/4.20' into 4.19-upgrade-gson
weizhouapache Jan 30, 2025
4ec94ee
PR#8756 gson2: fix FirewallRuleTO sourceCidrList
weizhouapache Jan 30, 2025
c5b1e38
Update unit tests
vishesh92 Feb 13, 2025
f3e28fe
Apply suggestions from code review
vishesh92 Feb 13, 2025
4805f09
Merge remote-tracking branch 'apache/pr/10252' into 4.19-upgrade-gson
weizhouapache Feb 14, 2025
d60f4d4
Merge branch 'main' into 4.19-upgrade-gson
weizhouapache Feb 26, 2025
e86f751
fix build error AlertManagerImplTest
weizhouapache Feb 26, 2025
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
2 changes: 2 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ public class ApiConstants {
public static final String MIN_CPU_NUMBER = "mincpunumber";
public static final String MIN_MEMORY = "minmemory";
public static final String MIGRATION_TYPE = "migrationtype";
public static final String MIGRATION_JOB_ID = "migrationjobid";
public static final String MIGRATION_JOB_STATUS = "migrationjobstatus";
public static final String MIGRATIONS = "migrations";
public static final String MEMORY = "memory";
public static final String MODE = "mode";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ public class AsyncJobResponse extends BaseResponse {
@Param(description = "the async command executed")
private String cmd;

@SerializedName("jobstatus")
@Param(description = "the current job status-should be 0 for PENDING")
private Integer jobStatus;

@SerializedName("jobprocstatus")
@Param(description = "the progress information of the PENDING job")
private Integer jobProcStatus;
Expand Down Expand Up @@ -119,11 +115,6 @@ public void setCmd(String cmd) {
this.cmd = cmd;
}

@Override
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}

public void setJobProcStatus(Integer jobProcStatus) {
this.jobProcStatus = jobProcStatus;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
@Param(description = "Destination host for VM migration")
String destHostName;

@SerializedName(ApiConstants.JOB_ID)
@SerializedName(ApiConstants.MIGRATION_JOB_ID)
@Param(description = "id of VM migration async job")
private Long jobId;
private Long migrationJobId;

@SerializedName(ApiConstants.JOB_STATUS)
@SerializedName(ApiConstants.MIGRATION_JOB_STATUS)
@Param(description = "Job status of VM migration async job")
private JobInfo.Status jobStatus;
private JobInfo.Status migrationJobStatus;


public ClusterDrsPlanMigrationResponse(String vmId, String vmName, String srcHostId, String srcHostName,
Expand All @@ -68,8 +68,8 @@
this.srcHostName = srcHostName;
this.destHostId = destHostId;
this.destHostName = destHostName;
this.jobId = jobId;
this.jobStatus = jobStatus;
this.migrationJobId = jobId;
this.migrationJobStatus = jobStatus;

Check warning on line 72 in api/src/main/java/org/apache/cloudstack/api/response/ClusterDrsPlanMigrationResponse.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/response/ClusterDrsPlanMigrationResponse.java#L71-L72

Added lines #L71 - L72 were not covered by tests
this.setObjectName(ApiConstants.MIGRATIONS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,6 @@ public class NetworkResponse extends BaseResponseWithAssociatedNetwork implement
@Param(description = "Name of the VPC to which this network belongs", since = "4.15")
private String vpcName;

@SerializedName(ApiConstants.ASSOCIATED_NETWORK_ID)
@Param(description = "the ID of the Network associated with this network")
private String associatedNetworkId;

@SerializedName(ApiConstants.ASSOCIATED_NETWORK)
@Param(description = "the name of the Network associated with this network")
private String associatedNetworkName;

@SerializedName(ApiConstants.TUNGSTEN_VIRTUAL_ROUTER_UUID)
@Param(description = "Tungsten-Fabric virtual router the network belongs to")
private String tungstenVirtualRouterUuid;
Expand Down Expand Up @@ -612,14 +604,6 @@ public void setVpcName(String vpcName) {
this.vpcName = vpcName;
}

public void setAssociatedNetworkId(String associatedNetworkId) {
this.associatedNetworkId = associatedNetworkId;
}

public void setAssociatedNetworkName(String associatedNetworkName) {
this.associatedNetworkName = associatedNetworkName;
}

@Override
public void setResourceIconResponse(ResourceIconResponse icon) {
this.icon = icon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ public class SystemVmResponse extends BaseResponseWithAnnotations {
@Param(description = "the system VM type")
private String systemVmType;

@SerializedName("jobid")
@Param(description = "the job ID associated with the system VM. This is only displayed if the router listed is part of a currently running asynchronous job.")
private String jobId;

@SerializedName("jobstatus")
@Param(description = "the job status associated with the system VM. This is only displayed if the router listed is part of a currently running asynchronous job.")
private Integer jobStatus;

@SerializedName("zoneid")
@Param(description = "the Zone ID for the system VM")
private String zoneId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

import com.cloud.utils.exception.CloudRuntimeException;

public class ArrayTypeAdaptor<T> implements JsonDeserializer<T[]>, JsonSerializer<T[]> {

protected Gson _gson = null;
Expand Down Expand Up @@ -75,13 +73,17 @@
try {
clazz = Class.forName(name);
} catch (ClassNotFoundException e) {
throw new CloudRuntimeException("can't find " + name);
throw new JsonParseException("can't find " + name);
}
T cmd = (T)_gson.fromJson(entry.getValue(), clazz);
cmds.add(cmd);
}
Class<?> type = ((Class<?>)typeOfT).getComponentType();
T[] ts = (T[])Array.newInstance(type, cmds.size());
return cmds.toArray(ts);
try {
Class<?> type = Class.forName(typeOfT.getTypeName().replace("[]", ""));
T[] ts = (T[])Array.newInstance(type, cmds.size());
return cmds.toArray(ts);
} catch (ClassNotFoundException e) {
throw new JsonParseException("can't find " + typeOfT.getTypeName());

Check warning on line 86 in core/src/main/java/com/cloud/agent/transport/ArrayTypeAdaptor.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/com/cloud/agent/transport/ArrayTypeAdaptor.java#L85-L86

Added lines #L85 - L86 were not covered by tests
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@
metricsResponse.setCpuTotal(hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
metricsResponse.setCpuUsed(hostResponse.getCpuUsed(), hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
metricsResponse.setCpuAllocated(hostResponse.getCpuAllocated(), hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
metricsResponse.setLoadAverage(hostResponse.getAverageLoad());
metricsResponse.setCpuAverageLoad(hostResponse.getAverageLoad());

Check warning on line 715 in plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java

View check run for this annotation

Codecov / codecov/patch

plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java#L715

Added line #L715 was not covered by tests
metricsResponse.setMemTotal(hostResponse.getMemoryTotal());
metricsResponse.setMemAllocated(hostResponse.getMemoryAllocated());
metricsResponse.setMemUsed(hostResponse.getMemoryUsed());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public class HostMetricsResponse extends HostResponse {
@Param(description = "the total cpu allocated in Ghz")
private String cpuAllocated;

@SerializedName("cpuloadaverage")
@Param(description = "the average cpu load the last minute")
private Double loadAverage;

@SerializedName("memorytotalgb")
@Param(description = "the total memory capacity in GiB")
private String memTotal;
Expand Down Expand Up @@ -132,12 +128,6 @@ public void setCpuUsed(final String cpuUsed, final Integer cpuNumber, final Long
}
}

public void setLoadAverage(final Double loadAverage) {
if (loadAverage != null) {
this.loadAverage = loadAverage;
}
}

public void setCpuAllocated(final String cpuAllocated, final Integer cpuNumber, final Long cpuSpeed) {
if (cpuAllocated != null && cpuNumber != null && cpuSpeed != null) {
this.cpuAllocated = String.format("%.2f Ghz", parseCPU(cpuAllocated) * cpuNumber * cpuSpeed / (100.0 * 1000.0));
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<cs.gmavenplus.version>3.0.2</cs.gmavenplus.version>
<cs.google-http-client>1.42.3</cs.google-http-client>
<cs.groovy.version>2.4.17</cs.groovy.version>
<cs.gson.version>1.7.2</cs.gson.version>
<cs.gson.version>2.10.1</cs.gson.version>
<cs.guava.version>31.1-jre</cs.guava.version>
<cs.httpclient.version>4.5.14</cs.httpclient.version>
<cs.httpcore.version>4.4.16</cs.httpcore.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public static String unescape(String escaped) {

public static String toJSONSerializedString(ResponseObject result, StringBuilder log) {
if (result != null && log != null) {
Gson responseBuilder = ApiResponseGsonHelper.getBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).create();
Gson logBuilder = ApiResponseGsonHelper.getLogBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT).create();
Gson responseBuilder = ApiResponseGsonHelper.getBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.STATIC).create();
Gson logBuilder = ApiResponseGsonHelper.getLogBuilder().excludeFieldsWithModifiers(Modifier.TRANSIENT, Modifier.STATIC).create();

StringBuilder sb = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@ public boolean postStateTransitionEvent(StateMachine2.Transition<State, Event> t
}

public static String logDeploymentWithoutException(VirtualMachine vm, DeploymentPlan plan, ExcludeList avoids, DeploymentPlanner planner) {
return LogUtils.logGsonWithoutException("Trying to deploy VM [%s] and details: Plan [%s]; avoid list [%s] and planner: [%s].", vm, plan, avoids, planner);
return LogUtils.logGsonWithoutException("Trying to deploy VM [%s] and details: Plan [%s]; avoid list [%s] and planner: [%s].", vm, plan, avoids, planner != null ? planner.getName() : null);
}
@Override
public ConfigKey<?>[] getConfigKeys() {
Expand Down
6 changes: 3 additions & 3 deletions ui/src/views/infra/ClusterDRSTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</template>
<template #bodyCell="{ column, text }">
<template v-if="column.key === 'successfulMigrations'">
{{ text.migrations.filter(m => m.jobstatus === 'SUCCEEDED').length }} / {{ text.migrations.length }}
{{ text.migrations.filter(m => m.migrationjobstatus === 'SUCCEEDED').length }} / {{ text.migrations.length }}
<!-- {{ text.migrations }} -->
</template>
<template v-else-if="column.key === 'created'">
Expand Down Expand Up @@ -214,9 +214,9 @@ export default {
generatedPlanMigrationColumns: generatedPlanMigrationColumns,
migrationColumns: generatedPlanMigrationColumns.concat([
{
key: 'jobstatus',
key: 'migrationjobstatus',
title: this.$t('label.status'),
dataIndex: 'jobstatus'
dataIndex: 'migrationjobstatus'
}
]),
loading: false,
Expand Down
2 changes: 1 addition & 1 deletion utils/src/test/java/com/cloud/utils/LogUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class LogUtilsTest {

@Test
public void logGsonWithoutExceptionTestLogCorrectlyPrimitives() {
String expected = "test primitives: int [1], double [1.11], float [1.2222], boolean [true], null [], char [\"c\"].";
String expected = "test primitives: int [1], double [1.11], float [1.2222], boolean [true], null [null], char [\"c\"].";
String log = LogUtils.logGsonWithoutException("test primitives: int [%s], double [%s], float [%s], boolean [%s], null [%s], char [%s].",
1, 1.11d, 1.2222f, true, null, 'c');
assertEquals(expected, log);
Expand Down
Loading