Skip to content

Commit

Permalink
INSPECTIT-2340: Fixed NPE in Http details generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Senic authored and pbouillet committed Mar 17, 2017
1 parent d4c974f commit 438fb11
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,12 @@ public void setInspectItTaggingHeaderValue(String inspectItTaggingHeaderValue) {
* @return the URL
*/
public String getUrl() {
// for backward compatibility with storage data always check if data is available
StringBuilder builder = new StringBuilder();
builder.append(scheme).append("://").append(serverName);
if (serverPort > 0) {
if ((null != scheme) && (null != serverName)) {
builder.append(scheme).append("://").append(serverName);
}
if ((null != serverPort) && (serverPort.intValue() > 0)) {
builder.append(':').append(serverPort);
}
builder.append(uri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ public DetailsTable generate(DefaultData defaultData, RepositoryDefinition repos
boolean usedHTTPS = StringUtils.isNotEmpty(scheme) && "https".equalsIgnoreCase(scheme);

String portDescription;
if (httpTimerData.getHttpInfo().getServerPort() > 0) {
if ((null != httpTimerData.getHttpInfo().getServerPort()) && (httpTimerData.getHttpInfo().getServerPort() > 0)) {
portDescription = String.valueOf(httpTimerData.getHttpInfo().getServerPort());
} else {
portDescription = NOT_AVAILABLE;
}

table.addContentRow("Used HTTPS:", null, new DetailsCellContent[] { new YesNoDetailsCellContent(usedHTTPS) });
table.addContentRow("Method:", null, new DetailsCellContent[] { new DetailsCellContent(httpTimerData.getHttpInfo().getRequestMethod()) });
table.addContentRow("Server Name:", null, new DetailsCellContent[] { new DetailsCellContent(httpTimerData.getHttpInfo().getServerName()) });
table.addContentRow("Method:", null, new DetailsCellContent[] { new DetailsCellContent(StringUtils.defaultString(httpTimerData.getHttpInfo().getRequestMethod(), NOT_AVAILABLE)) });
table.addContentRow("Server Name:", null, new DetailsCellContent[] { new DetailsCellContent(StringUtils.defaultString(httpTimerData.getHttpInfo().getServerName(), NOT_AVAILABLE)) });
table.addContentRow("Port:", null, new DetailsCellContent[] { new DetailsCellContent(portDescription) });
table.addContentRow("URI:", null, new DetailsCellContent[] { new DetailsCellContent(StringUtils.defaultString(httpTimerData.getHttpInfo().getUri())) });
table.addContentRow("Query String:", null, new DetailsCellContent[] { new DetailsCellContent(StringUtils.defaultString(httpTimerData.getHttpInfo().getQueryString(), NOT_AVAILABLE)) });
Expand Down

0 comments on commit 438fb11

Please sign in to comment.