int128 / int128/gradle-ssh-plugin
Gradle system property synchronization issue
Nobody has claimed this yet.
- Dominant language
- Groovy
- Stars
- 325
- Forks
- 59
- Avg merge
- 5h 29m
- Merged PRs (30d)
- 6
Description
Environment info
plugin: org.hidetake:gradle-ssh-plugin:2.9.0
jsch: com.jcraft:jsch:0.1.54
gradle: 4.10.2
OS: Windows
Example Stack:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class javax.crypto.JceSecurity
at com.jcraft.jsch.jce.AES256CTR.init(AES256CTR.java:56)
at com.jcraft.jsch.Session.checkCipher(Session.java:2497)
at com.jcraft.jsch.Session.checkCiphers(Session.java:2474)
at com.jcraft.jsch.Session.send_kexinit(Session.java:624)
at com.jcraft.jsch.Session.connect(Session.java:307)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.jcraft.jsch.Session$connect$4.call(Unknown Source)
at org.hidetake.groovy.ssh.connection.ConnectionManager.connectInternal(ConnectionManager.groovy:107)
at org.hidetake.groovy.ssh.connection.ConnectionManager$_connectInternal_closure1.doCall(ConnectionManager.groovy:85)
at org.hidetake.groovy.ssh.connection.ConnectionManager$_connectInternal_closure1.doCall(ConnectionManager.groovy)
at org.hidetake.groovy.ssh.util.Utility.retry(Utility.groovy:52)
at org.hidetake.groovy.ssh.util.Utility$retry.callStatic(Unknown Source)
at org.hidetake.groovy.ssh.connection.ConnectionManager.connectInternal(ConnectionManager.groovy:83)
at org.hidetake.groovy.ssh.connection.ConnectionManager.connectInternal(ConnectionManager.groovy)
at org.hidetake.groovy.ssh.connection.ConnectionManager.connect(ConnectionManager.groovy:59)
at org.hidetake.groovy.ssh.connection.ConnectionManager$connect$0.call(Unknown Source)
at org.hidetake.groovy.ssh.session.SessionTask.wetRun(SessionTask.groovy:61)
at org.hidetake.groovy.ssh.session.SessionTask.call(SessionTask.groovy:48)
at java_util_concurrent_Callable$call$0.call(Unknown Source)
at org.hidetake.groovy.ssh.core.Service.run(Service.groovy:81)
at org.hidetake.groovy.ssh.core.Service$run$0.call(Unknown Source)
at org.hidetake.groovy.ssh.core.Service$run$0.call(Unknown Source)
Our build makes liberal use of ssh.run and runs many tasks using the parallel flag, so most users probably won't run into this. This problem happens intermittently. I believe the root cause is that gradle swaps out system properties while doing some things (like compile). Here is a report on gradle about a similar issue and a comment indicating the issue: https://github.com/gradle/gradle/issues/8830#issuecomment-476349575
I've worked around this in our build by doing something like this before a call to ssh.run (probably only needed on the first call):
SystemProperties.getInstance().withSystemProperties(new Factory<String>() {
@Override
String create() {
Cipher.getInstance("AES/CTR/NoPadding")
"success"
}
})
This resolves our problem by assuring that the JCE classes that look at java.home are initialized while the system properties are in good state. This uses internal gradle classes, so you'll probably need to get them to expose something public. There also may be different usage patterns that will need different resolution code.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at org.hidetake.groovy.ssh.connection.ConnectionManager.groovy:107 and the parallel ssh.run path described in the report. Reproduce the intermittent JCE initialization failure under Gradle 4.10.2 with parallel tasks, then investigate the SystemProperties workaround and determine a supported synchronization approach. Done means SSH connections no longer intermittently fail with NoClassDefFoundError when Gradle changes system properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- build-system, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100