Skip to content

Commit

Permalink
Merge pull request #174 from xdev-software/renovate/major-org.eclipse…
Browse files Browse the repository at this point in the history
….store.version

Update org.eclipse.store.version to v2 (major)
  • Loading branch information
JohannesRabauer authored Dec 2, 2024
2 parents 96f2cb8 + 193eb04 commit 2c4ee6f
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spring-data-eclipse-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

<!-- Should be in sync with org.eclipse.store:integrations-spring-boot3 -->
<org.springframework.boot.version>3.4.0</org.springframework.boot.version>
<org.eclipse.store.version>1.4.0</org.eclipse.store.version>
<org.eclipse.serializer.version>1.4.0</org.eclipse.serializer.version>
<org.eclipse.store.version>2.0.0</org.eclipse.store.version>
<org.eclipse.serializer.version>2.0.0</org.eclipse.serializer.version>
<hibernate-validator.version>8.0.1.Final</hibernate-validator.version>
<jakarta.el-api.version>6.0.1</jakarta.el-api.version>
<expressly.version>6.0.0-M1</expressly.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

import java.lang.reflect.Field;
import java.util.Objects;
import java.util.function.Consumer;

import org.eclipse.serializer.collections.HashEnum;
import org.eclipse.serializer.collections.types.XGettingEnum;
import org.eclipse.serializer.reference.Lazy;
import org.eclipse.serializer.reference.ObjectSwizzling;
import org.eclipse.serializer.reference.Swizzling;
Expand Down Expand Up @@ -73,6 +76,7 @@ final class Default<T> implements SpringDataEclipseStoreLazy<T>
private transient ObjectSwizzling loader;
private transient WorkingCopier<T> copier;
private transient boolean isStored;
private final transient HashEnum<Object> usageMarks = HashEnum.New();

private Default(final Lazy<T> lazySubject)
{
Expand Down Expand Up @@ -259,5 +263,65 @@ public boolean isOriginalObject()
{
return this.objectToBeWrapped != null;
}

// region Copied from org.eclipse.serializer.reference.UsageMarkable#Default
@Override
public int markUsedFor(final Object instance)
{
// lock internal instance to avoid side effect deadlocks
synchronized(this.usageMarks)
{
final boolean added = this.usageMarks.add(instance);

return this.usageMarks.intSize() * (added ? 1 : -1);
}
}

@Override
public int unmarkUsedFor(final Object instance)
{
// lock internal instance to avoid side effect deadlocks
synchronized(this.usageMarks)
{
final boolean removed = this.usageMarks.removeOne(instance);

return this.usageMarks.intSize() * (removed ? 1 : -1);
}
}

@Override
public boolean isUsed()
{
// lock internal instance to avoid side effect deadlocks
synchronized(this.usageMarks)
{
return !this.usageMarks.isEmpty();
}
}

@Override
public int markUnused()
{
// lock internal instance to avoid side effect deadlocks
synchronized(this.usageMarks)
{
final int currentSize = this.usageMarks.intSize();
this.usageMarks.clear();

return currentSize;
}
}

@Override
public void accessUsageMarks(final Consumer<? super XGettingEnum<Object>> logic)
{
// lock internal instance to avoid side effect deadlocks
synchronized(this.usageMarks)
{
// no null check to give logic a chance to notice no-marks case.
logic.accept(this.usageMarks);
}
}
// endregion
}
}

0 comments on commit 2c4ee6f

Please sign in to comment.