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

Commit

Permalink
[FIXED JENKINS-14821]: Fixed equals method.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Sep 10, 2012
1 parent 66450ae commit 7e5f781
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
Expand Up @@ -11,7 +11,6 @@
import org.apache.commons.io.IOUtils;

import hudson.plugins.analysis.util.ContextHashCode;
import hudson.plugins.analysis.util.TreeStringBuilder;
import hudson.plugins.analysis.util.model.AbstractAnnotation;
import hudson.plugins.analysis.util.model.FileAnnotation;

Expand Down Expand Up @@ -71,15 +70,7 @@ public Collection<FileAnnotation> parse(final File file, final String moduleName
* this function used as a filter.
*/
protected Collection<FileAnnotation> intern(final Collection<FileAnnotation> annotations) {
TreeStringBuilder stringPool = new TreeStringBuilder();
for (FileAnnotation annotation : annotations) {
if (annotation instanceof AbstractAnnotation) {
AbstractAnnotation aa = (AbstractAnnotation) annotation;
aa.intern(stringPool);
}
}
stringPool.dedup();
return annotations;
return AbstractAnnotation.intern(annotations);
}

/**
Expand Down
Expand Up @@ -201,6 +201,28 @@ public void intern(final TreeStringBuilder builder) {
readResolve(); // String.intern some of the data fields
}


/**
* Let {@link FileAnnotation}s share some of their internal data structure
* to reduce memory footprint.
*
* @param annotations
* the annotations to compress
* @return The same object as passed in the 'annotations' parameter to let
* this function used as a filter.
*/
public static Collection<FileAnnotation> intern(final Collection<FileAnnotation> annotations) {
TreeStringBuilder stringPool = new TreeStringBuilder();
for (FileAnnotation annotation : annotations) {
if (annotation instanceof AbstractAnnotation) {
AbstractAnnotation aa = (AbstractAnnotation) annotation;
aa.intern(stringPool);
}
}
stringPool.dedup();
return annotations;
}

/**
* Sets the column position of this warning.
*
Expand Down Expand Up @@ -450,7 +472,7 @@ else if (!category.equals(other.category)) {
return false;
}
}
else if (!fileName.equals(other.fileName)) {
else if (!fileName.toString().equals(other.fileName.toString())) {
return false;
}
if (lineRanges == null) {
Expand All @@ -466,23 +488,23 @@ else if (!lineRanges.equals(other.lineRanges)) {
return false;
}
}
else if (!message.equals(other.message)) {
else if (!message.toString().equals(other.message.toString())) {
return false;
}
if (moduleName == null) {
if (other.moduleName != null) {
return false;
}
}
else if (!moduleName.equals(other.moduleName)) {
else if (!moduleName.toString().equals(other.moduleName.toString())) {
return false;
}
if (packageName == null) {
if (other.packageName != null) {
return false;
}
}
else if (!packageName.equals(other.packageName)) {
else if (!packageName.toString().equals(other.packageName.toString())) {
return false;
}
if (primaryLineNumber != other.primaryLineNumber) {
Expand Down

0 comments on commit 7e5f781

Please sign in to comment.