Skip to content

Don't swallow IOException caused by opening socket #2041

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 4 commits into from
Dec 11, 2024

Conversation

Sineaggi
Copy link
Contributor

While debugging an issue locally I noticed the stacktrace included references to the DomainSocket class. This meant that somehow java.net.UnixDomainSocketAddress was being bypassed. I thought there was an issue with the jvm I was running on, but it turns out we were simply swallowing the IOException thrown by the SocketChannel.open(this.socketAddress); call, then trying to load the socket via the DomainSocket class.

I've fixed the code by adding the thrown methods to the signature, and catching the exact exceptions thrown by the methods in the class one level higher.

Exception in question.

Caused by: java.io.IOException: com.sun.jna.LastErrorException: [61] Connection refused
        at com.github.dockerjava.transport.DomainSocket.<init>(DomainSocket.java:63)
        at com.github.dockerjava.transport.BsdDomainSocket.<init>(BsdDomainSocket.java:43)
        at com.github.dockerjava.transport.DomainSocket.get(DomainSocket.java:138)
        at com.github.dockerjava.transport.UnixSocket.get(UnixSocket.java:29)
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl$2.createSocket(ApacheDockerHttpClientImpl.java:153)
        at org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:125)
        at org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:409)
        at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:164)
        at org.apache.hc.client5.http.impl.classic.InternalExecRuntime.connectEndpoint(InternalExecRuntime.java:174)
        at org.apache.hc.client5.http.impl.classic.ConnectExec.execute(ConnectExec.java:135)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at org.apache.hc.client5.http.impl.classic.ProtocolExec.execute(ProtocolExec.java:172)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at org.apache.hc.client5.http.impl.classic.HttpRequestRetryExec.execute(HttpRequestRetryExec.java:93)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at org.apache.hc.client5.http.impl.classic.ContentCompressionExec.execute(ContentCompressionExec.java:128)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement$1.proceed(ExecChainElement.java:57)
        at org.apache.hc.client5.http.impl.classic.RedirectExec.execute(RedirectExec.java:116)
        at org.apache.hc.client5.http.impl.classic.ExecChainElement.execute(ExecChainElement.java:51)
        at org.apache.hc.client5.http.impl.classic.InternalHttpClient.doExecute(InternalHttpClient.java:178)
        at org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:67)
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:191)
        ... 67 more
Caused by: com.sun.jna.LastErrorException: [61] Connection refused
        at com.github.dockerjava.transport.BsdDomainSocket.connect(Native Method)
        at com.github.dockerjava.transport.BsdDomainSocket.connect(BsdDomainSocket.java:49)
        at com.github.dockerjava.transport.DomainSocket.open(DomainSocket.java:69)
        at com.github.dockerjava.transport.DomainSocket.<init>(DomainSocket.java:59)
        ... 92 more

@Sineaggi Sineaggi force-pushed the dont-trash-ioexception branch from 564c7d3 to 2e91373 Compare January 12, 2023 19:10
@Sineaggi Sineaggi force-pushed the dont-trash-ioexception branch from 2e91373 to d82d9be Compare February 7, 2023 04:06
@Sineaggi
Copy link
Contributor Author

Bump

1 similar comment
@Sineaggi
Copy link
Contributor Author

Bump

@Sineaggi
Copy link
Contributor Author

@eddumelendez Would you be able to check this out?

@Sineaggi Sineaggi requested a review from a team as a code owner April 23, 2023 05:31
@Sineaggi
Copy link
Contributor Author

Sineaggi commented Aug 3, 2023

Bump

@Sineaggi Sineaggi force-pushed the dont-trash-ioexception branch from a36141d to 4d24f18 Compare August 21, 2023 18:15
@Sineaggi Sineaggi mentioned this pull request Aug 21, 2023
@Sineaggi
Copy link
Contributor Author

Bump

@Sineaggi Sineaggi force-pushed the dont-trash-ioexception branch from f2b77b8 to 9d8db99 Compare October 27, 2023 18:03
@Sineaggi
Copy link
Contributor Author

Rebased

Copy link

stale bot commented Mar 17, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@Sineaggi
Copy link
Contributor Author

Sineaggi commented Aug 3, 2024

Rebased, can we get this merged @eddumelendez?

@eddumelendez eddumelendez added this to the next milestone Dec 11, 2024
@eddumelendez eddumelendez merged commit 721f09f into docker-java:main Dec 11, 2024
5 checks passed
@eddumelendez
Copy link
Member

Thanks for your contribution, @Sineaggi !

