Merge branch '2.7.x' into 3.0.x

Closes gh-37459
pull/37462/head
Moritz Halbritter 1 year ago
commit 2b4afe974a

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,9 +69,15 @@ public abstract class DomainSocket extends AbstractSocket {
private FileDescriptor open(String path) { private FileDescriptor open(String path) {
int handle = socket(PF_LOCAL, SOCK_STREAM, 0); int handle = socket(PF_LOCAL, SOCK_STREAM, 0);
try {
connect(path, handle); connect(path, handle);
return new FileDescriptor(handle, this::close); return new FileDescriptor(handle, this::close);
} }
catch (RuntimeException ex) {
this.close(handle);
throw ex;
}
}
private int read(ByteBuffer buffer) throws IOException { private int read(ByteBuffer buffer) throws IOException {
try (Handle handle = this.fileDescriptor.acquire()) { try (Handle handle = this.fileDescriptor.acquire()) {

Loading…
Cancel
Save