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

Update org.eclipse.store.version to v2 (major) #174

Merged
merged 4 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
}
}