Skip to content

Handle null entries in gradle/checksums.json #2775

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

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

mfussenegger
Copy link
Contributor

If there are connection errors during the build, it can happen that the
checksums.json contains null entries.

These currently result in a logged error:

PM Initialization failed Not a JSON Object: null
java.lang.IllegalStateException: Not a JSON Object: null
	at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:101)
	at org.eclipse.jdt.ls.internal.gradle.checksums.WrapperValidator.loadInternalChecksums(WrapperValidator.java:183)
	at org.eclipse.jdt.ls.internal.gradle.checksums.WrapperValidator.checkWrapper(WrapperValidator.java:97)
	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.getGradleDistribution(GradleProjectImporter.java:308)
	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.getBuildConfiguration(GradleProjectImporter.java:441)
	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.startSynchronization(GradleProjectImporter.java:408)
	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importDir(GradleProjectImporter.java:298)
	at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importToWorkspace(GradleProjectImporter.java:210)
	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:152)
	at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:114)
	at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:256)
	at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

If there are connection errors during the build, it can happen that the
`checksums.json` contains `null` entries.

These currently result in a logged error:

	PM Initialization failed Not a JSON Object: null
	java.lang.IllegalStateException: Not a JSON Object: null
		at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:101)
		at org.eclipse.jdt.ls.internal.gradle.checksums.WrapperValidator.loadInternalChecksums(WrapperValidator.java:183)
		at org.eclipse.jdt.ls.internal.gradle.checksums.WrapperValidator.checkWrapper(WrapperValidator.java:97)
		at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.getGradleDistribution(GradleProjectImporter.java:308)
		at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.getBuildConfiguration(GradleProjectImporter.java:441)
		at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.startSynchronization(GradleProjectImporter.java:408)
		at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importDir(GradleProjectImporter.java:298)
		at org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter.importToWorkspace(GradleProjectImporter.java:210)
		at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.importProjects(ProjectsManager.java:152)
		at org.eclipse.jdt.ls.core.internal.managers.ProjectsManager.initializeProjects(ProjectsManager.java:114)
		at org.eclipse.jdt.ls.core.internal.handlers.InitHandler$1.runInWorkspace(InitHandler.java:256)
		at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:43)
		at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
@jdneo
Copy link
Contributor

jdneo commented Jul 26, 2023

We merged a change about downloading checksums in parallel recently: #2759

Not sure if this is caused by that change. Did you observe a corrupted gradle/checksums.json in the release build?

@rgrunber
Copy link
Contributor

rgrunber commented Jul 26, 2023

Looks like it could be caused by a1e0914#diff-45482730788077c6b3eaa2accc0cc6f3dbc3016815b9563c397e3b22525f37e8R101 ?

I haven't been able to reproduce though. @mfussenegger are you able to reproduce this.. and if so, how did the checksums.json file look like prior to the change (a1e0914) . I'm curious if the entries that couldn't be resolved were elegantly just left out.

@mfussenegger
Copy link
Contributor Author

For me it reproduces pretty much all the time. The entries which are missing is changing from build to build

An example snippet of some missing bits:

    {
        "sha256": "70239e6ca1f0d5e3b2808ef6d82390cf9ad58d3a3a0d271677a51d1b89475857",
        "wrapperChecksumUrl": "https://services.gradle.org/distributions/gradle-6.4-rc-1-wrapper.jar.sha256"
    },
    null,
    {
        "sha256": "1cef53de8dc192036e7b0cc47584449b0cf570a00d560bfaa6c9eabe06e1fc06",
        "wrapperChecksumUrl": "https://services.gradle.org/distributions/gradle-6.3-rc-4-wrapper.jar.sha256"
    },
    null,
    null,
    null,
    null,
    null,
    null,
    null,
    {
        "sha256": "96f793a18e056c23ffeec67c1f3bb8eccff5a4a407fc9ceac183527e7eedf4b6",
        "wrapperChecksumUrl": "https://services.gradle.org/distributions/gradle-6.2-rc-2-wrapper.jar.sha256"
    },
    null,
    null,
    null,
    null,
    {
        "sha256": "96f793a18e056c23ffeec67c1f3bb8eccff5a4a407fc9ceac183527e7eedf4b6",
        "wrapperChecksumUrl": "https://services.gradle.org/distributions/gradle-6.1-rc-2-wrapper.jar.sha256"
    },

