-
Notifications
You must be signed in to change notification settings - Fork 109
fix(client): Adapt client graphSpace method to 1.7.0 server #712
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -29,7 +29,6 @@ | |
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashMap; | ||
| import java.util.LinkedHashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
|
|
@@ -71,15 +70,16 @@ public List<String> list() { | |
| } | ||
|
|
||
| public List<Map<String, Object>> listProfile(String prefix) { | ||
| String profilePath = joinPath(this.path(), "profile"); | ||
| Map<String, Object> params = new LinkedHashMap<>(); | ||
| params.put("prefix", prefix); | ||
| RestResult result = this.client.get(profilePath, params); | ||
| List<Map> results = result.readList(Map.class); | ||
| List<String> names = this.list(); | ||
| List<Map<String, Object>> profiles = new ArrayList<>(); | ||
| for (Object entry : results) { | ||
| profiles.add(JsonUtil.fromJson(JsonUtil.toJson(entry), Map.class)); | ||
| for (String name : names) { | ||
| if (name.startsWith(prefix)) { | ||
| GraphSpace space = this.get(name); | ||
| Map<String, Object> profileMap = JsonUtil.fromJson(JsonUtil.toJson(space), Map.class); | ||
| profiles.add(profileMap); | ||
| } | ||
| } | ||
|
|
||
| return profiles; | ||
|
Comment on lines
72
to
83
|
||
| } | ||
|
|
||
|
|
||
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.
The prefix parameter can be null (as seen in GraphSpaceManager.listProfile() which calls this method with null), but this code calls name.startsWith(prefix) without checking if prefix is null first. This will cause a NullPointerException. Consider using StringUtils.isEmpty(prefix) to handle null/empty prefix cases - when prefix is null or empty, all names should be included in the result.