Permalink
Browse files

singleton NullChangeLogParser to reduce memory footprint

  • Loading branch information...
1 parent f4b6826 commit 39c76672607a6b7ad0cc9b6c35507a2fe9a4b8db @huybrechts committed Dec 23, 2011
View
2 core/src/main/java/hudson/model/AbstractBuild.java
@@ -563,7 +563,7 @@ private void checkout(BuildListener listener) throws Exception {
// for historical reasons, null in the scm field means CVS, so we need to explicitly set this to something
// in case check out fails and leaves a broken changelog.xml behind.
// see http://www.nabble.com/CVSChangeLogSet.parse-yields-SAXParseExceptions-when-parsing-bad-*AccuRev*-changelog.xml-files-td22213663.html
- AbstractBuild.this.scm = new NullChangeLogParser();
+ AbstractBuild.this.scm = NullChangeLogParser.INSTANCE;
try {
if (project.checkout(AbstractBuild.this,launcher,listener,new File(getRootDir(),"changelog.xml"))) {
View
7 core/src/main/java/hudson/scm/NullChangeLogParser.java 100644 → 100755
@@ -34,7 +34,14 @@
* @author Kohsuke Kawaguchi
*/
public class NullChangeLogParser extends ChangeLogParser {
+
+ public static final NullChangeLogParser INSTANCE = new NullChangeLogParser();
+
public ChangeLogSet<? extends ChangeLogSet.Entry> parse(AbstractBuild build, File changelogFile) throws IOException, SAXException {
return ChangeLogSet.createEmpty(build);
}
+
+ public Object readResolve() {
+ return INSTANCE;
+ }
}
View
2 core/src/main/java/hudson/scm/NullSCM.java 100644 → 100755
@@ -55,7 +55,7 @@ public boolean checkout(AbstractBuild<?,?> build, Launcher launcher, FilePath re
}
public ChangeLogParser createChangeLogParser() {
- return new NullChangeLogParser();
+ return NullChangeLogParser.INSTANCE;
}
@Extension

0 comments on commit 39c7667

Please sign in to comment.