You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jk...@apache.org on 2019/05/13 20:54:07 UTC

[thrift] branch master updated (6ba58e9 -> b261f3c)

This is an automated email from the ASF dual-hosted git repository.

jking pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git.


    from 6ba58e9  Update README [ci skip]
     new 6b6a827  THRIFT-4857: Made Java TField class hash code consistent with equals.
     new b261f3c  THRIFT-4857: [java] added a unit test for TField

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/org/apache/thrift/protocol/TField.java     |  3 +-
 .../org/apache/thrift/protocol/TestTField.java     | 60 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 lib/java/test/org/apache/thrift/protocol/TestTField.java


[thrift] 01/02: THRIFT-4857: Made Java TField class hash code consistent with equals.

Posted by jk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git

commit 6b6a8279aba29a67f005f5e498e88519cdb85049
Author: Garret Wilson <ga...@globalmentor.com>
AuthorDate: Fri May 3 13:12:16 2019 -0700

    THRIFT-4857: Made Java TField class hash code consistent with equals.
    
    Client: java
---
 lib/java/src/org/apache/thrift/protocol/TField.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/java/src/org/apache/thrift/protocol/TField.java b/lib/java/src/org/apache/thrift/protocol/TField.java
index 31331bb..3872b00 100644
--- a/lib/java/src/org/apache/thrift/protocol/TField.java
+++ b/lib/java/src/org/apache/thrift/protocol/TField.java
@@ -21,7 +21,7 @@ package org.apache.thrift.protocol;
 
 /**
  * Helper class that encapsulates field metadata.
- *
+ * <p>Two fields are considered equal if they have the same type and id.</p>
  */
 public class TField {
   public TField() {
@@ -47,7 +47,6 @@ public class TField {
     final int prime = 31;
     int result = 1;
     result = prime * result + id;
-    result = prime * result + ((name == null) ? 0 : name.hashCode());
     result = prime * result + type;
     return result;
   }


[thrift] 02/02: THRIFT-4857: [java] added a unit test for TField

Posted by jk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jking pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git

commit b261f3c0f114be31ef0f9a103dc4d2baa7c4fc3f
Author: James E. King III <jk...@apache.org>
AuthorDate: Mon May 13 08:04:09 2019 -0400

    THRIFT-4857: [java] added a unit test for TField
---
 .../org/apache/thrift/protocol/TestTField.java     | 60 ++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/lib/java/test/org/apache/thrift/protocol/TestTField.java b/lib/java/test/org/apache/thrift/protocol/TestTField.java
new file mode 100644
index 0000000..f72c259
--- /dev/null
+++ b/lib/java/test/org/apache/thrift/protocol/TestTField.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.thrift.protocol;
+
+import junit.framework.TestCase;
+import static org.junit.Assert.assertNotEquals;
+
+public abstract class TestTField extends TestCase {
+
+  public void testConstructor() {
+    TField uut = new TField();
+    assertEquals("", uut.name);
+    assertEquals(TType.STOP, uut.type);
+    assertEquals(0, uut.id);
+
+    uut = new TField("foo", TType.VOID, (short)42);
+    assertEquals("foo", uut.name);
+    assertEquals(TType.VOID, uut.type);
+    assertEquals(42, uut.id);
+  }
+
+  public void testEquality() {
+    TField uut1 = new TField();
+    TField uut2 = new TField();
+    assertEquals(uut1, uut2);
+    assertEquals(uut1.hashCode(), uut2.hashCode());
+
+    uut1 = new TField("foo", TType.I32, (short)1);
+    uut2 = new TField("foo", TType.I32, (short)2);
+    assertNotEquals(uut1, uut2);
+    assertNotEquals(uut1.hashCode(), uut2.hashCode());
+
+    uut1 = new TField("foo", TType.VOID, (short)1);
+    uut2 = new TField("foo", TType.I32, (short)1);
+    assertNotEquals(uut1, uut2);
+    assertNotEquals(uut1.hashCode(), uut2.hashCode());
+
+    uut1 = new TField("foo", TType.VOID, (short)5);
+    uut2 = new TField("bar", TType.I32, (short)5);
+    assertEquals(uut1, uut2); // name field is ignored
+    assertEquals(uut1.hashCode(), uut2.hashCode());
+  }
+
+}