mirror of
https://github.com/jlengrand/github-api.git
synced 2026-04-04 08:21:23 +00:00
Fix for NullPointer in issue search results
User reported #708 which made me realize that search tests were basically all disabled. This terms on two basic search tests and also makes it so GHIssue can continue to work without a GHRepository set on it. Fixes #708
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
*/
|
||||
package org.kohsuke.github;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@@ -98,6 +100,10 @@ public class GHPullRequest extends GHIssue implements Refreshable {
|
||||
|
||||
@Override
|
||||
protected String getApiRoute() {
|
||||
if (owner == null) {
|
||||
// Issues returned from search to do not have an owner. Attempt to use url.
|
||||
return StringUtils.prependIfMissing(getUrl().toString().replace(root.getApiUrl(), ""), "/");
|
||||
}
|
||||
return "/repos/" + owner.getOwnerName() + "/" + owner.getName() + "/pulls/" + number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user