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 ;
@@ -272,7 +276,12 @@ public void incrRefCnt() {
272276 }
273277
274278 public void decrRefCnt () {
275- refCnt --;
279+ if (refCnt > 0 ) {
280+ refCnt --;
281+ }
282+ else {
283+ s_logger .warn ("We should not try to decrement a zero reference count even though our code has guarded" );
284+ }
276285 }
277286
278287 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 ;
@@ -367,7 +371,12 @@ public void incrRefCnt() {
367371 }
368372
369373 public void decrRefCnt () {
370- refCnt --;
374+ if (refCnt > 0 ) {
375+ refCnt --;
376+ }
377+ else {
378+ s_logger .warn ("We should not try to decrement a zero reference count even though our code has guarded" );
379+ }
371380 }
372381
373382}
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 ;
@@ -342,7 +346,12 @@ public Long getRefCnt() {
342346 }
343347
344348 public void setRefCnt (Long refCnt ) {
345- this .refCnt = refCnt ;
349+ if (refCnt > 0 ) {
350+ refCnt --;
351+ }
352+ else {
353+ s_logger .warn ("We should not try to decrement a zero reference count even though our code has guarded" );
354+ }
346355 }
347356
348357 public void incrRefCnt () {
You can’t perform that action at this time.
0 commit comments