简体   繁体   English

运行 Gradle 测试时出现管道损坏错误

[英]Broken pipe error when running Gradle test

I've got a problem regarding running tests in gradle.我有一个关于在 gradle 中运行测试的问题。 I know that in other machines my gradle config works but in mine unfortunately not.我知道在其他机器上我的 gradle 配置可以工作,但不幸的是在我的机器上不行。 We have got junit test and testNG and both of them, when try to execute, produces stacktrace like this:我们有 junit test 和 testNG ,当尝试执行时,它们都会产生这样的堆栈跟踪:

Could not write standard input into: Gradle Worker 1.
java.io.IOException: The pipe is being closed
    at java.io.FileOutputStream.writeBytes(Native Method)
    at java.io.FileOutputStream.write(FileOutputStream.java:318)
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
    at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:53)
    at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:722)

Which continuously will produce this error with different number (Gradle Worker 2, Gradle Worker 3, etc).哪个会连续产生不同数量的错误(Gradle Worker 2、Gradle Worker 3 等)。 Has anybody ever faced similar problem?有没有人遇到过类似的问题?

I'm using gradle 1.6.我正在使用 gradle 1.6。

EDIT: I forgot to tell that I'm using gradle wrapper编辑:我忘了告诉我我正在使用 gradle 包装器

EDIT: After changing to version 1.12 I'm receiving error:编辑:更改为 1.12 版后,我收到错误:

Caused by: org.gradle.api.InvalidUserDataException: Could not create task '(custome taks name)': Unknown argument(s) in task definition: [mustRunAfter]
11:20:17.990 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.TaskFactory.validateArgs(TaskFactory.java:147)
11:20:17.991 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.TaskFactory.checkTaskArgsAndCreateDefaultValues(TaskFactory.java:134)
11:20:17.991 [ERROR] [org.gradle.BuildExceptionReporter]    at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:72)

EDIT: Ok I think I have found what cause this problem - it was Antivirus .编辑:好的,我想我已经找到了导致这个问题的原因 -它是 Antivirus When I disable it script moves a little bit forward but ended with:当我禁用它时,脚本会向前移动一点,但以:

org.gradle.messaging.remote.internal.ConnectException: Could not connect to server [e42b57ea-ced6-4bb6-9369-3186ab4983d6 port:63631, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]]. Tried addresses: [/127.0.0.1, /0:0:0:0:0:0:0:1].
    at org.gradle.messaging.remote.internal.inet.TcpOutgoingConnector.connect(TcpOutgoingConnector.java:62)
    at org.gradle.messaging.remote.internal.hub.MessageHubBackedClient.getConnection(MessageHubBackedClient.java:35)
    at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:54)
    at org.gradle.process.internal.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:35)
    at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:85)
    at org.gradle.process.internal.child.ImplementationClassLoaderWorker.execute(ImplementationClassLoaderWorker.java:41)
    at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:43)
    at org.gradle.process.internal.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:32)
    at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:46)
    at org.gradle.process.internal.launcher.BootstrapClassLoaderWorker.call(BootstrapClassLoaderWorker.java:32)
    at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.run(GradleWorkerMain.java:32)
    at jarjar.org.gradle.process.internal.launcher.GradleWorkerMain.main(GradleWorkerMain.java:37)
Caused by: java.net.ConnectException: Connection refused: connect

Searching with google on this error gives me nothing (only some old gradle 1.1 errors info).用谷歌搜索这个错误给我什么(只有一些旧的 gradle 1.1 错误信息)。 Anybody faced this kind of problem?有人遇到过这种问题吗?

Whew, after whole day struggling with gradle I think I've finally found what cause problems.哇,经过一整天的 gradle 挣扎,我想我终于找到了导致问题的原因。 Guilty of that was antivirus - COMODO.罪魁祸首是防病毒软件 - COMODO。 After uninstalling it and installing another one, everything started to working fine.卸载它并安装另一个后,一切都开始正常工作。 So all Gradle Users - please be careful with COMODO because even disabled, it could cause problems when using Gradle .所以所有 Gradle 用户 -请小心使用 COMODO 因为即使禁用,它也可能在使用 Gradle 时导致问题 Be aware :)意识到 :)

I faced the similar issue while running the test classes.我在运行测试类时遇到了类似的问题。 I can able to build the project, but I couldn't able to run, so after some research I found one of the solution, which is to remove the some of the workerThread-jar from the .gradle/cache folder.我可以构建项目,但无法运行,因此经过一番研究,我找到了解决方案之一,即从 .gradle/cache 文件夹中删除一些 workerThread-jar。 I tried and it worked for me.我试过了,它对我有用。 You can use below commands to solve this.您可以使用以下命令来解决此问题。

  1. In terminal I invoked gradle test --info command,在终端中,我调用了gradle test --info命令,

In response, I receive the logs, where I searched the for the作为回应,我收到了日志,在那里我搜索了

Gradle worker Daemon Gradle worker 守护进程

key, to fetch the location of my gradle-worker.jar.键,获取我的 gradle-worker.jar 的位置。 Typically in windows you can find this under the following location C:\\Users\\.gradle\\caches\\\\workerMain\\gradle-worker.jar.通常在 Windows 中,您可以在以下位置 C:\\Users\\.gradle\\caches\\\\workerMain\\gradle-worker.jar 下找到它。

To fix this, one approach is to remove the the workerMain folder itself, and run the test classes.要解决此问题,一种方法是删除 workerMain 文件夹本身,然后运行测试类。

You really don't need to disable or remove COMODO Antivirus.您真的不需要禁用或删除 COMODO Antivirus。 Just do the following steps:只需执行以下步骤:

  1. Go to COMODO Client Panel转到 COMODO 客户端面板
  2. Open the Advanced Tasks option under the Task menu.打开任务菜单下的高级任务选项。
  3. See all active tasks and select the Gradle process that is being blocked.查看所有活动任务并选择被阻止的 Gradle 进程。
  4. Right click on the task and 'Add to Trusted Files'右键单击任务并“添加到受信任的文件”

I got this same error, except it said Gradle Worker 2. I restarted my command line (powershell) and then tried to build again with gradle and it worked.我遇到了同样的错误,除了它说 Gradle Worker 2。我重新启动了我的命令行(powershell),然后尝试使用 gradle 再次构建并且它工作正常。 I had changed my environment variables to point to the Java version the project was expecting and had not thought to restart- not sure if that had anything to do with it.我已经更改了我的环境变量以指向项目期望的 Java 版本并且没有想过要重新启动 - 不确定这是否与它有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM