File tree Expand file tree Collapse file tree
engine/schema/src/org/apache/cloudstack/storage/datastore/db Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import javax .persistence .Temporal ;
3030import javax .persistence .TemporalType ;
3131
32+ import org .apache .log4j .Logger ;
33+
3234import org .apache .cloudstack .engine .subsystem .api .storage .DataObjectInStore ;
3335import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine ;
3436import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine .State ;
4446@ Entity
4547@ Table (name = "snapshot_store_ref" )
4648public class SnapshotDataStoreVO implements StateObject <ObjectInDataStoreStateMachine .State >, DataObjectInStore {
49+ private static final Logger s_logger = Logger .getLogger (SnapshotDataStoreVO .class );
50+
4751 @ Id
4852 @ GeneratedValue (strategy = GenerationType .IDENTITY )
4953 Long id ;
@@ -266,7 +270,12 @@ public void incrRefCnt() {
266270 }
267271
268272 public void decrRefCnt () {
269- refCnt --;
273+ if (refCnt > 0 ) {
274+ refCnt --;
275+ }
276+ else {
277+ s_logger .warn ("We should not try to decrement a zero reference count even though our code has guarded" );
278+ }
270279 }
271280
272281 public Long getVolumeId () {
Original file line number Diff line number Diff line change 2929import javax .persistence .Temporal ;
3030import javax .persistence .TemporalType ;
3131
32+ import org .apache .log4j .Logger ;
33+
3234import org .apache .cloudstack .engine .subsystem .api .storage .DataObjectInStore ;
3335import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine ;
3436import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine .State ;
4547@ Entity
4648@ Table (name = "template_store_ref" )
4749public class TemplateDataStoreVO implements StateObject <ObjectInDataStoreStateMachine .State >, DataObjectInStore {
50+ private static final Logger s_logger = Logger .getLogger (TemplateDataStoreVO .class );
51+
4852 @ Id
4953 @ GeneratedValue (strategy = GenerationType .IDENTITY )
5054 Long id ;
@@ -369,7 +373,12 @@ public void incrRefCnt() {
369373 }
370374
371375 public void decrRefCnt () {
372- refCnt --;
376+ if (refCnt > 0 ) {
377+ refCnt --;
378+ }
379+ else {
380+ s_logger .warn ("We should not try to decrement a zero reference count even though our code has guarded" );
381+ }
373382 }
374383
375384}
Original file line number Diff line number Diff line change 2929import javax .persistence .Temporal ;
3030import javax .persistence .TemporalType ;
3131
32+ import org .apache .log4j .Logger ;
33+
3234import org .apache .cloudstack .engine .subsystem .api .storage .DataObjectInStore ;
3335import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine ;
3436import org .apache .cloudstack .engine .subsystem .api .storage .ObjectInDataStoreStateMachine .State ;
4446@ Entity
4547@ Table (name = "volume_store_ref" )
4648public class VolumeDataStoreVO implements StateObject <ObjectInDataStoreStateMachine .State >, DataObjectInStore {
49+ private static final Logger s_logger = Logger .getLogger (VolumeDataStoreVO .class );
50+
4751 @ Id
4852 @ GeneratedValue (strategy = GenerationType .IDENTITY )
4953 Long id ;
@@ -344,7 +348,12 @@ public Long getRefCnt() {
344348 }
345349
346350 public void setRefCnt (Long refCnt ) {
347- this .refCnt = refCnt ;
351+ if (refCnt > 0 ) {
352+ refCnt --;
353+ }
354+ else {
355+ s_logger .warn ("We should not try to decrement a zero reference count even though our code has guarded" );
356+ }
348357 }
349358
350359 public void incrRefCnt () {
You can’t perform that action at this time.
0 commit comments