Skip to content

Commit 79aacaa

Browse files
fix: Several issues wrt JavaDoc and the module-path. (#2865)
The latest version of the Maven JavaDoc plugin and JavaDoc itself have been rightfully complaining that some pieces of SDN have been using internal API of the driver and Cypher-DSL which would not be available on the module-path. This has been fixed. The schema-name support from Cypher-DSL is now a direct dependency and not relying on the shaded version any long. Several issues in the `Neo4jSpelSupport` have been fixed along the way.
1 parent f45ec11 commit 79aacaa

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@
198198
</exclusion>
199199
</exclusions>
200200
</dependency>
201+
<dependency>
202+
<groupId>org.neo4j</groupId>
203+
<artifactId>neo4j-cypher-dsl-schema-name-support</artifactId>
204+
<version>${cypher-dsl.version}</version>
205+
</dependency>
201206
<dependency>
202207
<groupId>org.neo4j.driver</groupId>
203208
<artifactId>neo4j-java-driver</artifactId>
@@ -370,6 +375,10 @@
370375
<groupId>org.neo4j</groupId>
371376
<artifactId>neo4j-cypher-dsl</artifactId>
372377
</dependency>
378+
<dependency>
379+
<groupId>org.neo4j</groupId>
380+
<artifactId>neo4j-cypher-dsl-schema-name-support</artifactId>
381+
</dependency>
373382
<dependency>
374383
<groupId>org.neo4j.driver</groupId>
375384
<artifactId>neo4j-java-driver</artifactId>

src/main/java/org/springframework/data/neo4j/core/mapping/CypherGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.neo4j.cypherdsl.core.SymbolicName;
6161
import org.neo4j.cypherdsl.core.renderer.Configuration;
6262
import org.neo4j.cypherdsl.core.renderer.Renderer;
63-
import org.neo4j.cypherdsl.core.utils.Assertions;
6463
import org.springframework.data.domain.Sort;
6564
import org.springframework.data.mapping.MappingException;
6665
import org.springframework.data.mapping.PersistentProperty;
@@ -701,7 +700,7 @@ public Collection<Expression> createReturnStatementForMatch(Neo4jPersistentEntit
701700
expression = Cypher.property(property.substring(0, firstDot), tail);
702701
} else {
703702
try {
704-
Assertions.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
703+
Assert.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
705704
expression = Cypher.name(property);
706705
} catch (IllegalArgumentException e) {
707706
if (e.getMessage().endsWith(".")) {

src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jEntityConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.neo4j.driver.Record;
3939
import org.neo4j.driver.Value;
4040
import org.neo4j.driver.Values;
41-
import org.neo4j.driver.internal.value.NullValue;
4241
import org.neo4j.driver.types.MapAccessor;
4342
import org.neo4j.driver.types.Node;
4443
import org.neo4j.driver.types.Relationship;
@@ -895,7 +894,7 @@ private static Value extractValueOf(Neo4jPersistentProperty property, MapAccesso
895894
} else if (propertyContainer.containsKey(Constants.NAME_OF_ALL_PROPERTIES)) {
896895
return propertyContainer.get(Constants.NAME_OF_ALL_PROPERTIES).get(graphPropertyName);
897896
} else {
898-
return NullValue.NULL;
897+
return Values.NULL;
899898
}
900899
}
901900
}

src/main/java/org/springframework/data/neo4j/core/mapping/MapValueWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import org.neo4j.driver.Value;
2020

2121
/**
22-
* A wrapper or marker for a Neo4j {@link org.neo4j.driver.internal.value.MapValue} that needs to be unwrapped when used
22+
* A wrapper or marker for a Neo4j {@code org.neo4j.driver.internal.value.MapValue} that needs to be unwrapped when used
2323
* for properties.
2424
* This class exists solely for projection / filtering purposes: It allows the {@link DefaultNeo4jEntityConverter} to keep
2525
* the composite properties together as long as possible (in the form of above's {@code MapValue}. Thus, the key in the

src/main/java/org/springframework/data/neo4j/repository/query/Neo4jSpelSupport.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.neo4j.repository.query;
1717

18+
import java.io.Serial;
1819
import java.util.Collection;
1920
import java.util.LinkedHashMap;
2021
import java.util.Locale;
@@ -24,10 +25,8 @@
2425
import java.util.regex.Pattern;
2526
import java.util.stream.Collectors;
2627

27-
import org.apache.commons.logging.LogFactory;
2828
import org.apiguardian.api.API;
29-
import org.neo4j.cypherdsl.core.internal.SchemaNames;
30-
import org.springframework.core.log.LogAccessor;
29+
import org.neo4j.cypherdsl.support.schema_name.SchemaNames;
3130
import org.springframework.data.domain.Pageable;
3231
import org.springframework.data.domain.Sort;
3332
import org.springframework.data.neo4j.core.mapping.CypherGenerator;
@@ -57,8 +56,6 @@ public final class Neo4jSpelSupport {
5756
public static String FUNCTION_ALL_OF = "allOf";
5857
public static String FUNCTION_ORDER_BY = "orderBy";
5958

60-
private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(Neo4jSpelSupport.class));
61-
6259
/**
6360
* Takes {@code arg} and tries to either extract a {@link Sort sort} from it or cast it to a sort. That sort is
6461
* than past to the {@link CypherGenerator} that renders a valid order by fragment which replaces the SpEL placeholder
@@ -90,9 +87,8 @@ public static LiteralReplacement orderBy(@Nullable Object arg) {
9087
*/
9188
public static LiteralReplacement literal(@Nullable Object arg) {
9289

93-
LiteralReplacement literalReplacement = StringBasedLiteralReplacement
90+
return StringBasedLiteralReplacement
9491
.withTargetAndValue(LiteralReplacement.Target.UNSPECIFIED, arg == null ? "" : arg.toString());
95-
return literalReplacement;
9692
}
9793

9894
public static LiteralReplacement anyOf(@Nullable Object arg) {
@@ -113,7 +109,7 @@ private static LiteralReplacement labels(@Nullable Object arg, String joinOn) {
113109
private static String joinStrings(Object arg, String joinOn) {
114110
if (arg instanceof Collection) {
115111
return ((Collection<?>) arg).stream()
116-
.map(o -> SchemaNames.sanitize(o.toString()).get())
112+
.map(o -> SchemaNames.sanitize(o.toString()).orElseThrow())
117113
.collect(Collectors.joining(joinOn));
118114
}
119115

@@ -130,7 +126,7 @@ private static String joinStrings(Object arg, String joinOn) {
130126
* comes in handy in places where non-parameterizable things should be created dynamic, for example matching on
131127
* set of dynamic labels, types order ordering in a dynamic way.
132128
*/
133-
interface LiteralReplacement {
129+
public interface LiteralReplacement {
134130

135131
/**
136132
* The target of this replacement. While a replacement can be used theoretically everywhere in the query, the target
@@ -155,7 +151,10 @@ private static class StringBasedLiteralReplacement implements LiteralReplacement
155151
* the creation of too many small objects.
156152
*/
157153
private static final Map<String, LiteralReplacement> INSTANCES =
158-
new LinkedHashMap<String, LiteralReplacement>(DEFAULT_CACHE_SIZE) {
154+
new LinkedHashMap<>(DEFAULT_CACHE_SIZE) {
155+
@Serial
156+
private static final long serialVersionUID = 195460174410223375L;
157+
159158
@Override
160159
protected boolean removeEldestEntry(Map.Entry<String, LiteralReplacement> eldest) {
161160
return size() > DEFAULT_CACHE_SIZE;
@@ -167,7 +166,7 @@ protected boolean removeEldestEntry(Map.Entry<String, LiteralReplacement> eldest
167166
static LiteralReplacement withTargetAndValue(LiteralReplacement.Target target, @Nullable String value) {
168167

169168
String valueUsed = value == null ? "" : value;
170-
String key = new StringBuilder(target.name()).append("_").append(valueUsed).toString();
169+
String key = target.name() + "_" + valueUsed;
171170

172171
long stamp = LOCK.tryOptimisticRead();
173172
if (LOCK.validate(stamp) && INSTANCES.containsKey(key)) {

0 commit comments

Comments
 (0)