@Sineaggi Sineaggi deleted the dont-trash-ioexception branch December 11, 2024 20:19
svc-squareup-copybara pushed a commit to cashapp/misk that referenced this pull request Dec 12, 2024
| Package | Type | Package file | Manager | Update | Change |
|---|---|---|---|---|---|
|
[com.google.http-client:google-http-client-jackson2](https://github.com/googleapis/google-http-java-client)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`1.45.2` -> `1.45.3` |
|
[com.google.http-client:google-http-client](https://github.com/googleapis/google-http-java-client)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`1.45.2` -> `1.45.3` |
|
[com.google.auth:google-auth-library-oauth2-http](https://github.com/googleapis/google-auth-library-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`1.30.0` -> `1.30.1` |
|
[com.google.auth:google-auth-library-credentials](https://github.com/googleapis/google-auth-library-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`1.30.0` -> `1.30.1` |
| [org.flywaydb:flyway-gradle-plugin](https://flywaydb.org)
([source](https://github.com/flyway/flyway)) | dependencies |
misk/gradle/libs.versions.toml | gradle | minor | `11.0.1` -> `11.1.0` |
|
[com.github.docker-java:docker-java-transport](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.4.0` -> `3.4.1` |
|
[com.github.docker-java:docker-java-transport-httpclient5](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.4.0` -> `3.4.1` |
|
[com.github.docker-java:docker-java-core](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.4.0` -> `3.4.1` |
|
[com.github.docker-java:docker-java-api](https://github.com/docker-java/docker-java)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`3.4.0` -> `3.4.1` |
| [software.amazon.awssdk:sdk-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.29.31` -> `2.29.32` |
|
[software.amazon.awssdk:dynamodb-enhanced](https://aws.amazon.com/sdkforjava)
| dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.29.31` -> `2.29.32` |
| [software.amazon.awssdk:dynamodb](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.29.31` -> `2.29.32` |
| [software.amazon.awssdk:aws-core](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.29.31` -> `2.29.32` |
| [software.amazon.awssdk:bom](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.29.31` -> `2.29.32` |
| [software.amazon.awssdk:auth](https://aws.amazon.com/sdkforjava) |
dependencies | misk/gradle/libs.versions.toml | gradle | patch |
`2.29.31` -> `2.29.32` |

---

> ⚠️ **Warning**
>
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>googleapis/google-http-java-client
(com.google.http-client:google-http-client-jackson2)</summary>

###
[`v1.45.3`](https://github.com/googleapis/google-http-java-client/blob/HEAD/CHANGELOG.md#1453-2024-12-11)

##### Dependencies

- Update dependency io.grpc:grpc-context to v1.69.0
([#&#8203;2050](googleapis/google-http-java-client#2050))
([9f4f6ab](googleapis/google-http-java-client@9f4f6ab))
- Update github/codeql-action action to v3.27.7
([#&#8203;2049](googleapis/google-http-java-client#2049))
([9190382](googleapis/google-http-java-client@9190382))

</details>

<details>
<summary>googleapis/google-auth-library-java
(com.google.auth:google-auth-library-oauth2-http)</summary>

###
[`v1.30.1`](https://github.com/googleapis/google-auth-library-java/blob/HEAD/CHANGELOG.md#1301-2024-12-11)

##### Bug Fixes

- JSON parsing of S2A addresses.
([#&#8203;1589](googleapis/google-auth-library-java#1589))
([9d5ebfe](googleapis/google-auth-library-java@9d5ebfe))

</details>

<details>
<summary>docker-java/docker-java
(com.github.docker-java:docker-java-transport)</summary>

###
[`v3.4.1`](https://github.com/docker-java/docker-java/releases/tag/3.4.1)

[Compare
Source](docker-java/docker-java@3.4.0...3.4.1)

##### Changes

- Fix restart test
[@&#8203;eddumelendez](https://github.com/eddumelendez)
([#&#8203;2375](docker-java/docker-java#2375))

##### 📈 Enhancements

- Add support for CgroupVersion and CgroupDriver
[@&#8203;LarsSven](https://github.com/LarsSven)
([#&#8203;2360](docker-java/docker-java#2360))

##### 🧰 Maintenance

- Don't swallow IOException caused by opening socket
[@&#8203;Sineaggi](https://github.com/Sineaggi)
([#&#8203;2041](docker-java/docker-java#2041))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 6pm every weekday,before 2am
every weekday" in timezone Australia/Melbourne, Automerge - At any time
(no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config help](https://github.com/renovatebot/renovate/discussions) if
that's undesired.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://github.com/renovatebot/renovate).

GitOrigin-RevId: 6eb3a8d6c07d3090499286e2624f648323e96355
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants