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

Running check/apply with buf on Windows fails for files slightly over 4100 bytes #2147

Closed
6 tasks done
azam opened this issue May 29, 2024 · 3 comments · Fixed by #2153
Closed
6 tasks done

Running check/apply with buf on Windows fails for files slightly over 4100 bytes #2147

azam opened this issue May 29, 2024 · 3 comments · Fixed by #2153
Labels

Comments

@azam
Copy link
Contributor

azam commented May 29, 2024

Summary

spotlessProtobufCheck/Apply fails with pipe has closed exception, when processing .proto files larger than 4100 bytes, only on Windows.
Reducing the size of the .proto file (remove the last message on attached project) results in successful task execution.

Environment

Spotless: 6.25.0
Buf: 1.31.0
Gradle: 8.7
JVM: Oracle/GraalVM/Temurin 21
OS: OS: Windows 10 Pro Build: 22H2 (19045)
Shell: PowerShell 7.4.2

Stacktrace

English translation for "パイプは終了しました" is "The pipe is being closed".

#### buf: C:\Users\valkyrie\.gradle\caches\modules-2\files-2.1\build.buf\buf\1.31.0\4152371536f12671d4f04b3c2aa14c3182dd1774\buf-1.31.0-windows-x86_64.exe
> Task :spotlessInternalRegisterDependencies UP-TO-DATE

> Task :spotlessProtobuf FAILED
Step 'buf' found problem in 'src\main\proto\service.proto':
パイプは終了しました。
java.io.IOException: パイプは終了しました。
	at com.diffplug.spotless.ProcessRunner.start(ProcessRunner.java:166)
	at com.diffplug.spotless.ProcessRunner.start(ProcessRunner.java:131)
	at com.diffplug.spotless.ProcessRunner.exec(ProcessRunner.java:114)
	at com.diffplug.spotless.ProcessRunner.exec(ProcessRunner.java:109)
	at com.diffplug.spotless.protobuf.BufStep$State.format(BufStep.java:93)
	at com.diffplug.spotless.FormatterFunc$Closeable$3.apply(FormatterFunc.java:125)
	at com.diffplug.spotless.FormatterStepImpl$Standard.format(FormatterStepImpl.java:82)
	at com.diffplug.spotless.FormatterStep$Strict.format(FormatterStep.java:103)
	at com.diffplug.spotless.Formatter.compute(Formatter.java:246)
	at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:203)
	at com.diffplug.spotless.PaddedCell.calculateDirtyState(PaddedCell.java:190)
	at com.diffplug.gradle.spotless.SpotlessTaskImpl.processInputFile(SpotlessTaskImpl.java:105)
	at com.diffplug.gradle.spotless.SpotlessTaskImpl.performAction(SpotlessTaskImpl.java:89)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:125)
	at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:45)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
	at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.execute(IncrementalTaskAction.java:26)
	at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
	at org.gradle.api.internal.tasks.execution.TaskExecution$3.run(TaskExecution.java:244)

Attached is the full stacktrace for ./gradlew spotlessProtobufCheck --stacktrace.
stacktrace.txt

Reproducible project

Attached is a minimal gradle project that can reproduce the problem. Just run ./gradlew build or ./gradlew spotlessProtobufCheck to reproduce the problem. buf executable is automatically provisioned on the build script for convenience, but running with defaults (using buf executable available on PATH) results with same exception.
spotless-buf-sample.zip


If you are submitting a bug, please include the following:

  • summary of problem
  • Gradle or Maven version
  • spotless version
  • operating system and version
  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible
  • copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

If you're just submitting a feature request or question, no need for the above.

@nedtwigg nedtwigg added the bug label May 29, 2024
@azam
Copy link
Contributor Author

azam commented May 31, 2024

Skipping OutputStream#close() here seems to fix this.

The process input stream is closed on Process#destroy() anyway, so probably it should be ok?
Ignore this comment. The close was only for file redirect. The pipe is registered for cleanup here.

I ran BufIntegrationTest with this patch and all was successful. I could make a PR (minus the fixed executable version on the patch) if that is preferred.
bufpatch.patch

@nedtwigg
Copy link
Member

Amazing, thanks for finding this! A PR would be great.

@azam
Copy link
Contributor Author

azam commented Jun 1, 2024

Created PR #2153 for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants