Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-37195] Show parent page if invalid URL is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 4, 2017
1 parent a2a98c5 commit 1dcfdc5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
16 changes: 14 additions & 2 deletions src/main/java/hudson/plugins/analysis/core/BuildResult.java
Expand Up @@ -10,6 +10,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand Down Expand Up @@ -1120,8 +1121,19 @@ private Collection<FileAnnotation> loadFixedWarningsBeforeRelease72() {
* @return the dynamic result of the analysis (detail page).
*/
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
return DetailFactory.create(getResultActionType()).createTrendDetails(link, getOwner(), getContainer(), getFixedWarnings(),
getNewWarnings(), getErrors(), getDefaultEncoding(), getDisplayName());
try {
return DetailFactory.create(getResultActionType()).createTrendDetails(link, getOwner(), getContainer(), getFixedWarnings(),
getNewWarnings(), getErrors(), getDefaultEncoding(), getDisplayName());
}
catch (NoSuchElementException exception) {
try {
response.sendRedirect2("../");
}
catch (IOException e) {
// ignore
}
return this; // fallback on broken URLs
}
}

/**
Expand Down
@@ -1,18 +1,17 @@
package hudson.plugins.analysis.views;

import java.io.IOException;
import java.util.Collection;
import java.util.NoSuchElementException;

import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;

import com.infradna.tool.bridge_method_injector.WithBridgeMethods;

import hudson.model.ModelObject;
import hudson.model.AbstractBuild;
import hudson.model.ModelObject;
import hudson.model.Run;

import hudson.plugins.analysis.util.model.AnnotationContainer;
import hudson.plugins.analysis.util.model.FileAnnotation;
import hudson.plugins.analysis.util.model.Priority;
Expand Down Expand Up @@ -137,7 +136,18 @@ public String getLocalizedPriority(final String priorityName) {
* @return the dynamic result of this module detail view
*/
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) {
return detailFactory.createDetails(link, owner, getContainer(), defaultEncoding, getDisplayName());
try {
return detailFactory.createDetails(link, owner, getContainer(), defaultEncoding, getDisplayName());
}
catch (NoSuchElementException exception) {
try {
response.sendRedirect2("../");
}
catch (IOException e) {
// ignore
}
return this; // fallback on broken URLs
}
}

/**
Expand Down
Expand Up @@ -295,7 +295,12 @@ private String createGenericTabUrl(final String link) {
* @return the hash code
*/
private int createHashCode(final String link, final String prefix) {
return Integer.parseInt(StringUtils.substringAfter(link, prefix));
try {
return Integer.parseInt(StringUtils.substringAfter(link, prefix));
}
catch (NumberFormatException e) {
return -1; // non-existent ID
}
}

/**
Expand Down

0 comments on commit 1dcfdc5

Please sign in to comment.