Skip to content

Commit beba6a3

Browse files
authored
Merge pull request #8971 from stuartwdouglas/8927
Only check debug port usage on first startup
2 parents df0a02c + 11dc2ed commit beba6a3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public class DevMojo extends AbstractMojo {
245245
@Component
246246
private BuildPluginManager pluginManager;
247247

248+
private Boolean debugPortOk;
249+
248250
@Override
249251
public void execute() throws MojoFailureException, MojoExecutionException {
250252

@@ -492,15 +494,18 @@ class DevModeRunner {
492494
*/
493495
void prepare() throws Exception {
494496
if (debug == null) {
495-
boolean useDebugMode = true;
496497
// debug mode not specified
497498
// make sure 5005 is not used, we don't want to just fail if something else is using it
498-
try (Socket socket = new Socket(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 5005)) {
499-
getLog().error("Port 5005 in use, not starting in debug mode");
500-
useDebugMode = false;
501-
} catch (IOException e) {
499+
// we don't check this on restarts, as the previous process is still running
500+
if (debugPortOk == null) {
501+
try (Socket socket = new Socket(InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 }), 5005)) {
502+
getLog().error("Port 5005 in use, not starting in debug mode");
503+
debugPortOk = false;
504+
} catch (IOException e) {
505+
debugPortOk = true;
506+
}
502507
}
503-
if (useDebugMode) {
508+
if (debugPortOk) {
504509
args.add("-Xdebug");
505510
args.add("-Xrunjdwp:transport=dt_socket,address=0.0.0.0:5005,server=y,suspend=" + suspend);
506511
}

0 commit comments

Comments
 (0)