[
https://issues.apache.org/jira/browse/HADOOP-13147?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847734#comment-17847734
]
ASF GitHub Bot commented on HADOOP-13147:
-----------------------------------------
ayushtkn commented on code in PR #6408:
URL: https://github.com/apache/hadoop/pull/6408#discussion_r1606103696
##########
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestPureJavaCrc32C.java:
##########
@@ -0,0 +1,36 @@
+/**
+ * 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.hadoop.util;
+
+import static org.junit.Assert.*;
+
+import java.util.zip.Checksum;
+
+import org.junit.Test;
+
+public class TestPureJavaCrc32C {
+
+ @Test
+ public void testChecksumInit() {
+ Checksum csum = new PureJavaCrc32C();
+ long crc1 = csum.getValue();
+ csum.reset();
+ long crc2 = csum.getValue();
+ assertEquals("reset should give same as initial value", crc1, crc2);
+ }
+}
Review Comment:
A test like this does demonstrates the issue what I believe you intend to fix
```suggestion
/**
* 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.hadoop.util;
import java.util.zip.Checksum;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestPureJavaCrc32C {
@Test
public void testChecksumInit() {
Checksum csum = new DummyPureJavaCrc32C();
long crc1 = csum.getValue();
csum.reset();
long crc2 = csum.getValue();
assertEquals("reset should give same as initial value", crc1, crc2);
}
static class DummyPureJavaCrc32C extends PureJavaCrc32C {
private final String dummVariable;
DummyPureJavaCrc32C() {
dummVariable = "abc";
}
@Override
public void reset() {
dummVariable.toString();
}
}
}
```
> Constructors must not call overrideable methods
> -----------------------------------------------
>
> Key: HADOOP-13147
> URL: https://issues.apache.org/jira/browse/HADOOP-13147
> Project: Hadoop Common
> Issue Type: Bug
> Affects Versions: 2.0.6-alpha
> Environment:
> http://svn.apache.org/repos/asf/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PureJavaCrc32C.java
> Reporter: Sebb
> Priority: Blocker
> Labels: pull-request-available
>
> Constructors must not call overrideable methods.
> An object is not guaranteed fully constructed until the constructor exits, so
> the subclass override may not see the fully created parent object.
> This applies to:
> PureJavaCrc32
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]