I just tried with 9752381 (the commit before the parallel download) and there I don't get null entries.
A diff between the two:

↪  diff /tmp/checksums.json <(cat ./org.eclipse.jdt.ls.core/gradle/checksums/checksums.json| jq -r '.[] | .wrapperChecksumUrl' | sort)
2,5d1
< https://services.gradle.org/distributions/gradle-1.10-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-1.11-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-1.12-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-1.1-wrapper.jar.sha256
7d2
< https://services.gradle.org/distributions/gradle-1.3-wrapper.jar.sha256
10,14d4
< https://services.gradle.org/distributions/gradle-1.6-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-1.7-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-1.8-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-1.9-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-2.0-wrapper.jar.sha256
21d10
< https://services.gradle.org/distributions/gradle-2.1-wrapper.jar.sha256
23,25d11
< https://services.gradle.org/distributions/gradle-2.2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-2.3-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-2.4-wrapper.jar.sha256
29d14
< https://services.gradle.org/distributions/gradle-2.8-wrapper.jar.sha256
41d25
< https://services.gradle.org/distributions/gradle-4.2-wrapper.jar.sha256
60d43
< https://services.gradle.org/distributions/gradle-5.2.1-wrapper.jar.sha256
75d57
< https://services.gradle.org/distributions/gradle-5.5-rc-4-wrapper.jar.sha256
77d58
< https://services.gradle.org/distributions/gradle-5.6.1-wrapper.jar.sha256
80,81d60
< https://services.gradle.org/distributions/gradle-5.6.4-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-5.6-rc-1-wrapper.jar.sha256
83,88d61
< https://services.gradle.org/distributions/gradle-5.6-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.0.1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.0-rc-1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.0-rc-2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.0-rc-3-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.0-wrapper.jar.sha256
90,93d62
< https://services.gradle.org/distributions/gradle-6.1-milestone-1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.1-milestone-2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.1-milestone-3-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.1-rc-1-wrapper.jar.sha256
95,107d63
< https://services.gradle.org/distributions/gradle-6.1-rc-3-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.2.1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.2.2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.2-rc-1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.2-rc-2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.2-rc-3-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.3-rc-1-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.3-rc-2-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.3-rc-3-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.3-rc-4-wrapper.jar.sha256
< https://services.gradle.org/distributions/gradle-6.3-wrapper.jar.sha256
110d65
< https://services.gradle.org/distributions/gradle-6.4-rc-2-wrapper.jar.sha256
113d67
< https://services.gradle.org/distributions/gradle-6.4-wrapper.jar.sha256
115d68
< https://services.gradle.org/distributions/gradle-6.5-milestone-1-wrapper.jar.sha256
131d83
< https://services.gradle.org/distributions/gradle-6.7-rc-1-wrapper.jar.sha256
230a183,230
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null
> null

So the file before the change contained entries that the new one is missing.

@rgrunber rgrunber added bug and removed need info labels Jul 26, 2023
@mfussenegger
Copy link
Contributor Author

Added some logging, it can resolve the newUrl but I'm getting handshake errors:

Exception getting https://downloads.gradle.org/distributions/gradle-8.3-rc-1-wrapper.jar.sha256: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
Exception getting https://downloads.gradle.org/distributions/gradle-8.1-rc-3-wrapper.jar.sha256: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
Exception getting https://downloads.gradle.org/distributions/gradle-8.2-rc-1-wrapper.jar.sha256: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake
Exception getting https://downloads.gradle.org/distributions/gradle-8.2-wrapper.jar.sha256: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake

