Author: cdouglas
Date: Tue Sep 30 11:54:36 2008
New Revision: 700548
URL: http://svn.apache.org/viewvc?rev=700548&view=rev
Log:
HADOOP-4210. Fix findbugs warnings for equals implementations of mapred ID
classes. Removed public, static ID::read and ID::forName; made ID an
abstract class. Contributed by Suresh Srinivas.
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/MapTypeID.java
hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/TypeID.java
hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/VectorTypeID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/ID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskAttemptID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/ID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/JobID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskAttemptID.java
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskID.java
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Tue Sep 30 11:54:36 2008
@@ -4,6 +4,10 @@
INCOMPATIBLE CHANGES
+ HADOOP-4210. Fix findbugs warnings for equals implementations of mapred ID
+ classes. Removed public, static ID::read and ID::forName; made ID an
+ abstract class. (Suresh Srinivas via cdouglas)
+
NEW FEATURES
IMPROVEMENTS
Modified:
hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/MapTypeID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/MapTypeID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/MapTypeID.java
(original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/MapTypeID.java Tue
Sep 30 11:54:36 2008
@@ -62,14 +62,13 @@
* same type
*/
public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof MapTypeID))
+ if (!super.equals(o))
return false;
+
MapTypeID mti = (MapTypeID) o;
- if (!this.typeIDKey.equals(mti.typeIDKey))
- return false;
- return this.typeIDValue.equals(mti.typeIDValue);
+
+ return this.typeIDKey.equals(mti.typeIDKey) &&
+ this.typeIDValue.equals(mti.typeIDValue);
}
/**
Modified: hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/TypeID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/TypeID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/TypeID.java
(original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/TypeID.java Tue
Sep 30 11:54:36 2008
@@ -84,8 +84,13 @@
public boolean equals(Object o) {
if (this == o)
return true;
- if (!(o instanceof TypeID))
+
+ if (o == null)
+ return false;
+
+ if (this.getClass() != o.getClass())
return false;
+
TypeID oTypeID = (TypeID) o;
return (this.typeVal == oTypeID.typeVal);
}
Modified:
hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/VectorTypeID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/VectorTypeID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/VectorTypeID.java
(original)
+++ hadoop/core/trunk/src/core/org/apache/hadoop/record/meta/VectorTypeID.java
Tue Sep 30 11:54:36 2008
@@ -47,10 +47,9 @@
* same type
*/
public boolean equals(Object o) {
- if (this == o)
- return true;
- if (!(o instanceof VectorTypeID))
+ if (!super.equals (o))
return false;
+
VectorTypeID vti = (VectorTypeID) o;
return this.typeIDElement.equals(vti.typeIDElement);
}
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/ID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/ID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/ID.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/ID.java Tue Sep 30
11:54:36 2008
@@ -33,7 +33,7 @@
* @see TaskID
* @see TaskAttemptID
*/
-public class ID implements WritableComparable<ID> {
+public abstract class ID implements WritableComparable<ID> {
protected int id;
/** constructs an ID object from the given int */
@@ -61,9 +61,11 @@
@Override
public boolean equals(Object o) {
+ if (this == o)
+ return true;
if(o == null)
return false;
- if (o.getClass().equals(ID.class)) {
+ if (o.getClass() == this.getClass()) {
ID that = (ID) o;
return this.id == that.id;
}
@@ -83,29 +85,4 @@
public void write(DataOutput out) throws IOException {
out.writeInt(id);
}
-
- public static ID read(DataInput in) throws IOException {
- ID id = new ID();
- id.readFields(in);
- return id;
- }
-
- /**
- * Construct an ID object from given string
- *
- * @return constructed Id object or null if the given String is null
- * @throws IllegalArgumentException if the given string is malformed
- */
- public static ID forName(String str) throws IllegalArgumentException {
- if (str == null)
- return null;
- try {
- int id = Integer.parseInt(str);
- return new ID(id);
- }
- catch (Exception ex) {
- throw new IllegalArgumentException("Id string : " + str
- + " is not propoerly formed");
- }
- }
}
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobID.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/JobID.java Tue Sep 30
11:54:36 2008
@@ -73,14 +73,11 @@
@Override
public boolean equals(Object o) {
- if(o == null)
+ if (!super.equals(o))
return false;
- if(o.getClass().equals(JobID.class)) {
- JobID that = (JobID)o;
- return this.id==that.id
- && this.jtIdentifier.equals(that.jtIdentifier);
- }
- else return false;
+
+ JobID that = (JobID)o;
+ return this.jtIdentifier.equals(that.jtIdentifier);
}
/**Compare JobIds by first jtIdentifiers, then by job numbers*/
Modified:
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskAttemptID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskAttemptID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskAttemptID.java
(original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskAttemptID.java
Tue Sep 30 11:54:36 2008
@@ -125,15 +125,12 @@
@Override
public boolean equals(Object o) {
- if(o == null)
+ if (!super.equals(o))
return false;
- if(o.getClass().equals(TaskAttemptID.class)) {
- TaskAttemptID that = (TaskAttemptID)o;
- return this.id==that.id
- && this.taskId.equals(that.taskId)
- && this.jtTimestamp == that.jtTimestamp;
- }
- else return false;
+
+ TaskAttemptID that = (TaskAttemptID)o;
+ return this.taskId.equals(that.taskId) &&
+ this.jtTimestamp == that.jtTimestamp;
}
/**Compare TaskIds by first tipIds, then by task numbers. */
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskID.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapred/TaskID.java Tue Sep
30 11:54:36 2008
@@ -97,15 +97,11 @@
@Override
public boolean equals(Object o) {
- if(o == null)
+ if (!super.equals(o))
return false;
- if(o.getClass().equals(TaskID.class)) {
- TaskID that = (TaskID)o;
- return this.id==that.id
- && this.isMap == that.isMap
- && this.jobId.equals(that.jobId);
- }
- else return false;
+
+ TaskID that = (TaskID)o;
+ return this.isMap == that.isMap && this.jobId.equals(that.jobId);
}
/**Compare TaskInProgressIds by first jobIds, then by tip numbers. Reduces
are
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/ID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/ID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/ID.java (original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/ID.java Tue Sep 30
11:54:36 2008
@@ -33,7 +33,7 @@
* @see TaskID
* @see TaskAttemptID
*/
-public class ID implements WritableComparable<ID> {
+public abstract class ID implements WritableComparable<ID> {
protected int id;
/** constructs an ID object from the given int */
@@ -61,9 +61,11 @@
@Override
public boolean equals(Object o) {
+ if (this == o)
+ return true;
if(o == null)
return false;
- if (o.getClass().equals(ID.class)) {
+ if (o.getClass() == this.getClass()) {
ID that = (ID) o;
return this.id == that.id;
}
@@ -83,29 +85,4 @@
public void write(DataOutput out) throws IOException {
out.writeInt(id);
}
-
- public static ID read(DataInput in) throws IOException {
- ID id = new ID();
- id.readFields(in);
- return id;
- }
-
- /**
- * Construct an ID object from given string
- *
- * @return constructed Id object or null if the given String is null
- * @throws IllegalArgumentException if the given string is malformed
- */
- public static ID forName(String str) throws IllegalArgumentException {
- if (str == null)
- return null;
- try {
- int id = Integer.parseInt(str);
- return new ID(id);
- }
- catch (Exception ex) {
- throw new IllegalArgumentException("Id string : " + str
- + " is not propoerly formed");
- }
- }
}
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/JobID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/JobID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/JobID.java
(original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/JobID.java Tue Sep
30 11:54:36 2008
@@ -74,14 +74,11 @@
@Override
public boolean equals(Object o) {
- if(o == null)
+ if (!super.equals(o))
return false;
- if(o.getClass().equals(JobID.class)) {
- JobID that = (JobID)o;
- return this.id==that.id
- && this.jtIdentifier.equals(that.jtIdentifier);
- }
- else return false;
+
+ JobID that = (JobID)o;
+ return this.jtIdentifier.equals(that.jtIdentifier);
}
/**Compare JobIds by first jtIdentifiers, then by job numbers*/
Modified:
hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskAttemptID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskAttemptID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskAttemptID.java
(original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskAttemptID.java
Tue Sep 30 11:54:36 2008
@@ -92,14 +92,11 @@
@Override
public boolean equals(Object o) {
- if(o == null)
+ if (!super.equals(o))
return false;
- if(o.getClass().equals(TaskAttemptID.class)) {
- TaskAttemptID that = (TaskAttemptID)o;
- return this.id==that.id
- && this.taskId.equals(that.taskId);
- }
- else return false;
+
+ TaskAttemptID that = (TaskAttemptID)o;
+ return this.taskId.equals(that.taskId);
}
/**Compare TaskIds by first tipIds, then by task numbers. */
Modified: hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskID.java
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskID.java?rev=700548&r1=700547&r2=700548&view=diff
==============================================================================
--- hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskID.java
(original)
+++ hadoop/core/trunk/src/mapred/org/apache/hadoop/mapreduce/TaskID.java Tue
Sep 30 11:54:36 2008
@@ -97,15 +97,11 @@
@Override
public boolean equals(Object o) {
- if(o == null)
+ if (!super.equals(o))
return false;
- if(o.getClass().equals(TaskID.class)) {
- TaskID that = (TaskID)o;
- return this.id==that.id
- && this.isMap == that.isMap
- && this.jobId.equals(that.jobId);
- }
- else return false;
+
+ TaskID that = (TaskID)o;
+ return this.isMap == that.isMap && this.jobId.equals(that.jobId);
}
/**Compare TaskInProgressIds by first jobIds, then by tip numbers. Reduces
are