Skip to content

Commit 1050622

Browse files
jongyoulclaude
andcommitted
[ZEPPELIN-6400] Handle time unit suffixes in InterpreterLauncher.getConnectTimeout
ZeppelinConfiguration parsed time values like "600s" internally, but after switching to Properties, the raw string is passed directly. Add parseTimeValue() to handle "s" (seconds) and "ms" (milliseconds) suffixes in timeout configuration values. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 03a602a commit 1050622

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/launcher/InterpreterLauncher.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,31 @@ protected InterpreterLauncher(Properties zProperties, RecoveryStorage recoverySt
5656
* @return
5757
*/
5858
protected int getConnectTimeout(InterpreterLaunchContext context) {
59-
int connectTimeout = (int) Long.parseLong(
59+
int connectTimeout = (int) parseTimeValue(
6060
zProperties.getProperty(CONNECT_TIMEOUT_KEY,
6161
String.valueOf(DEFAULT_CONNECT_TIMEOUT)));
6262
Properties properties = context.getProperties();
6363
if (properties != null && properties.containsKey(CONNECT_TIMEOUT_KEY)) {
64-
connectTimeout = Integer.parseInt(properties.getProperty(CONNECT_TIMEOUT_KEY));
64+
connectTimeout = (int) parseTimeValue(properties.getProperty(CONNECT_TIMEOUT_KEY));
6565
}
6666
return connectTimeout;
6767
}
6868

69+
/**
70+
* Parse a time value string that may have a suffix (s for seconds, ms for milliseconds).
71+
* If no suffix, the value is treated as milliseconds.
72+
*/
73+
private static long parseTimeValue(String value) {
74+
value = value.trim().toLowerCase();
75+
if (value.endsWith("ms")) {
76+
return Long.parseLong(value.substring(0, value.length() - 2).trim());
77+
} else if (value.endsWith("s")) {
78+
return Long.parseLong(value.substring(0, value.length() - 1).trim()) * 1000;
79+
} else {
80+
return Long.parseLong(value);
81+
}
82+
}
83+
6984
protected int getConnectPoolSize(InterpreterLaunchContext context) {
7085
return Integer.parseInt(context.getProperties().getProperty(
7186
CONNECTION_POOL_SIZE_KEY,

0 commit comments

Comments
 (0)