You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cloudstack.apache.org by "Wei Zhou (JIRA)" <ji...@apache.org> on 2015/01/29 14:35:35 UTC
[jira] [Created] (CLOUDSTACK-8186) setRemoved(null) does not work
as expected
Wei Zhou created CLOUDSTACK-8186:
------------------------------------
Summary: setRemoved(null) does not work as expected
Key: CLOUDSTACK-8186
URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8186
Project: CloudStack
Issue Type: Bug
Security Level: Public (Anyone can view this level - this is the default.)
Reporter: Wei Zhou
Priority: Critical
in cloudstack 4.5, there are two locations where set the removed field as null.
[root@localhost cloudstack.git(4.5)]# grep -r "setRemoved(null)" *
engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java: tmpltZoneVO.setRemoved(null);
framework/cluster/src/com/cloud/cluster/ClusterManagerImpl.java: mshost.setRemoved(null);
As far as I think, the proposal is to clean the removed field in the database.
However, it does not work as expected.
The removed field will be set the current date.
After investigating for a long time, I find it is because the following part in ./framework/db/src/com/cloud/utils/db/GenericDaoBase.java
@DB()
protected void prepareAttribute(final int j, final PreparedStatement pstmt, final Attribute attr, Object value) throws SQLException {
if (attr.is(Attribute.Flag.DaoGenerated) && value == null) {
value = generateValue(attr);
if (attr.field == null) {
pstmt.setObject(j, value);
return;
}
}
......
@DB()
protected Object generateValue(final Attribute attr) {
if (attr.is(Attribute.Flag.Created) || attr.is(Attribute.Flag.Removed)) {
return new Date();
......
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)