Caleb Cushing
11/01/2024, 8:04 PMjava.lang.NullPointerException: Cannot invoke "java.lang.Class.getName()" because "this.type" is null
at org.gradle.api.internal.provider.DefaultProperty.describeContents(DefaultProperty.java:178)
at org.gradle.api.internal.provider.AbstractProperty.toStringNoReentrance(AbstractProperty.java:207)
at org.gradle.api.internal.provider.EvaluationContext.evaluate(EvaluationContext.java:142)
at org.gradle.api.internal.provider.EvaluationContext.tryEvaluate(EvaluationContext.java:166)
at org.gradle.api.internal.provider.AbstractMinimalProvider.toString(AbstractMinimalProvider.java:174)
at org.gradle.process.internal.ProcessArgumentsSpec.getArgs(ProcessArgumentsSpec.java:107)
at org.gradle.process.internal.ProcessArgumentsSpec.getAllArguments(ProcessArgumentsSpec.java:67)
at org.gradle.process.internal.DefaultExecHandleBuilder.getAllArguments(DefaultExecHandleBuilder.java:113)
at org.gradle.process.internal.AbstractExecHandleBuilder.getEffectiveArguments(AbstractExecHandleBuilder.java:59)
at org.gradle.process.internal.AbstractExecHandleBuilder.build(AbstractExecHandleBuilder.java:140)
at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:35)
at org.gradle.process.internal.DefaultExecActionFactory.exec(DefaultExecActionFactory.java:202)
at org.gradle.process.internal.DefaultExecOperations.exec(DefaultExecOperations.java:37)
at com.xenoterracide.gradle.git.HeadBranchValueSource.gitRemoteShow(HeadBranchValueSource.java:68)
68
this.execOperations.exec(execSpec -> {
execSpec.setExecutable("git");
execSpec.args("remote", "show", this.getParameters().getSourceRemote());
execSpec.setStandardOutput(baos);
}).getExitValue();Mikhail Lopatkin
11/01/2024, 8:28 PMCaleb Cushing
11/01/2024, 8:28 PMCaleb Cushing
11/01/2024, 8:29 PMCaleb Cushing
11/04/2024, 2:31 PMif (!remotes.isEmpty()) {
remotes
.stream()
.findFirst()
.ifPresent(remote -> this.getParameters().getSourceRemote().convention(remote.getName()));
I know that remote.getName() is not null (debugger)
java.lang.NullPointerException: Cannot invoke "java.lang.Class.isInstance(Object)" because "targetType" is null
at org.gradle.api.internal.provider.Providers.fixedValue(Providers.java:39)
at org.gradle.api.internal.provider.DefaultProperty.convention(DefaultProperty.java:125)
at com.xenoterracide.gradle.git.HeadBranchValueSource.lambda$obtain$4(HeadBranchValueSource.java:55)Mikhail Lopatkin
11/04/2024, 3:38 PMDefaultProperty.type shouldn't be null. How is your Parameters interface defined?Caleb Cushing
11/04/2024, 3:40 PMpublic interface GitValueSourceParameters extends ValueSourceParameters {
Property<File> getProjectDir();
}Caleb Cushing
11/04/2024, 3:41 PMpublic interface HeadBranchValueSourceParameters extends GitValueSourceParameters {
Property<String> getHeadBranch();
Property<String> getSourceRemote();Caleb Cushing
11/04/2024, 3:41 PMCaleb Cushing
11/04/2024, 3:44 PMpublic abstract class HeadBranchValueSource implements ValueSource<String, HeadBranchValueSourceParameters> {Caleb Cushing
11/04/2024, 3:54 PMgetSourceRemote so I'm expecting it to use the conventionMikhail Lopatkin
11/04/2024, 4:08 PMpotentially worth noting, there is no set value of getSourceRemote so I'm expecting it to use the conventionThanks, just got to that with my research and this is what triggers the issue. Could you please file a bug?
Caleb Cushing
11/04/2024, 4:10 PMCaleb Cushing
11/04/2024, 4:11 PMCaleb Cushing
11/04/2024, 4:13 PMCaleb Cushing
11/04/2024, 4:13 PMMikhail Lopatkin
11/04/2024, 4:25 PMconvention for a ValueSource. I suspect you cannot set the convention from outside, by e.g. wrapping provider.of into a helper function, because it comes from another call to git?Caleb Cushing
11/04/2024, 4:29 PMCaleb Cushing
11/04/2024, 4:32 PMCaleb Cushing
11/04/2024, 4:33 PMCaleb Cushing
11/04/2024, 4:34 PMthis.execOperations.exec(execSpec -> {
execSpec.setExecutable("git");
execSpec.args("remote", "show", this.getParameters().getSourceRemote());
execSpec.setStandardOutput(baos);
}).getExitValue();Caleb Cushing
11/04/2024, 4:34 PMMikhail Lopatkin
11/04/2024, 4:35 PMget() also triggers the issue
you can use orElse(<your convention value>).get() at the consumer side (it works), but it has a slight semantic difference compared to the original convention() call.Caleb Cushing
11/04/2024, 4:35 PMMikhail Lopatkin
11/04/2024, 4:37 PMCaleb Cushing
11/04/2024, 4:38 PMCaleb Cushing
11/04/2024, 4:45 PMCaleb Cushing
11/04/2024, 4:46 PMCaleb Cushing
11/04/2024, 4:46 PMCaleb Cushing
11/04/2024, 4:47 PMCaleb Cushing
11/04/2024, 4:55 PMCaleb Cushing
11/04/2024, 5:04 PMValueSource for anything else
try (var git = Git.open(finalizeOnRead(this.getParameters().getProjectDir()).get())) {
try (var baos = new ByteArrayOutputStream()) {
this.execOperations.exec(execSpec -> {
execSpec.setExecutable("git");
execSpec.args("remote", "show", this.getParameters().getSourceRemote().get());
execSpec.setStandardOutput(baos);
}).getExitValue();
return baos.toString(Charsets.UTF_8);
}
} catch (IOException e) {
this.log.warn("Git had an exception", e);
}
return null;
}Caleb Cushing
11/04/2024, 5:05 PMgetSourceRemote can come in from somewhere elseCaleb Cushing
11/04/2024, 5:05 PM