garydgregory commented on code in PR #441:
URL: https://github.com/apache/commons-compress/pull/441#discussion_r1409205097


##########
src/main/java/org/apache/commons/compress/harmony/pack200/Pack200Adapter.java:
##########
@@ -41,11 +42,11 @@ public void addPropertyChangeListener(final 
PropertyChangeListener listener) {
      *
      * @param value Completion between 0..1.
      */
-    protected void completed(final double value) {
+    protected void completed(final double value) throws IOException {

Review Comment:
   Hello @yakovsh 
   Thank for your updates.
   Note that if you add or remove exceptions to public or protected method 
signatures, you must update their Javadoc comments ;-)
   TY



##########
src/main/java/org/apache/commons/compress/utils/ParsingUtils.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.commons.compress.utils;
+
+import java.io.IOException;
+
+/**
+ * Utility methods for parsing data and converting it to other formats.
+ *
+ * @since 1.26

Review Comment:
   Note that the next version will be "1.26.0" as opposed to "1.26".



##########
src/test/java/org/apache/commons/compress/archivers/cpio/CpioArchiveEntryTest.java:
##########
@@ -0,0 +1,32 @@
+/*
+ * 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.commons.compress.archivers.cpio;
+
+import static org.junit.Assert.assertThrows;
+
+import org.junit.jupiter.api.Test;
+
+public class CpioArchiveEntryTest {

Review Comment:
   Nice to have: On tests I edit or add, I like to have a class Javadoc for a 
class `TestFoo` that says "Tests {@link Foo}". Your IDE (YMMV) then lets you 
hyperlink (F3 in Eclipse) to that class.



##########
src/test/java/org/apache/commons/compress/utils/ParsingUtilsTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.commons.compress.utils;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.IOException;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+public class ParsingUtilsTest {
+
+    @ParameterizedTest
+    @ValueSource(strings = {Integer.MIN_VALUE + "1", "x.x", "9e999", "1.1", 
"one", Integer.MAX_VALUE + "1"})
+    public void testParseIntValueInvalidValues(final String value) {
+        assertThrows(IOException.class, () -> 
ParsingUtils.parseIntValue(value, 10));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {Integer.MIN_VALUE + "", "-1", "1", "123456", 
Integer.MAX_VALUE + ""})
+    public void testParseIntValueValidValues(final String value) {
+        assertDoesNotThrow(() -> ParsingUtils.parseIntValue(value, 10));

Review Comment:
   We do not need the additional layer of `assertDoesNotThrow` for test methods 
that only test a single call.



##########
src/main/java/org/apache/commons/compress/utils/ParsingUtils.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.commons.compress.utils;
+
+import java.io.IOException;
+
+/**
+ * Utility methods for parsing data and converting it to other formats.
+ *
+ * @since 1.26
+ */
+public final class ParsingUtils {
+    /**
+     * Tries to parse the provided string value to an Integer, assuming a 
base-10 radix
+     *
+     * @param value string value to parse
+     * @return parsed value as an int
+     * @throws IOException

Review Comment:
   This Javadoc is incomplete because the throws tag is missing a description.



##########
src/test/java/org/apache/commons/compress/utils/ParsingUtilsTest.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.commons.compress.utils;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import java.io.IOException;
+
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+
+public class ParsingUtilsTest {
+
+    @ParameterizedTest
+    @ValueSource(strings = {Integer.MIN_VALUE + "1", "x.x", "9e999", "1.1", 
"one", Integer.MAX_VALUE + "1"})
+    public void testParseIntValueInvalidValues(final String value) {
+        assertThrows(IOException.class, () -> 
ParsingUtils.parseIntValue(value, 10));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {Integer.MIN_VALUE + "", "-1", "1", "123456", 
Integer.MAX_VALUE + ""})
+    public void testParseIntValueValidValues(final String value) {
+        assertDoesNotThrow(() -> ParsingUtils.parseIntValue(value, 10));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {Long.MIN_VALUE + "1", "x.x", "9e999", "1.1", 
"one", Long.MAX_VALUE + "1"})
+    public void testParseLongValueInvalidValues(final String value) {
+        assertThrows(IOException.class, () -> 
ParsingUtils.parseLongValue(value, 10));
+    }
+
+    @ParameterizedTest
+    @ValueSource(strings = {Long.MIN_VALUE + "", "-1", "1", "12345678901234", 
Long.MAX_VALUE + ""})
+    public void testParseLongValueValidValues(final String value) {
+        assertDoesNotThrow(() -> ParsingUtils.parseLongValue(value, 10));

Review Comment:
   See above.



##########
src/main/java/org/apache/commons/compress/utils/ParsingUtils.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.commons.compress.utils;
+
+import java.io.IOException;
+
+/**
+ * Utility methods for parsing data and converting it to other formats.
+ *
+ * @since 1.26
+ */
+public final class ParsingUtils {
+    /**
+     * Tries to parse the provided string value to an Integer, assuming a 
base-10 radix
+     *
+     * @param value string value to parse
+     * @return parsed value as an int
+     * @throws IOException
+     */
+    public static int parseIntValue(final String value) throws IOException {
+        return parseIntValue(value, 10);
+    }
+
+    /**
+     * Tries to parse the provided string value to an Integer
+     *
+     * @param value string value to parse
+     * @param radix radix value to use for parsing
+     * @return parsed value as an int
+     * @throws IOException
+     */
+    public static int parseIntValue(final String value, final int radix) 
throws IOException {
+        try {
+            return Integer.parseInt(value, radix);
+        } catch (final NumberFormatException exp) {
+            throw new IOException("Unable to parse int from string value: " + 
value);
+        }
+    }
+
+    /**
+     * Tries to parse the provided string value to a Long, assuming a base-10 
radix
+     *
+     * @param value string value to parse
+     * @return parsed value as a long
+     * @throws IOException
+     */
+    public static long parseLongValue(final String value) throws IOException {
+        return parseLongValue(value, 10);
+    }
+
+    /**
+     * Tries to parse the provided string value to a Long

Review Comment:
   I would rephrase these comments from "Tries..." to "Parses the given Foo 
into a Bar". All method "try" to do something ;-) In general, for these types 
of methods, I use the same verb to start the comment as the method name. This 
feels consistent and drives to the reader what is the main point of the method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to