Skip to content

Commit 6805a33

Browse files
committed
Close file handle on exceptions during connect
Closes gh-32423
1 parent 95690f7 commit 6805a33

File tree

1 file changed

+9
-3
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket

1 file changed

+9
-3
lines changed

spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/DomainSocket.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -69,8 +69,14 @@ public abstract class DomainSocket extends AbstractSocket {
6969

7070
private FileDescriptor open(String path) {
7171
int handle = socket(PF_LOCAL, SOCK_STREAM, 0);
72-
connect(path, handle);
73-
return new FileDescriptor(handle, this::close);
72+
try {
73+
connect(path, handle);
74+
return new FileDescriptor(handle, this::close);
75+
}
76+
catch (RuntimeException ex) {
77+
this.close(handle);
78+
throw ex;
79+
}
7480
}
7581

7682
private int read(ByteBuffer buffer) throws IOException {

0 commit comments

Comments
 (0)