Skip to content

Commit 50df99d

Browse files
committed
ipc: Ensure timeouts not (::) or long are rejected
1 parent 51ccd40 commit 50df99d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ipc.q

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,17 @@
9595
/ Open a connection to the specified target host/port with a maximum timeout period.
9696
/ NOTE: Passwords can be configured to not be printed to via logging
9797
/ @param hostPort (HostPort) The target process to connect to
98-
/ @param timeout (Integer) The maximum time to wait for a connection. Pass generic null to use the default
98+
/ @param timeout (Long) The maximum time to wait, in milliseconds, for a connection. Pass generic null to use the default
9999
/ @return (Integer) The handle to that process if the connection is successful
100100
/ @throws IllegalArgumentException If the host/port is not of the correct type
101101
/ @throws ConnectionFailedException If the connection to the process fails
102102
/ @see .ipc.cfg.defaultConnectTimeout
103103
/ @see .ipc.cfg.logPasswordsDuringConnect
104104
.ipc.connectWithTimeout:{[hostPort;timeout]
105-
$[not .type.isLong timeout;
105+
$[(::) ~ timeout;
106106
timeout:.ipc.cfg.defaultConnectTimeout;
107+
not .type.isLong timeout;
108+
'"IllegalArgumentException";
107109
0 > timeout;
108110
'"IllegalArgumentException"
109111
];
@@ -150,15 +152,17 @@
150152
/ Sends a one-shot query to the specified host/port with a specified connection timeout
151153
/ NOTE: Passwords can be configured to not be printed to via logging
152154
/ @param hostPort (HostPort) The target process to connect to
153-
/ @param timeout (Integer) The maximum time to wait for a connection. Pass generic null to use the default
155+
/ @param timeout (Long) The maximum time to wait, in milliseconds, for a connection. Pass generic null to use the default
154156
/ @return () The result of the query executed on the remote process
155157
/ @throws IllegalArgumentException If the host/port is not of the correct type
156158
/ @throws ConnectionFailedException If the connection to the process fails
157159
/ @see .ipc.cfg.defaultConnectTimeout
158160
/ @see .ipc.cfg.logPasswordsDuringConnect
159161
.ipc.oneShotWithTimeout:{[hostPort; timeout; query]
160-
$[not .type.isLong timeout;
162+
$[(::) ~ timeout;
161163
timeout:.ipc.cfg.defaultConnectTimeout;
164+
not .type.isLong timeout;
165+
'"IllegalArgumentException";
162166
0 > timeout;
163167
'"IllegalArgumentException"
164168
];

0 commit comments

Comments
 (0)