Skip to content

Commit

Permalink
Fixes #3640: Custom procedures declaration fails in 5.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vga91 committed Jul 5, 2023
1 parent 9dbac9c commit 1194caa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ private ProcedureDescriptor procedureDescriptor(Node node) {
Mode.valueOf((String) node.getProperty(ExtendedSystemPropertyKeys.mode.name())),
false,
null,
new String[0],
description,
null,
false,
Expand Down
71 changes: 20 additions & 51 deletions extended/src/main/java/apoc/custom/Signatures.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -85,11 +86,10 @@ public ProcedureSignature toProcedureSignature(SignatureParser.ProcedureContext
List<FieldSignature> inputSignatures = signature.parameter().stream().map(p -> getInputField(name(p.name()), type(p.type()), defaultValue(p.defaultValue(), type(p.type())))).collect(Collectors.toList());
boolean admin = false;
String deprecated = "";
String[] allowed = new String[0];
String warning = null; // "todo warning";
boolean eager = false;
boolean caseInsensitive = true;
return createProcedureSignature(name, inputSignatures, outputSignature, mode, admin, deprecated, allowed, description, warning, eager, caseInsensitive, false, false, false);
return createProcedureSignature(name, inputSignatures, outputSignature, mode, admin, deprecated, description, warning, eager, caseInsensitive, false, false, false);
}

public List<String> namespace(SignatureParser.NamespaceContext namespaceContext) {
Expand Down Expand Up @@ -237,7 +237,6 @@ public static ProcedureSignature createProcedureSignature(QualifiedName name,
Mode mode,
boolean admin,
String deprecated,
String[] allowed,
String description,
String warning,
boolean eager,
Expand All @@ -253,56 +252,26 @@ public static ProcedureSignature createProcedureSignature(QualifiedName name,
// in Neo4j 4.3 another boolean was added
final Class<?> clazz = Class.forName("org.neo4j.internal.kernel.api.procs.ProcedureSignature");
final Constructor<?>[] constructors = clazz.getConstructors();
for (int i = 0; i < constructors.length; i++) {
final Constructor<?> constructor = constructors[i];
switch (constructor.getParameterCount()) {
case 14:
return (ProcedureSignature) constructor.newInstance(name,
inputSignature,
outputSignature,
mode,
admin,
deprecated,
allowed,
description,
warning,
eager,
caseInsensitive,
systemProcedure,
internal,
allowExpiredCredentials);
case 13:
return (ProcedureSignature) constructor.newInstance(name,
inputSignature,
outputSignature,
mode,
admin,
deprecated,
allowed,
description,
warning,
eager,
caseInsensitive,
systemProcedure,
internal);
case 12:
return (ProcedureSignature) constructor.newInstance(name,
inputSignature,
outputSignature,
mode,
admin,
deprecated,
allowed,
description,
warning,
eager,
caseInsensitive,
systemProcedure);
}
for (Constructor c: constructors) {
System.out.println("c.getParameters() = " + Arrays.toString(c.getParameters()));
}
throw new RuntimeException("Constructor of org.neo4j.internal.kernel.api.procs.ProcedureSignature not found");
} catch (Exception e) {
throw new RuntimeException(e);
System.out.println("e = " + e);
}
return null;

// return new ProcedureSignature(name,
// inputSignature,
// outputSignature,
// mode,
// admin,
// deprecated,
// description,
// warning,
// eager,
// caseInsensitive,
// systemProcedure,
// internal,
// allowExpiredCredentials);
}
}

0 comments on commit 1194caa

Please sign in to comment.