Skip to content

Commit da5154a

Browse files
committed
Fixes btraceio#235: Allow also augmenting the script parameter from the agent.properties
1 parent f213dd0 commit da5154a

1 file changed

Lines changed: 30 additions & 4 deletions

File tree

  • src/share/classes/com/sun/btrace/agent

src/share/classes/com/sun/btrace/agent/Main.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,36 @@ private static void loadDefaultArguments() {
145145
for (Map.Entry<Object, Object> entry : ps.entrySet()) {
146146
String argKey = (String) entry.getKey();
147147
String argVal = (String) entry.getValue();
148-
if (!argMap.containsKey(argKey)) {
149-
System.err.println("applying default agent argument '" + argKey + "'='" + argVal + "'");
150-
argMap.put(argKey, argVal);
151-
if (argKey.equals("debug")) {
148+
if (argKey.equals("script")) {
149+
// special treatment for the 'script' parameter
150+
boolean replace = false;
151+
String scriptVal = argVal;
152+
if (scriptVal.startsWith("!")) {
153+
scriptVal = scriptVal.substring(1);
154+
replace = true;
155+
} else {
156+
String oldVal = argMap.get(argKey);
157+
if (oldVal != null && !oldVal.isEmpty()) {
158+
scriptVal = oldVal + ":" + scriptVal;
159+
} else {
160+
replace = true;
161+
}
162+
System.err.println("augmenting default agent argument '" + argKey + "':'" + argMap.get(argKey) + "' with '" + argVal + "'");
163+
164+
}
165+
if (replace) {
166+
System.err.println("setting default agent argument '" + argKey + "' with '" + scriptVal + "'");
167+
} else {
168+
System.err.println("augmenting default agent argument '" + argKey + "':'" + argMap.get(argKey) + "' with '" + argVal + "'");
169+
}
170+
171+
argMap.put(argKey, scriptVal);
172+
} else {
173+
if (!argMap.containsKey(argKey)) {
174+
System.err.println("applying default agent argument '" + argKey + "'='" + argVal + "'");
175+
argMap.put(argKey, argVal);
176+
if (argKey.equals("debug")) {
177+
}
152178
}
153179
}
154180
}

0 commit comments

Comments
 (0)