Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
[FIXED JENKINS-37195] Show parent page if invalid URL is used.
  • Loading branch information
uhafner committed Jan 4, 2017
1 parent a2a98c5 commit 1dcfdc5df42790f55a51a4592923b65916385b0b
@@ -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;
@@ -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
}
}

/**
@@ -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;
@@ -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
}
}

/**
@@ -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
}
}

/**

0 comments on commit 1dcfdc5

Please sign in to comment.