The more often I run it, the worse it seems to become. Maybe I'm hitting some kind of rate limit on the gradle.org side?

@rgrunber
Copy link
Contributor

rgrunber commented Jul 26, 2023

Looking up the error it seems more in the realm of some local configuration option (maybe for TLS?) might be something services.gradle.org doesn't support, hence the failure at handshake. I tried playing with -Dhttp.protocols.. but for the most part I would just get a failure launching the script if I use something improper or unsupported.

@snjeza
Copy link
Contributor

snjeza commented Jul 27, 2023

test this please

Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfussenegger were you able to determine what was causing the issue for you ? Does it still occur ? I think this is worth merging.

@rgrunber rgrunber added this to the End September 2023 milestone Sep 19, 2023
@rgrunber rgrunber merged commit e894e35 into eclipse-jdtls:master Sep 19, 2023
@mfussenegger
Copy link
Contributor Author

were you able to determine what was causing the issue for you ?

No not really. I still think it is an issue on the server/cdn side given that it works if the requests are made sequential and I otherwise don't experience any SSL issues or network connectivity errors.

Does it still occur ?

Yes.
I was thinking of adding some retry/back-off logic to the download. Or maybe the gradle folks could be asked to provide a merged file like that, then the eclipse.jdt.ls build wouldn't have to make so many requests.

@mfussenegger mfussenegger deleted the checksum-nulls branch September 21, 2023 07:42
@rgrunber
Copy link
Contributor

It might also be related to the number concurrent requests that the server is willing to handle from a given client. Though it wouldn't explain why it works in some instances.

mfussenegger added a commit to mfussenegger/eclipse.jdt.ls that referenced this pull request Oct 20, 2023
This is a follow up to eclipse-jdtls#2775
I frequently experience build failures due to connection errors.

After some debugging with wireshark, netstat and
`-Djdk.httpclient.HttpClient.log=all` I suspect that I'm getting rate
throttled.

Somewhere between 150 and 200 requests, the connections either get
closed by the remote or almost stall.

This excludes nightly, snapshot, rc and broken releases, which would
mitigate the issue somewhat. The biggest impact has cutting out RC
releases:

total versions: 386
without nightly: 385
without RCs: 173
without broken: 172

Note that this still doesn't completely fix the issue for me, but it
helsp reduce the chance for it happening.
mfussenegger added a commit to mfussenegger/eclipse.jdt.ls that referenced this pull request Oct 20, 2023
This is a follow up to eclipse-jdtls#2775
I frequently experience build failures due to connection errors.

After some debugging with wireshark, netstat and
`-Djdk.httpclient.HttpClient.log=all` I suspect that I'm getting rate
throttled.

Somewhere between 150 and 200 requests, the connections either get
closed by the remote or almost stall.

To mitigate the issue, this excludes nightly, snapshot, rc and broken
gradle releases. The biggest impact has cutting out RC releases:

total versions: 386
without nightly: 385
without RCs: 173
without broken: 172

Note that this still doesn't completely fix the issue for me, but it
helsp reduce the chance for it happening.
mfussenegger added a commit to mfussenegger/eclipse.jdt.ls that referenced this pull request Oct 20, 2023
This is a follow up to eclipse-jdtls#2775
I frequently experience build failures due to connection errors.

After some debugging with wireshark, netstat and
`-Djdk.httpclient.HttpClient.log=all` I suspect that I'm getting rate
throttled.

Somewhere between 150 and 200 requests, the connections either get
closed by the remote or almost stall.

To mitigate the issue, this excludes nightly, snapshot, rc and broken
gradle releases. The biggest impact has cutting out RC releases:

total versions: 386
without nightly: 385
without RCs: 173
without broken: 172

Note that this still doesn't completely fix the issue for me, but it
helps reduce the chance for it happening.
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 this pull request may close these issues.

4 participants