Skip to content

Commit

Permalink
[JENKINS-37473] findbugs stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
escoem committed Aug 17, 2016
1 parent 35ea6d6 commit b4a2abe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
5 changes: 5 additions & 0 deletions findbugs-exclude.xml
@@ -0,0 +1,5 @@
<FindBugsFilter>
<Match>
<Class name="~.+\.Messages" />
</Match>
</FindBugsFilter>
Expand Up @@ -23,6 +23,7 @@
*/
package hudson.plugins.changelog_history;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.scm.ChangeLogParser;
Expand Down Expand Up @@ -58,6 +59,7 @@ public ChangeLogHistoryAction(AbstractBuild<?,?> build) {
/**
* Get all changelog detail; used by index.jelly
*/
@SuppressFBWarnings(value = "REC_CATCH_EXCEPTION", justification = "legacy code")
public Map<Long,ChangeLogSet> getChangeLogSets() throws Exception {
ChangeLogParser parser = build.getProject().getScm().createChangeLogParser();
File baseDir = new File(build.getRootDir(), "changelog-history");
Expand All @@ -68,9 +70,11 @@ public boolean accept(File pathname) {
return pathname.isFile() && pathname.getName().matches("\\d+\\.xml");
}
});

if (files == null) {
throw new IllegalStateException("Null files not allowed here.");
}
// Descending sort by build number
Arrays.sort(files, new Comparator<File>() {
Arrays.sort(files , new Comparator<File>() {
public int compare(File f1, File f2) {
return Long.signum(getBuildNumber(f2) - getBuildNumber(f1));
}
Expand All @@ -81,11 +85,15 @@ public int compare(File f1, File f2) {
for (File file : files) {
ChangeLogSet changeLogSet = parser.parse(build, build.getProject().getScm().getEffectiveBrowser(), file);
// Hack to avoid showing revision info (it's for this build, not the old builds)
if (changeLogSet instanceof SubversionChangeLogSet) try {
Field f = SubversionChangeLogSet.class.getDeclaredField("revisionMap");
f.setAccessible(true);
f.set(changeLogSet, new HashMap(0));
} catch (Exception ex) { /* ignore */ }
if (changeLogSet instanceof SubversionChangeLogSet) {
try {
Field f = SubversionChangeLogSet.class.getDeclaredField("revisionMap");
f.setAccessible(true);
f.set(changeLogSet, new HashMap(0));
} catch (Exception ex) {
/* ignore */
}
}
result.put(getBuildNumber(file), changeLogSet);
}
return result;
Expand Down
Expand Up @@ -69,10 +69,13 @@ private void copyChangeLogs(AbstractBuild build) throws IOException, BuildExcept
}
// Copy changelog-history in this build, if any
File changeHistory = new File(build.getRootDir(), "changelog-history");
if (changeHistory.isDirectory()) {
checkDir(baseDir);
for (File file : changeHistory.listFiles()) {
Util.copyFile(file, new File(baseDir, file.getName()));
if (changeHistory != null && changeHistory.isDirectory()) {
File[] files = changeHistory.listFiles();
if (files != null) {
checkDir(baseDir);
for (File file : files) {
Util.copyFile(file, new File(baseDir, file.getName()));
}
}
copied = true;
}
Expand Down

0 comments on commit b4a2abe

Please sign in to comment.