Skip to content

Commit f778863

Browse files
committed
fix null exception in TRexAStfClient.getTemplateGroupNames
Signed-off-by: Leo Ma <[email protected]>
1 parent bef2186 commit f778863

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/com/cisco/trex/stateful/TRexAstfClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.security.MessageDigest;
2121
import java.security.NoSuchAlgorithmException;
2222
import java.util.ArrayList;
23+
import java.util.Collections;
2324
import java.util.HashMap;
2425
import java.util.HashSet;
2526
import java.util.LinkedHashMap;
@@ -401,6 +402,11 @@ public List<String> getTemplateGroupNames() {
401402
* @return template group names
402403
*/
403404
public List<String> getTemplateGroupNames(String profileId) {
405+
if (profileId == null || !getProfileIds().contains(profileId)) {
406+
LOGGER.warn("can not fetch template group names due to invalid profileId, or relative profile is not loaded yet.");
407+
return Collections.emptyList();
408+
}
409+
404410
Map<String, Object> payload = createPayload(profileId);
405411
payload.put("initialized", false);
406412
String json = callMethod("get_tg_names", payload);

0 commit comments

Comments
 (0)