Skip to content

Commit 7d26454

Browse files
Made FieldAccessibleMaker change private fields and not change it back
1 parent 23e5726 commit 7d26454

2 files changed

Lines changed: 13 additions & 18 deletions

File tree

docs/modules/ROOT/pages/installation.adoc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ Also see the https://github.com/xdev-software/spring-data-eclipse-store/releases
2323

2424
After adding the library in your dependencies, using it is as easy as adding the ``@EnableEclipseStoreRepositories`` annotation to your ``@SpringBootApplication`` annotation.
2525

26-
[NOTE]
27-
====
28-
Since the library is using reflection to copy data, the following JVM-Arguments may have to be set.
26+
=== Merge behavior
27+
28+
To merge data of the xref:working-copies.adoc[working copy] into the original object graph, the library is using reflection.
29+
Therefore, the following *JVM-Arguments* may have to be set:
2930

3031
[source,title="JVM Arguments"]
3132
----
@@ -34,6 +35,11 @@ Since the library is using reflection to copy data, the following JVM-Arguments
3435
--add-opens=java.base/java.lang=ALL-UNNAMED
3536
--add-opens=java.base/java.time=ALL-UNNAMED
3637
----
38+
39+
[NOTE]
40+
====
41+
To access ``private`` variables, the library uses reflection and sets the access level to ``public`` (see https://github.com/xdev-software/spring-data-eclipse-store/blob/develop/spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/access/modifier/FieldAccessibleMaker.java[FieldAccessibleMaker]).
42+
For performance reasons, *this change stays permanent* during runtime.
3743
====
3844

3945
== Demo

spring-data-eclipse-store/src/main/java/software/xdev/spring/data/eclipse/store/repository/access/modifier/FieldAccessibleMaker.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ public class FieldAccessibleMaker<E> implements FieldAccessModifier<E>
3737
{
3838
private static final Logger LOG = LoggerFactory.getLogger(FieldAccessibleMaker.class);
3939
private final Field field;
40-
private final boolean wasAccessible;
4140
private final boolean isFinal;
4241

4342
FieldAccessibleMaker(final Field field, final E sourceObject)
4443
{
4544
this.field = field;
46-
this.wasAccessible = field.canAccess(Objects.requireNonNull(sourceObject));
45+
final boolean wasAccessible = field.canAccess(Objects.requireNonNull(sourceObject));
4746
final int fieldModifiers = field.getModifiers();
4847
this.isFinal = Modifier.isFinal(fieldModifiers);
49-
if(!this.wasAccessible)
48+
if(!wasAccessible)
5049
{
5150
if(LOG.isTraceEnabled())
5251
{
@@ -89,17 +88,7 @@ public boolean isFinal()
8988
@Override
9089
public void close()
9190
{
92-
if(!this.wasAccessible)
93-
{
94-
if(LOG.isTraceEnabled())
95-
{
96-
LOG.trace(
97-
"Make field {}#{} inaccessible.",
98-
this.field.getDeclaringClass().getSimpleName(),
99-
this.field.getName());
100-
}
101-
102-
this.field.setAccessible(false);
103-
}
91+
// This used to make the field optionally inaccessible again,
92+
// but was removed due to concurrency issues.
10493
}
10594
}

0 commit comments

Comments
 (0)