-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[java]: add websocket-port
test and --connect-existing
check
#15462
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
413a130
f1eac5f
2efeb62
15e4fdf
6300cd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,13 +222,26 @@ protected List<String> createArgs() { | |
List<String> args = new ArrayList<>(); | ||
args.add(String.format(Locale.ROOT, "--port=%d", getPort())); | ||
|
||
int wsPort = PortProber.findFreePort(); | ||
args.add(String.format("--websocket-port=%d", wsPort)); | ||
// Check if we're connecting to an existing Firefox instance | ||
boolean connectExisting = false; | ||
for (String arg : args) { | ||
if (arg.contains("--connect-existing")) { | ||
connectExisting = true; | ||
break; | ||
} | ||
} | ||
|
||
args.add("--allow-origins"); | ||
args.add(String.format("http://127.0.0.1:%d", wsPort)); | ||
args.add(String.format("http://localhost:%d", wsPort)); | ||
args.add(String.format("http://[::1]:%d", wsPort)); | ||
// Only allocate a free port for the websocket when not connecting to an existing instance | ||
// This avoids conflicts when multiple Firefox instances are started | ||
if (!connectExisting) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMHO we should check for "--websocket-port" here too, someone might want to select a specific port to forward it: |
||
int wsPort = PortProber.findFreePort(); | ||
args.add(String.format("--websocket-port=%d", wsPort)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be two args like this and 0 will autoselect a free port:
|
||
|
||
args.add("--allow-origins"); | ||
args.add(String.format("http://127.0.0.1:%d", wsPort)); | ||
args.add(String.format("http://localhost:%d", wsPort)); | ||
args.add(String.format("http://[::1]:%d", wsPort)); | ||
} | ||
|
||
if (logLevel != null) { | ||
args.add("--log"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
for (String arg : this.args) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joerg1985
this.args
is not accessible insidecreateArgs()
, is there any other way to access the passed args?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry my fault,
this.getArgs()
should work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even that doesn't works, I think we need to add a new method to the builder as Titus suggested.