[GitHub] [commons-imaging] Glavo commented on a diff in pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


Glavo commented on code in PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#discussion_r1339491986


##
src/main/java/org/apache/commons/imaging/formats/webp/chunks/WebPChunk.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.imaging.formats.webp.chunks;
+
+import org.apache.commons.imaging.ImagingException;
+import org.apache.commons.imaging.common.BinaryFileParser;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * A WebP image is composed of several chunks. This is the base class for the 
chunks,
+ * used by the parser.
+ *
+ * @see https://developers.google.com/speed/webp/docs/riff_container;>WebP 
Container Specification

Review Comment:
   None of the parsers for the other formats have javadoc, so I'm confused as 
to where to put the documentation.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-imaging] gwlucastrig commented on pull request #318: [IMAGING-316] Add support for BigTIFF format

2023-09-27 Thread via GitHub


gwlucastrig commented on PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#issuecomment-1738274426

   Added Javadoc and corrected formatting.  In order to support an additional 
JUnit test, I needed to add a new toBytes() method for longs.  This method 
wasn't required for reading BigTIFFs, but it was necessary to implement the 
JUnit test.  It will be useful in the future for any implementation that writes 
BigTIFFs (the current implementation only reads them).



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-imaging] kinow commented on pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


kinow commented on PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#issuecomment-1738133122

   > We don't need to use since tags IMO since we don't have a 1.0 yet.
   
   I think there are other since tags (can't recall if only for 1.0-alphaX or 
for 0.98 (sanselan) as well)


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-imaging] garydgregory commented on pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


garydgregory commented on PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#issuecomment-1738088877

   We don't need to use since tags IMO since we don't have a 1.0 yet.


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-collections] aherbert commented on a diff in pull request #402: COLLECTIONS-843: Implement Layered Bloom filter

2023-09-27 Thread via GitHub


aherbert commented on code in PR #402:
URL: 
https://github.com/apache/commons-collections/pull/402#discussion_r1339164850


##
src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilterProducer.java:
##
@@ -38,54 +40,102 @@ public interface BloomFilterProducer {
 boolean forEachBloomFilter(Predicate bloomFilterPredicate);
 
 /**
- * Return a deep copy of the BloomFilterProducer data as a Bloom filter 
array.
- * 
- * The default implementation of this method is slow. It is recommended 
that
- * implementing classes reimplement this method.
- * 
+ * Return an array of the Bloom filters in the collection.
+ * Implementations should specify if the array contains deep 
copies, immutable instances,
+ * or references to the filters in the collection.
  *
  * @return An array of Bloom filters.
  */
 default BloomFilter[] asBloomFilterArray() {
-class Filters {
-private BloomFilter[] data = new BloomFilter[16];
-private int size;
-
-boolean add(final BloomFilter filter) {
-if (size == data.length) {
-// This will throw an out-of-memory error if there are too 
many Bloom filters.
-data = Arrays.copyOf(data, size * 2);
-}
-data[size++] = filter.copy();
-return true;
-}
-
-BloomFilter[] toArray() {
-// Edge case to avoid a large array copy
-return size == data.length ? data : Arrays.copyOf(data, size);
-}
-}
-final Filters filters = new Filters();
-forEachBloomFilter(filters::add);
-return filters.toArray();
+final List filters = new ArrayList<>();
+forEachBloomFilter(f -> filters.add(f.copy()));
+return filters.toArray(new BloomFilter[filters.size()]);
 }
 
 /**
  * Applies the {@code func} to each Bloom filter pair in order. Will apply 
all
  * of the Bloom filters from the other BloomFilterProducer to this 
producer. If
- * this producer does not have as many BloomFilters it will provide
- * {@code null} for all excess calls to the BiPredicate.
+ * either {@code this} producer or {@code other} producer has fewer 
BloomFilters
+ * ths method will provide {@code null} for all excess calls to the {@code 
func}.
+ *
+ * This implementation returns references to the Bloom filter.  
Other implementations
+ * should specify if the array contains deep copies, immutable instances,
+ * or references to the filters in the collection.
  *
  * @param other The other BloomFilterProducer that provides the y values 
in the
  *  (x,y) pair.
  * @param func  The function to apply.
- * @return A LongPredicate that tests this BitMapProducers bitmap values in
- * order.
+ * @return {@code true} if the {@code func} returned {@code true} for 
every pair,
+ * {@code false} otherwise.
  */
 default boolean forEachBloomFilterPair(final BloomFilterProducer other,
 final BiPredicate func) {
 final CountingPredicate p = new 
CountingPredicate<>(asBloomFilterArray(), func);
 return other.forEachBloomFilter(p) && p.forEachRemaining();
 }
 
+/**
+ * Create a standard (non-layered) Bloom filter by merging all of the 
layers. If
+ * the filter is empty this method will return an empty Bloom filter.
+ *
+ * @return the merged bloom filter.
+ */
+default BloomFilter flatten() {
+BloomFilter bf[] = {null};
+forEachBloomFilter( x -> {
+if (bf[0]==null) {

Review Comment:
   whitespace:
   ```java
   forEachBloomFilter(x -> {
   if (bf[0] == null) {
   bf[0] = new SimpleBloomFilter(x.getShape());
   }
   return bf[0].merge(x);
   ```
   



##
src/main/java/org/apache/commons/collections4/bloomfilter/BloomFilterProducer.java:
##
@@ -38,54 +40,102 @@ public interface BloomFilterProducer {
 boolean forEachBloomFilter(Predicate bloomFilterPredicate);
 
 /**
- * Return a deep copy of the BloomFilterProducer data as a Bloom filter 
array.
- * 
- * The default implementation of this method is slow. It is recommended 
that
- * implementing classes reimplement this method.
- * 
+ * Return an array of the Bloom filters in the collection.
+ * Implementations should specify if the array contains deep 
copies, immutable instances,
+ * or references to the filters in the collection.
  *
  * @return An array of Bloom filters.
  */
 default BloomFilter[] asBloomFilterArray() {
-class Filters {
-private BloomFilter[] data = new BloomFilter[16];
-private int size;
-
-boolean add(final BloomFilter filter) {
-if (size == data.length) {
-// This will 

[GitHub] [commons-imaging] kinow commented on a diff in pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


kinow commented on code in PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#discussion_r1339171634


##
src/main/java/org/apache/commons/imaging/formats/webp/chunks/WebPChunk.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.imaging.formats.webp.chunks;
+
+import org.apache.commons.imaging.ImagingException;
+import org.apache.commons.imaging.common.BinaryFileParser;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.ByteOrder;
+import java.nio.charset.StandardCharsets;
+
+/**
+ * A WebP image is composed of several chunks. This is the base class for the 
chunks,
+ * used by the parser.
+ *
+ * @see https://developers.google.com/speed/webp/docs/riff_container;>WebP 
Container Specification

Review Comment:
   Maybe this should be documented in the parser as well.



##
src/main/java/org/apache/commons/imaging/formats/webp/WebPImageParser.java:
##
@@ -0,0 +1,326 @@
+/*
+ * 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.imaging.formats.webp;
+
+import org.apache.commons.imaging.AbstractImageParser;
+import org.apache.commons.imaging.ImageFormat;
+import org.apache.commons.imaging.ImageFormats;
+import org.apache.commons.imaging.ImageInfo;
+import org.apache.commons.imaging.ImagingException;
+import org.apache.commons.imaging.bytesource.ByteSource;
+import org.apache.commons.imaging.common.XmpEmbeddable;
+import org.apache.commons.imaging.common.XmpImagingParameters;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.TiffImageParser;
+import org.apache.commons.imaging.formats.webp.chunks.WebPChunk;
+import org.apache.commons.imaging.formats.webp.chunks.WebPChunkVP8;
+import org.apache.commons.imaging.formats.webp.chunks.WebPChunkVP8L;
+import org.apache.commons.imaging.formats.webp.chunks.WebPChunkVP8X;
+import org.apache.commons.imaging.formats.webp.chunks.WebPChunkXMP;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.nio.ByteOrder;
+import java.util.ArrayList;
+
+import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
+import static org.apache.commons.imaging.common.BinaryFunctions.readBytes;
+import static org.apache.commons.imaging.common.BinaryFunctions.skipBytes;
+
+/**
+ * @since 1.0-alpha4

Review Comment:
   Maybe the description here could be improved, perhaps including a link to 
where this implementation came from (spec, docs, another library, etc.)



##
src/main/java/org/apache/commons/imaging/formats/webp/WebPImageMetadata.java:
##
@@ -0,0 +1,53 @@
+/*
+ * 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 

[GitHub] [commons-imaging] kinow commented on pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


kinow commented on PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#issuecomment-1737998055

   Thank you @Glavo ! Hopefully we can solve simple issues and we won't need 
any major refactoring for the review :crossed_fingers: Coming back to this one 
soon... (allowed GH Actions to run)


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-imaging] Glavo commented on pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


Glavo commented on PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#issuecomment-1737971692

   I've rebased and resolved conflicts.
   
   I noticed that the project had changed a lot in my time away, so I simply 
updated this PR so that it would compile and pass tests. If there is anything 
else to update, it will take me some time to get back to this work.


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-imaging] kinow commented on pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


kinow commented on PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#issuecomment-1737924058

   > Considering the libwebp CVE the industry is currently dealing with, would 
love to see this PR's conflicts resolved and this merged in sooner than later 
so I can move away from using a library that relies on JNI. 
   
   @Glavo can you rebase and fix conflicts, please? I returned from my overseas 
trip last Friday. Just going through the backlog ($work/emails/etc.), but I 
should be able to review this pretty soon. Or if you are busy (and you trust 
us) just say so and we can try to fix the conflicts and review it. Thanks!


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Commented] (IMAGING-362) TIFF tags 0x111 and 0x117 have wrong descriptive names

2023-09-27 Thread Gary Lucas (Jira)


[ 
https://issues.apache.org/jira/browse/IMAGING-362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769687#comment-17769687
 ] 

Gary Lucas commented on IMAGING-362:


Hi Gary,

Thanks for taking care of this (and the others you just addressed).

Gary (the other Gary)

> TIFF tags 0x111 and 0x117 have wrong descriptive names
> --
>
> Key: IMAGING-362
> URL: https://issues.apache.org/jira/browse/IMAGING-362
> Project: Commons Imaging
>  Issue Type: Bug
>  Components: Format: TIFF
>Affects Versions: 1.0-alpha2
>Reporter: Gary Lucas
>Priority: Minor
> Fix For: 1.0
>
>
> The TIFF standard defines metadata elements using integer code values. For 
> code values 0x111 and 0x117, Commons Imaging associates these with incorrect 
> names "PreviewImageStart" and "PreviewImageLength".  According to the 
> specification "TIFF Revision 6.0 Final – June 3, 1992", the correct names for 
> these are "StripOffsets" and "StripByteCounts".   In fact, the word "preview" 
> never even shows up in the TIFF specification. 
> This should be an easy fix.  No new test cases will be required, since these 
> are descriptive elements only.
> The role of these two elements is to define the file position and length of 
> data elements for TIFF files that are encoded as strips.
> One of the example programs in the Commons Imaging distribution (which is not 
> compiled) is called ReadTagsAndImages.java.  It can be used to dump TIFF tags.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-imaging] spencerhakim commented on pull request #254: [IMAGING-339] Basic WebP Support

2023-09-27 Thread via GitHub


spencerhakim commented on PR #254:
URL: https://github.com/apache/commons-imaging/pull/254#issuecomment-1737605199

   Considering the libwebp CVE the industry is currently dealing with, would 
love to see this PR's conflicts resolved and this merged in sooner than later 
so I can move away from using a library that relies on JNI.  


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338772361


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {

Review Comment:
   This equals builder is typed. We provide a type and then the field functions 
to build the equals method.
   So the Type is a Java Class.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Updated] (IMAGING-344) NPE in PcxWriter for PCX without color palette (24-bit)

2023-09-27 Thread Gary D. Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-344?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated IMAGING-344:

Fix Version/s: 1.0
   (was: 1.0-alpha3)

> NPE in PcxWriter for PCX without color palette (24-bit)
> ---
>
> Key: IMAGING-344
> URL: https://issues.apache.org/jira/browse/IMAGING-344
> Project: Commons Imaging
>  Issue Type: Bug
>  Components: Format: PCX
>Affects Versions: 1.0-alpha2
>Reporter: Bruno P. Kinoshita
>Priority: Major
> Fix For: 1.0
>
>
> From: 
> [https://github.com/apache/commons-imaging/pull/273#pullrequestreview-1264740338]
> A 24-bit PCX image has 8 bit per pixel and no color palette. The code is 
> handling the parsing, but when you try to write it (as the roundtrip test 
> does) it fails due to an access to the palette object in the PcxWriter (even 
> though the palette is null/non-existent).
> Fix is really simple. But we must have a test case to prevent regressions.
> When fixing this one, we must also update the header of the Pcx classes to 
> state the specification and version used, related to IMAGING-341



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IMAGING-358) "RationalNumber" class is "public"

2023-09-27 Thread Gary D. Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated IMAGING-358:

Fix Version/s: (was: 1.0-alpha3)

> "RationalNumber" class is "public"
> --
>
> Key: IMAGING-358
> URL: https://issues.apache.org/jira/browse/IMAGING-358
> Project: Commons Imaging
>  Issue Type: Wish
>  Components: imaging.common.*
>Affects Versions: 1.0-alpha2
>Reporter: Gilles Sadowski
>Priority: Major
>  Labels: API, support
> Fix For: 1.0
>
>
> As per its Javadoc, class 
> [{{RationalNumber}}|https://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/common/RationalNumber.html]
>  is tuned to the requirements of the TIFF format while its name purports that 
> it's a general implementation of the "fraction" concept.
> Which is it?
> Do we want that utility to be part of [Imaging]'s public API (thus eliciting 
> support to application developers who might use it beyond its intended scope)?
> A dependency on [[Numbers]'s "fraction" 
> module|https://commons.apache.org/proper/commons-numbers/commons-numbers-docs/apidocs/org/apache/commons/numbers/fraction/package-summary.html],
>  as proposed in IMAGING-309) would avoid the issue, and also consolidate 
> (and/or help find potential bugs in) [Numbers]'s implementation.
> If that proposal is not accepted, {{RationalNumber}} should preferably be 
> moved to [Imaging]'s [{{internal}} 
> package|https://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/internal/package-summary.html].



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IMAGING-339) Basic WebP support

2023-09-27 Thread Gary D. Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-339?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated IMAGING-339:

Fix Version/s: 1.0
   (was: 1.0-alpha3)

> Basic WebP support
> --
>
> Key: IMAGING-339
> URL: https://issues.apache.org/jira/browse/IMAGING-339
> Project: Commons Imaging
>  Issue Type: Improvement
>  Components: Format: WebP
>Affects Versions: 1.0-alpha2
>Reporter: Bruno P. Kinoshita
>Assignee: Bruno P. Kinoshita
>Priority: Minor
> Fix For: 1.0
>
>  Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Placeholder for https://github.com/apache/commons-imaging/pull/254



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IMAGING-363) commons-imaging-1.0-alpha3.jar complains that certain smartfone videos have not supported file format

2023-09-27 Thread Gary D. Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-363?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated IMAGING-363:

Fix Version/s: 1.0
   (was: 1.0-alpha3)

> commons-imaging-1.0-alpha3.jar complains that certain smartfone videos have 
> not supported file format
> -
>
> Key: IMAGING-363
> URL: https://issues.apache.org/jira/browse/IMAGING-363
> Project: Commons Imaging
>  Issue Type: Bug
>  Components: Build
>Affects Versions: 1.0-alpha3
> Environment: Windows 11
>Reporter: Manfred Haiduk
>Priority: Major
> Fix For: 1.0
>
>
> Using a program called jAlbum to create WebAlbums, i have discovered that one 
> part of this program, namely the lib commons-imaging-1.0-alpha3.jar, 
> complains about file format is not supported to read at least the metadata 
> from the video and extract i.e  userdata part of the embedded metadata from 
> the video containing gps coordinates. Reverting to the versions 
> commons-imaging-1.0-alpha1.jar and even to commons-imaging-1.0-alpha2.jar 
> there is no issue about this so i guess updating from version 2 to version3 
> there must be a bug inside the lib.
> As i am only an end user of the jAlbum program i cannot give more details to 
> that failure



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IMAGING-362) TIFF tags 0x111 and 0x117 have wrong descriptive names

2023-09-27 Thread Gary D. Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-362?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory updated IMAGING-362:

Fix Version/s: 1.0
   (was: 1.0-alpha3)

> TIFF tags 0x111 and 0x117 have wrong descriptive names
> --
>
> Key: IMAGING-362
> URL: https://issues.apache.org/jira/browse/IMAGING-362
> Project: Commons Imaging
>  Issue Type: Bug
>  Components: Format: TIFF
>Affects Versions: 1.0-alpha2
>Reporter: Gary Lucas
>Priority: Minor
> Fix For: 1.0
>
>
> The TIFF standard defines metadata elements using integer code values. For 
> code values 0x111 and 0x117, Commons Imaging associates these with incorrect 
> names "PreviewImageStart" and "PreviewImageLength".  According to the 
> specification "TIFF Revision 6.0 Final – June 3, 1992", the correct names for 
> these are "StripOffsets" and "StripByteCounts".   In fact, the word "preview" 
> never even shows up in the TIFF specification. 
> This should be an easy fix.  No new test cases will be required, since these 
> are descriptive elements only.
> The role of these two elements is to define the file position and length of 
> data elements for TIFF files that are encoded as strips.
> One of the example programs in the Commons Imaging distribution (which is not 
> compiled) is called ReadTagsAndImages.java.  It can be used to dump TIFF tags.
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Resolved] (IMAGING-360) Missing some TIFF compression information in ImageInfo

2023-09-27 Thread Gary D. Gregory (Jira)


 [ 
https://issues.apache.org/jira/browse/IMAGING-360?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gary D. Gregory resolved IMAGING-360.
-
Fix Version/s: 1.0
   Resolution: Fixed

> Missing some TIFF compression information in ImageInfo
> --
>
> Key: IMAGING-360
> URL: https://issues.apache.org/jira/browse/IMAGING-360
> Project: Commons Imaging
>  Issue Type: Bug
>Reporter: Gary Lucas
>Priority: Major
> Fix For: 1.0
>
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-imaging] garydgregory merged pull request #311: Issue-360: Add more TIFF compression entries to ImageInfo

2023-09-27 Thread via GitHub


garydgregory merged PR #311:
URL: https://github.com/apache/commons-imaging/pull/311


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-imaging] garydgregory commented on a diff in pull request #318: Imaging-316: Add support for BigTIFF format

2023-09-27 Thread via GitHub


garydgregory commented on code in PR #318:
URL: https://github.com/apache/commons-imaging/pull/318#discussion_r1338737448


##
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##
@@ -234,6 +234,14 @@ public int[] getIntArrayValue() throws ImagingException {
 final int[] numbers = (int[]) o;
 return Arrays.copyOf(numbers, numbers.length);
 }
+if (o instanceof long[]){

Review Comment:
   The formatting seems off in the block, missing spaces.



##
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException 
{
 // return -1;
 }
 
+public long[] getLongArrayValue() throws ImagingException {

Review Comment:
   We should provide Javadocs on all new public and protected methods IMO.



##
src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java:
##
@@ -455,27 +473,47 @@ private TiffHeader readTiffHeader(final ByteSource 
byteSource) throws ImagingExc
 }
 }
 
-private TiffHeader readTiffHeader(final InputStream is) throws 
ImagingException, IOException {
-final int byteOrder1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF 
File");
-final int byteOrder2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF 
File");
-if (byteOrder1 != byteOrder2) {
-throw new ImagingException("Byte Order bytes don't match (" + 
byteOrder1 + ", " + byteOrder2 + ").");
-}
-
-final ByteOrder byteOrder = getTiffByteOrder(byteOrder1);
-setByteOrder(byteOrder);
-
-final int tiffVersion = read2Bytes("tiffVersion", is, "Not a Valid 
TIFF File", getByteOrder());
-if (tiffVersion != 42) {
-throw new ImagingException("Unknown TIFF Version: " + tiffVersion);
-}
+   private TiffHeader readTiffHeader(final InputStream is) throws 
ImagingException, IOException {

Review Comment:
   Formatting seems odd.



##
src/main/java/org/apache/commons/imaging/common/ByteConversions.java:
##
@@ -399,6 +399,43 @@ private static int[] toUInt16s(final byte[] bytes, final 
int offset, final int l
 return result;
 }
 
+ public static long toLong(final byte[] bytes, final ByteOrder byteOrder) {

Review Comment:
   Also, it looks like there is an extra space in front of `public`?



##
src/main/java/org/apache/commons/imaging/common/ByteConversions.java:
##
@@ -399,6 +399,43 @@ private static int[] toUInt16s(final byte[] bytes, final 
int offset, final int l
 return result;
 }
 
+ public static long toLong(final byte[] bytes, final ByteOrder byteOrder) {

Review Comment:
   We should provide Javadocs on all new public and protected methods IMO.



##
src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java:
##
@@ -288,6 +296,55 @@ public int getIntValueOrArraySum() throws ImagingException 
{
 // return -1;
 }
 
+public long[] getLongArrayValue() throws ImagingException {
+final Object o = getValue();
+// if (o == null)
+// return null;
+
+if (o instanceof Number) {
+return new  long[] { ((Number) o).longValue() };
+}
+if (o instanceof Number[]) {
+final Number[] numbers = (Number[]) o;
+final long[] result = Allocator.longArray(numbers.length);
+Arrays.setAll(result, i -> numbers[i].longValue());
+return result;
+}
+if (o instanceof short[]) {
+final short[] numbers = (short[]) o;
+final long[] result = Allocator.longArray(numbers.length);
+Arrays.setAll(result, i ->  0x & numbers[i]);
+return result;
+}
+if (o instanceof int[]) {
+final int[] numbers = (int[]) o;
+final long[]result = Allocator.longArray(numbers.length);
+Arrays.setAll(result, i ->  0xL & numbers[i]);
+return result;
+}
+if (o instanceof long[]){
+  final long[] numbers = (long[]) o;
+  return Arrays.copyOf(numbers, numbers.length);
+}
+
+throw new ImagingException("Unknown value: " + o + " for: "
++ getTagInfo().getDescription());
+// return null;
+}
+
+public long getLongValue() throws ImagingException {

Review Comment:
   We should provide Javadocs on all new public and protected methods IMO.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Comment Edited] (IO-809) MessageDigestCalculatingInputStream Builder Not Working

2023-09-27 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/IO-809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769657#comment-17769657
 ] 

Gary D. Gregory edited comment on IO-809 at 9/27/23 2:46 PM:
-

{quote}As the current signature returns void, there shouldn't be any 
assignments to variables out there. So it wouldn't be a breaking change, or am 
I overlooking something?
{quote}
Yes, you are overlooking binary compatibility. Breaking BC can cause the 
infamous "jar hell".


was (Author: garydgregory):
bq. As the current signature returns void, there shouldn't be any assignments 
to variables out there. So it wouldn't be a breaking change, or am I 
overlooking something?

Yes, you are overlooking binary compatibility.


> MessageDigestCalculatingInputStream Builder Not Working
> ---
>
> Key: IO-809
> URL: https://issues.apache.org/jira/browse/IO-809
> Project: Commons IO
>  Issue Type: Bug
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Jeremias Eppler
>Priority: Major
> Fix For: 3.x
>
> Attachments: commons-io-issue.png
>
>
> I am currently trying to use the MessageDigestCalculatingInputStream Builder. 
> However, the setters of the builder do not return the builder.
> Meaning, this code does not work:
>  
> ~~~java
> MessageDigestCalculatingInputStream messageDigestInputStream = 
> MessageDigestCalculatingInputStream.builder()
>     .setInputStream(fileInputstream)
>     .setMessageDigest(digest)
>     .get();
> ~~~



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (IO-809) MessageDigestCalculatingInputStream Builder Not Working

2023-09-27 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/IO-809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769657#comment-17769657
 ] 

Gary D. Gregory commented on IO-809:


bq. As the current signature returns void, there shouldn't be any assignments 
to variables out there. So it wouldn't be a breaking change, or am I 
overlooking something?

Yes, you are overlooking binary compatibility.


> MessageDigestCalculatingInputStream Builder Not Working
> ---
>
> Key: IO-809
> URL: https://issues.apache.org/jira/browse/IO-809
> Project: Commons IO
>  Issue Type: Bug
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Jeremias Eppler
>Priority: Major
> Fix For: 3.x
>
> Attachments: commons-io-issue.png
>
>
> I am currently trying to use the MessageDigestCalculatingInputStream Builder. 
> However, the setters of the builder do not return the builder.
> Meaning, this code does not work:
>  
> ~~~java
> MessageDigestCalculatingInputStream messageDigestInputStream = 
> MessageDigestCalculatingInputStream.builder()
>     .setInputStream(fileInputstream)
>     .setMessageDigest(digest)
>     .get();
> ~~~



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338516200


##
src/test/java/org/apache/commons/lang3/builder/TypedEqualsBuilderTest.java:
##
@@ -0,0 +1,89 @@
+/*
+ * 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.lang3.builder;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TypedEqualsBuilderTest {
+
+@Test
+void test_complete_equals() {
+TestObject testObject1 = new TestObject(1, 2);
+TestObject testObject2 = new TestObject(1, 3);
+TestObject testObject3 = new TestObject(1, 2);
+
+assertEquals(testObject1, testObject1);
+assertNotEquals(testObject1, testObject2);
+assertNotEquals(testObject2, testObject1);
+
+assertEquals(Boolean.TRUE,

Review Comment:
   It was done to make the test slightly more quick to read with the syntax 
coloration.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#issuecomment-1737544105

   I've addressed the comments. This version may tend to something better :) 


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Commented] (IO-810) Wrong JavaDoc regarding FileNotFoundException in FileUtils

2023-09-27 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/IO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769651#comment-17769651
 ] 

Gary D. Gregory commented on IO-810:


I like the idea of documenting the IOException only.

> Wrong JavaDoc regarding FileNotFoundException in FileUtils
> --
>
> Key: IO-810
> URL: https://issues.apache.org/jira/browse/IO-810
> Project: Commons IO
>  Issue Type: Bug
>  Components: Utilities
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Gregor Dschung
>Priority: Major
>
> The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
> {{FileNotFoundException}} is thrown if the file doesn't exist. This isn't 
> true with version 2.12 and above, including the current 2.14 snapshot, where 
> a {{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
> methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
> exception is coming via {{Files#newByteChannel(...)}}.
> Root cause seems to be, like in IO-800, [this 
> commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
>  from 2021, where {{openInputStream(file)}} (which is calling 
> {{new FileInputStream(file)}} from {{java.io}}) is replaced by 
> {{Files.newInputStream(file.toPath())}} from {{java.nio}}. 
> I'm unsure if just the JavaDoc should be updated or the old behavior be 
> restored: I noticed the bug because we catch a {{FileNotFoundException}}, 
> which doesn't work for 2.12 and above.
> {code:title=Old Stacktrace}
> java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
>   at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
>   at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
> ~[na:na]
>   at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
> ~[na:na]
>   at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
> ~[commons-io-2.11.0.jar:2.11.0]
> {code}
> {code:title=New Stacktrace}
> java.nio.file.NoSuchFileException: doesnt-exist.txt
>   at 
> java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
>   at 
> java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
>   at 
> org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616)
>  ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
> ~[commons-io-2.13.0.jar:2.13.0]
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CONFIGURATION-836) Make configuration use jakarte instead of javax

2023-09-27 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/CONFIGURATION-836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769623#comment-17769623
 ] 

Gary D. Gregory commented on CONFIGURATION-836:
---

[~michieldx]
Feel free to provide a PR on GitHub.

Note that we can only break binary compatibility in the next major release line 
(3.x).

> Make configuration use jakarte instead of javax
> ---
>
> Key: CONFIGURATION-836
> URL: https://issues.apache.org/jira/browse/CONFIGURATION-836
> Project: Commons Configuration
>  Issue Type: Improvement
>Reporter: Michiel
>Priority: Major
>
> I'm currently upgrading my Spring Boot application from 2 to 3 and therefor 
> also switching from javax to jakarta. Unfortunately I'm using Hystrix, which 
> relies on Commons Configuration, which does not support jakarta yet.
> This seems like an easy fix and makes me not have to migrate away from 
> Hystrix.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IO-810) Wrong JavaDoc regarding FileNotFoundException in FileUtils

2023-09-27 Thread Gregor Dschung (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gregor Dschung updated IO-810:
--
Summary: Wrong JavaDoc regarding FileNotFoundException in FileUtils  (was: 
Wrong JavaDoc regarding exception in FileUtils)

> Wrong JavaDoc regarding FileNotFoundException in FileUtils
> --
>
> Key: IO-810
> URL: https://issues.apache.org/jira/browse/IO-810
> Project: Commons IO
>  Issue Type: Bug
>  Components: Utilities
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Gregor Dschung
>Priority: Major
>
> The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
> {{FileNotFoundException}} is thrown if the file doesn't exist. This isn't 
> true with version 2.12 and above, including the current 2.14 snapshot, where 
> a {{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
> methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
> exception is coming via {{Files#newByteChannel(...)}}.
> Root cause seems to be, like in IO-800, [this 
> commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
>  from 2021, where {{openInputStream(file)}} (which is calling 
> {{new FileInputStream(file)}} from {{java.io}}) is replaced by 
> {{Files.newInputStream(file.toPath())}} from {{java.nio}}. 
> I'm unsure if just the JavaDoc should be updated or the old behavior be 
> restored: I noticed the bug because we catch a {{FileNotFoundException}}, 
> which doesn't work for 2.12 and above.
> {code:title=Old Stacktrace}
> java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
>   at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
>   at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
> ~[na:na]
>   at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
> ~[na:na]
>   at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
> ~[commons-io-2.11.0.jar:2.11.0]
> {code}
> {code:title=New Stacktrace}
> java.nio.file.NoSuchFileException: doesnt-exist.txt
>   at 
> java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
>   at 
> java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
>   at 
> org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616)
>  ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
> ~[commons-io-2.13.0.jar:2.13.0]
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (IO-809) MessageDigestCalculatingInputStream Builder Not Working

2023-09-27 Thread Gregor Dschung (Jira)


[ 
https://issues.apache.org/jira/browse/IO-809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769604#comment-17769604
 ] 

Gregor Dschung edited comment on IO-809 at 9/27/23 1:30 PM:


As the current signature returns void, there shouldn't be any assignments to 
variables out there. So it wouldn't be a breaking change, or am I overlooking 
something?

UPDATE: Ah, I see, it's a non-final public class, so subclassing would be an 
issue. But seriously: Who would do that in this case? And as the JavaDoc is 
stating that a fluent-api is possible, I think we shouldn't wait for a major 
version to update the current implementation.


was (Author: JIRAUSER302379):
As the current signature returns void, there shouldn't be any assignments to 
variables out there. So it wouldn't be a breaking change, or am I overlooking 
something?

UPDATE: Ah, I see, it's a non-final public class, so subclassing would be an 
issue. But seriously: Who would do that in this case? And as the JavaDoc is 
stating, that a fluent-api is possible, I think we shouldn't wait for a major 
version to update the current implementation.

> MessageDigestCalculatingInputStream Builder Not Working
> ---
>
> Key: IO-809
> URL: https://issues.apache.org/jira/browse/IO-809
> Project: Commons IO
>  Issue Type: Bug
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Jeremias Eppler
>Priority: Major
> Fix For: 3.x
>
> Attachments: commons-io-issue.png
>
>
> I am currently trying to use the MessageDigestCalculatingInputStream Builder. 
> However, the setters of the builder do not return the builder.
> Meaning, this code does not work:
>  
> ~~~java
> MessageDigestCalculatingInputStream messageDigestInputStream = 
> MessageDigestCalculatingInputStream.builder()
>     .setInputStream(fileInputstream)
>     .setMessageDigest(digest)
>     .get();
> ~~~



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (IO-809) MessageDigestCalculatingInputStream Builder Not Working

2023-09-27 Thread Gregor Dschung (Jira)


[ 
https://issues.apache.org/jira/browse/IO-809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769604#comment-17769604
 ] 

Gregor Dschung edited comment on IO-809 at 9/27/23 1:29 PM:


As the current signature returns void, there shouldn't be any assignments to 
variables out there. So it wouldn't be a breaking change, or am I overlooking 
something?

UPDATE: Ah, I see, it's a non-final public class, so subclassing would be an 
issue. But seriously: Who would do that in this case? And as the JavaDoc is 
stating, that a fluent-api is possible, I think we shouldn't wait for a major 
version to update the current implementation.


was (Author: JIRAUSER302379):
As the current signature returns void, there shouldn't be any assignments to 
variables out there. So it wouldn't be a breaking change, or am I overlooking 
something?

> MessageDigestCalculatingInputStream Builder Not Working
> ---
>
> Key: IO-809
> URL: https://issues.apache.org/jira/browse/IO-809
> Project: Commons IO
>  Issue Type: Bug
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Jeremias Eppler
>Priority: Major
> Fix For: 3.x
>
> Attachments: commons-io-issue.png
>
>
> I am currently trying to use the MessageDigestCalculatingInputStream Builder. 
> However, the setters of the builder do not return the builder.
> Meaning, this code does not work:
>  
> ~~~java
> MessageDigestCalculatingInputStream messageDigestInputStream = 
> MessageDigestCalculatingInputStream.builder()
>     .setInputStream(fileInputstream)
>     .setMessageDigest(digest)
>     .get();
> ~~~



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (IO-809) MessageDigestCalculatingInputStream Builder Not Working

2023-09-27 Thread Gregor Dschung (Jira)


[ 
https://issues.apache.org/jira/browse/IO-809?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769604#comment-17769604
 ] 

Gregor Dschung commented on IO-809:
---

As the current signature returns void, there shouldn't be any assignments to 
variables out there. So it wouldn't be a breaking change, or am I overlooking 
something?

> MessageDigestCalculatingInputStream Builder Not Working
> ---
>
> Key: IO-809
> URL: https://issues.apache.org/jira/browse/IO-809
> Project: Commons IO
>  Issue Type: Bug
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Jeremias Eppler
>Priority: Major
> Fix For: 3.x
>
> Attachments: commons-io-issue.png
>
>
> I am currently trying to use the MessageDigestCalculatingInputStream Builder. 
> However, the setters of the builder do not return the builder.
> Meaning, this code does not work:
>  
> ~~~java
> MessageDigestCalculatingInputStream messageDigestInputStream = 
> MessageDigestCalculatingInputStream.builder()
>     .setInputStream(fileInputstream)
>     .setMessageDigest(digest)
>     .get();
> ~~~



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Comment Edited] (IO-810) Wrong JavaDoc regarding exception in FileUtils

2023-09-27 Thread Gregor Dschung (Jira)


[ 
https://issues.apache.org/jira/browse/IO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769596#comment-17769596
 ] 

Gregor Dschung edited comment on IO-810 at 9/27/23 1:12 PM:


Okay, I'll do so. I see two options:
# As {{NoSuchFileException}} is an {{IOException}}, the simplest and most 
future-proof way would be to just remove {{FileNotFoundException}} from the 
JavaDoc and instead to change the description of {{IOException}} to something 
like {{@throws IOException if an I/O error occurs, including when the file does 
not exist, is a directory rather than a regular file, or for some other reason 
cannot be opened for reading.}}.
# Or do you prefer to keep the exception for the file-doesn't-exist-case 
explicit?


was (Author: JIRAUSER302379):
Okay, I'll do so. I see two options:
# As {{NoSuchFileException}} is an {{IOException}}, the simplest and most 
future-proof way would be to just remove {{FileNotFoundException}} from the 
JavaDoc and instead to change the description of {{NoSuchFileException}} to 
something like {{@throws IOException if an I/O error occurs, including when the 
file does not exist, is a directory rather than a regular file, or for some 
other reason cannot be opened for reading.}}.
# Or do you prefer to keep the exception for the file-doesn't-exist-case 
explicit?

> Wrong JavaDoc regarding exception in FileUtils
> --
>
> Key: IO-810
> URL: https://issues.apache.org/jira/browse/IO-810
> Project: Commons IO
>  Issue Type: Bug
>  Components: Utilities
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Gregor Dschung
>Priority: Major
>
> The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
> {{FileNotFoundException}} is thrown if the file doesn't exist. This isn't 
> true with version 2.12 and above, including the current 2.14 snapshot, where 
> a {{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
> methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
> exception is coming via {{Files#newByteChannel(...)}}.
> Root cause seems to be, like in IO-800, [this 
> commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
>  from 2021, where {{openInputStream(file)}} (which is calling 
> {{new FileInputStream(file)}} from {{java.io}}) is replaced by 
> {{Files.newInputStream(file.toPath())}} from {{java.nio}}. 
> I'm unsure if just the JavaDoc should be updated or the old behavior be 
> restored: I noticed the bug because we catch a {{FileNotFoundException}}, 
> which doesn't work for 2.12 and above.
> {code:title=Old Stacktrace}
> java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
>   at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
>   at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
> ~[na:na]
>   at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
> ~[na:na]
>   at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
> ~[commons-io-2.11.0.jar:2.11.0]
> {code}
> {code:title=New Stacktrace}
> java.nio.file.NoSuchFileException: doesnt-exist.txt
>   at 
> java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
>   at 
> java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
>   at 
> org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616)
>  ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
> 

[jira] [Commented] (IO-810) Wrong JavaDoc regarding exception in FileUtils

2023-09-27 Thread Gregor Dschung (Jira)


[ 
https://issues.apache.org/jira/browse/IO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769596#comment-17769596
 ] 

Gregor Dschung commented on IO-810:
---

Okay, I'll do so. I see two options:
# As {{NoSuchFileException}} is an {{IOException}}, the simplest and most 
future-proof way would be to just remove {{FileNotFoundException}} from the 
JavaDoc and instead to change the description of {{NoSuchFileException}} to 
something like {{@throws IOException if an I/O error occurs, including when the 
file does not exist, is a directory rather than a regular file, or for some 
other reason cannot be opened for reading.}}.
# Or do you prefer to keep the exception for the file-doesn't-exist-case 
explicit?

> Wrong JavaDoc regarding exception in FileUtils
> --
>
> Key: IO-810
> URL: https://issues.apache.org/jira/browse/IO-810
> Project: Commons IO
>  Issue Type: Bug
>  Components: Utilities
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Gregor Dschung
>Priority: Major
>
> The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
> {{FileNotFoundException}} is thrown if the file doesn't exist. This isn't 
> true with version 2.12 and above, including the current 2.14 snapshot, where 
> a {{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
> methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
> exception is coming via {{Files#newByteChannel(...)}}.
> Root cause seems to be, like in IO-800, [this 
> commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
>  from 2021, where {{openInputStream(file)}} (which is calling 
> {{new FileInputStream(file)}} from {{java.io}}) is replaced by 
> {{Files.newInputStream(file.toPath())}} from {{java.nio}}. 
> I'm unsure if just the JavaDoc should be updated or the old behavior be 
> restored: I noticed the bug because we catch a {{FileNotFoundException}}, 
> which doesn't work for 2.12 and above.
> {code:title=Old Stacktrace}
> java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
>   at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
>   at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
> ~[na:na]
>   at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
> ~[na:na]
>   at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
> ~[commons-io-2.11.0.jar:2.11.0]
> {code}
> {code:title=New Stacktrace}
> java.nio.file.NoSuchFileException: doesnt-exist.txt
>   at 
> java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
>   at 
> java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
>   at 
> org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616)
>  ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
> ~[commons-io-2.13.0.jar:2.13.0]
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338582697


##
src/test/java/org/apache/commons/lang3/builder/TypedEqualsBuilderTest.java:
##
@@ -0,0 +1,89 @@
+/*
+ * 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.lang3.builder;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TypedEqualsBuilderTest {
+
+@Test
+void test_complete_equals() {
+TestObject testObject1 = new TestObject(1, 2);
+TestObject testObject2 = new TestObject(1, 3);
+TestObject testObject3 = new TestObject(1, 2);
+
+assertEquals(testObject1, testObject1);
+assertNotEquals(testObject1, testObject2);
+assertNotEquals(testObject2, testObject1);
+
+assertEquals(Boolean.TRUE,

Review Comment:
   GitHub has also syntax coloration. But yes let's change these asserts.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338531019


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {

Review Comment:
   Yes it is a java Class. But maybe I should rename it differently or extend 
the EqualsBuilder and add some special appending I will try that...



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] elharo commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


elharo commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338576635


##
src/test/java/org/apache/commons/lang3/builder/TypedEqualsBuilderTest.java:
##
@@ -0,0 +1,89 @@
+/*
+ * 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.lang3.builder;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TypedEqualsBuilderTest {
+
+@Test
+void test_complete_equals() {
+TestObject testObject1 = new TestObject(1, 2);
+TestObject testObject2 = new TestObject(1, 3);
+TestObject testObject3 = new TestObject(1, 2);
+
+assertEquals(testObject1, testObject1);
+assertNotEquals(testObject1, testObject2);
+assertNotEquals(testObject2, testObject1);
+
+assertEquals(Boolean.TRUE,

Review Comment:
   In general, do not assume devs are using IDEs. E.g. right now I'm reading 
this code in Github, and it's less clear than assertTrue



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338563661


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {
+
+private final T currentInstance;
+
+private boolean sameReference = false;
+private T other;
+
+@SuppressWarnings("unchecked")
+public TypedEqualsBuilder(T currentInstance, Object other) {
+Objects.requireNonNull(currentInstance);
+this.currentInstance = currentInstance;
+if (currentInstance == other) {
+sameReference = true;
+return;
+}
+Class currentInstanceClass = (Class) currentInstance.getClass();
+if (other == null || currentInstanceClass != other.getClass()) {
+isEquals = false;
+return;
+}
+this.other = (T) other;
+}
+
+@Override
+boolean shouldLeaveEarly() {
+return sameReference || super.shouldLeaveEarly();
+}
+
+public TypedEqualsBuilder append(Function extractor) {

Review Comment:
   If the function throws a checked exception it can use `FailableFunction`, 
yes. I'll catch the Exception class (Throwable are meant to not be caught)



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338546647


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {
+
+private final T currentInstance;
+
+private boolean sameReference = false;
+private T other;
+
+@SuppressWarnings("unchecked")
+public TypedEqualsBuilder(T currentInstance, Object other) {
+Objects.requireNonNull(currentInstance);
+this.currentInstance = currentInstance;
+if (currentInstance == other) {
+sameReference = true;
+return;
+}
+Class currentInstanceClass = (Class) currentInstance.getClass();
+if (other == null || currentInstanceClass != other.getClass()) {
+isEquals = false;
+return;
+}
+this.other = (T) other;
+}
+
+@Override
+boolean shouldLeaveEarly() {
+return sameReference || super.shouldLeaveEarly();
+}
+
+public TypedEqualsBuilder append(Function extractor) {

Review Comment:
   It's better not to use the FailableFunction as it changes the signature of 
the method, hence forces you to surround with try/catch the build in your 
equals method.
   
![image](https://github.com/apache/commons-lang/assets/2562315/d0846d67-3a5b-433f-bfde-d8b4a17362f7)
   



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338546647


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {
+
+private final T currentInstance;
+
+private boolean sameReference = false;
+private T other;
+
+@SuppressWarnings("unchecked")
+public TypedEqualsBuilder(T currentInstance, Object other) {
+Objects.requireNonNull(currentInstance);
+this.currentInstance = currentInstance;
+if (currentInstance == other) {
+sameReference = true;
+return;
+}
+Class currentInstanceClass = (Class) currentInstance.getClass();
+if (other == null || currentInstanceClass != other.getClass()) {
+isEquals = false;
+return;
+}
+this.other = (T) other;
+}
+
+@Override
+boolean shouldLeaveEarly() {
+return sameReference || super.shouldLeaveEarly();
+}
+
+public TypedEqualsBuilder append(Function extractor) {

Review Comment:
   It's better not to use the FailableFunction as it changes the signature of 
the method, hence forces you to surround with try/catch the build in your 
equals method.
   
![image](https://github.com/apache/commons-lang/assets/2562315/d0846d67-3a5b-433f-bfde-d8b4a17362f7)
   



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338531019


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {

Review Comment:
   Yes it is a java Class. But maybe I should rename it differently or extend 
the EqualsBuilder and add some special appending I will try that...



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] Cousnouf commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


Cousnouf commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338516200


##
src/test/java/org/apache/commons/lang3/builder/TypedEqualsBuilderTest.java:
##
@@ -0,0 +1,89 @@
+/*
+ * 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.lang3.builder;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TypedEqualsBuilderTest {
+
+@Test
+void test_complete_equals() {
+TestObject testObject1 = new TestObject(1, 2);
+TestObject testObject2 = new TestObject(1, 3);
+TestObject testObject3 = new TestObject(1, 2);
+
+assertEquals(testObject1, testObject1);
+assertNotEquals(testObject1, testObject2);
+assertNotEquals(testObject2, testObject1);
+
+assertEquals(Boolean.TRUE,

Review Comment:
   It was done to make the test slightly more quick to read with of the syntax 
coloration.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] ecki commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


ecki commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338513972


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {

Review Comment:
   It is the class type. its refering to the T class parameter which is 
supported by this Builder subtype.



-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-collections] garydgregory commented on pull request #392: Remove duplicate condition in FixedOrderComparator equals()

2023-09-27 Thread via GitHub


garydgregory commented on PR #392:
URL: 
https://github.com/apache/commons-collections/pull/392#issuecomment-1737270338

   Hello @saurabh-rahate 
   Thank you for your PR. Would you please resolve conflicts and rebase on 
master?


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Commented] (IO-810) Wrong JavaDoc regarding exception in FileUtils

2023-09-27 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/IO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769570#comment-17769570
 ] 

Gary D. Gregory commented on IO-810:


In general, it's better to update the Javadoc to match the code. Feel free to 
provide a PR on github.

> Wrong JavaDoc regarding exception in FileUtils
> --
>
> Key: IO-810
> URL: https://issues.apache.org/jira/browse/IO-810
> Project: Commons IO
>  Issue Type: Bug
>  Components: Utilities
>Affects Versions: 2.12.0, 2.13.0
>Reporter: Gregor Dschung
>Priority: Major
>
> The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
> {{FileNotFoundException}} is thrown if the file doesn't exist. This isn't 
> true with version 2.12 and above, including the current 2.14 snapshot, where 
> a {{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
> methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
> exception is coming via {{Files#newByteChannel(...)}}.
> Root cause seems to be, like in IO-800, [this 
> commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
>  from 2021, where {{openInputStream(file)}} (which is calling 
> {{new FileInputStream(file)}} from {{java.io}}) is replaced by 
> {{Files.newInputStream(file.toPath())}} from {{java.nio}}. 
> I'm unsure if just the JavaDoc should be updated or the old behavior be 
> restored: I noticed the bug because we catch a {{FileNotFoundException}}, 
> which doesn't work for 2.12 and above.
> {code:title=Old Stacktrace}
> java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
>   at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
>   at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
> ~[na:na]
>   at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
> ~[na:na]
>   at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
> ~[commons-io-2.11.0.jar:2.11.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
> ~[commons-io-2.11.0.jar:2.11.0]
> {code}
> {code:title=New Stacktrace}
> java.nio.file.NoSuchFileException: doesnt-exist.txt
>   at 
> java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
>  ~[na:na]
>   at 
> java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
>   at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
>   at 
> java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
>  ~[na:na]
>   at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
>   at 
> org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616)
>  ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
> ~[commons-io-2.13.0.jar:2.13.0]
>   at 
> org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
> ~[commons-io-2.13.0.jar:2.13.0]
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-lang] elharo commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


elharo commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338483094


##
src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java:
##
@@ -450,6 +450,15 @@ public static boolean reflectionEquals(final Object lhs, 
final Object rhs, final
 .isEquals();
 }
 
+/**
+ * Indicates if an early append method leave should be done

Review Comment:
   unclear, rephrase



##
src/test/java/org/apache/commons/lang3/builder/TypedEqualsBuilderTest.java:
##
@@ -0,0 +1,89 @@
+/*
+ * 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.lang3.builder;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TypedEqualsBuilderTest {
+
+@Test
+void test_complete_equals() {
+TestObject testObject1 = new TestObject(1, 2);
+TestObject testObject2 = new TestObject(1, 3);
+TestObject testObject3 = new TestObject(1, 2);
+
+assertEquals(testObject1, testObject1);
+assertNotEquals(testObject1, testObject2);
+assertNotEquals(testObject2, testObject1);
+
+assertEquals(Boolean.TRUE,

Review Comment:
   probably use assertTrue and assertFalse, unless perhaps there's some 
auto-boxing detail I'm missing



##
src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java:
##
@@ -198,7 +198,7 @@ private static void unregister(final Object lhs, final 
Object rhs) {
  * If the fields tested are equals.

Review Comment:
   equals --> equal



##
src/test/java/org/apache/commons/lang3/builder/TypedEqualsBuilderTest.java:
##
@@ -0,0 +1,89 @@
+/*
+ * 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.lang3.builder;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class TypedEqualsBuilderTest {
+
+@Test
+void test_complete_equals() {
+TestObject testObject1 = new TestObject(1, 2);
+TestObject testObject2 = new TestObject(1, 3);
+TestObject testObject3 = new TestObject(1, 2);
+
+assertEquals(testObject1, testObject1);
+assertNotEquals(testObject1, testObject2);
+assertNotEquals(testObject2, testObject1);
+
+assertEquals(Boolean.TRUE,
+new TypedEqualsBuilder<>(testObject1, testObject2)
+.append(TestObject::getA)
+.isEquals());
+assertEquals(Boolean.TRUE,
+new TypedEqualsBuilder<>(testObject1, testObject3)
+.append(TestObject::getA)
+.append(TestObject::getB)
+.isEquals());
+assertEquals(Boolean.FALSE,
+new TypedEqualsBuilder<>(testObject1, testObject2)
+.append(TestObject::getA)
+.append(TestObject::getB)
+.isEquals());
+assertEquals(Boolean.FALSE,
+new TypedEqualsBuilder<>(testObject2, testObject1)
+.append(TestObject::getA)
+.append(TestObject::getB)
+.isEquals());
+assertEquals(Boolean.FALSE,
+new TypedEqualsBuilder<>(testObject1, null)
+.append(TestObject::getA)
+.isEquals());
+assertEquals(Boolean.FALSE,
+   

[jira] [Commented] (VFS-842) CopyFrom method doesn't update File Size after replacing file

2023-09-27 Thread Usman Ashraf Bajwah (Jira)


[ 
https://issues.apache.org/jira/browse/VFS-842?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17769561#comment-17769561
 ] 

Usman Ashraf Bajwah commented on VFS-842:
-

I have tried both but it didn't work. I assume that while creating copy the 
size is not setup in new object instead old information is preserved. The wrong 
size is also displayed by File System

> CopyFrom method doesn't update File Size after replacing file
> -
>
> Key: VFS-842
> URL: https://issues.apache.org/jira/browse/VFS-842
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Usman Ashraf Bajwah
>Priority: Major
>
> Consider the scenario where we have two folders source and destination both 
> have file with SAME NAME use copyFrom method file will be copied (replaced) 
> in the destination folder alright but size of the file WILL NOT BE UPDATED IF 
> THE SIZE OF DESTINATION FILE BEFORE COPY WAS GREATER THAN THE SIZE OF SOURCE 
> FILE. In order to produce this issue. Use following code. and also take 2 
> image files in two different folders. Also make sure the destination folder 
> contains image with higher size. 
>  
>  
> {color:#7f0055}public{color}{color:#00} 
> {color}{color:#7f0055}static{color}{color:#00} 
> {color}{color:#7f0055}void{color}{color:#00} main(String[] 
> {color}{color:#6a3e3e}args{color}{color:#00}) 
> {color}{color:#7f0055}throws{color}{color:#00} FileSystemException, 
> UnsupportedEncodingException {{color}
> {color:#7f0055}try{color}{color:#00} {{color}
> {color:#00} String {color}{color:#6a3e3e}source{color}{color:#00} = 
> {color}{color:#2a00ff}"C:
> SourceFolder
> Usman.jpg"{color}{color:#00};{color}
> {color:#00} String 
> {color}{color:#6a3e3e}destination{color}{color:#00} = 
> {color}{color:#2a00ff}"C:
> TargetFolder
> Usman.jpg"{color}{color:#00};{color}
> {color:#00} FileSystemManager 
> {color}{color:#6a3e3e}fsManager{color}{color:#00} = 
> VFS.{color}{color:#00}getManager{color}{color:#00}();{color}
> {color:#00} FileObject 
> {color}{color:#6a3e3e}fileToCopy{color}{color:#00} = 
> {color}{color:#6a3e3e}fsManager{color}{color:#00}.resolveFile({color}{color:#6a3e3e}source{color}{color:#00});{color}
> {color:#00} FileObject 
> {color}{color:#6a3e3e}destinationFilePath{color}{color:#00} = 
> {color}{color:#6a3e3e}fsManager{color}{color:#00}.resolveFile({color}{color:#6a3e3e}destination{color}{color:#00});{color}
> {color:#00} 
> System.{color}{color:#c0}out{color}{color:#00}.println({color}{color:#2a00ff}"Source
>  File Size: 
> "{color}{color:#00}+{color}{color:#6a3e3e}fileToCopy{color}{color:#00}.getContent().getSize());{color}
> {color:#00} 
> System.{color}{color:#c0}out{color}{color:#00}.println({color}{color:#2a00ff}"Destination
>  File Size Before Copy: 
> "{color}{color:#00}+{color}{color:#6a3e3e}destinationFilePath{color}{color:#00}.getContent().getSize());{color}
> {color:#6a3e3e}destinationFilePath{color}{color:#00}.copyFrom({color}{color:#6a3e3e}fileToCopy{color}{color:#00},
>  Selectors.{color}{color:#c0}SELECT_ALL{color}{color:#00});{color}
> {color:#00} 
> System.{color}{color:#c0}out{color}{color:#00}.println({color}{color:#2a00ff}"Destination
>  File Size After Copy: 
> "{color}{color:#00}+{color}{color:#6a3e3e}destinationFilePath{color}{color:#00}.getContent().getSize());{color}
> {color:#00} }{color}{color:#7f0055}catch{color}{color:#00}(Exception 
> {color}{color:#6a3e3e}ex{color}{color:#00}) {{color}
> {color:#6a3e3e}ex{color}{color:#00}.printStackTrace();{color}
> {color:#00} } {color}
> {color:#00} }{color}
> {color:#00}The output it shows : {color}
> {color:#00}Source File Size: 17259{color}
> {color:#00}Destination File Size Before Copy: 110696{color}
> {color:#00}Destination File Size After Copy: 110696{color}
> {color:#00}I have verified the file is successfully copied but on File 
> explorer the old size is showing. It seems there is some issue while we write 
> the content of the file. Please let me know if you need any information. The 
> documentation [here 
> |https://commons.apache.org/proper/commons-vfs/commons-vfs2/apidocs/org/apache/commons/vfs2/FileObject.html#copyFrom-org.apache.commons.vfs2.FileObject-org.apache.commons.vfs2.FileSelector-]says
>  the destination file is deleted first but i don't see in code while 
> debugging that file is actually deleting. or I am missing something but issue 
> is definitely there.{color}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-lang] garydgregory commented on a diff in pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


garydgregory commented on code in PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#discussion_r1338471365


##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It then offers the possibility to append field extractors.
+ *
+ * Typical use for the code is as follows:
+ * 
+ * public boolean equals(Object obj) {
+ * return new TypedEqualsBuilder<>(this)
+ * .appendBaseObject(obj)
+ * .append(TestObject::getA)
+ * .append(TestObject::getB)
+ * .isEquals();
+ * }
+ * 
+ *
+ * @param  the type of the compared object.
+ *
+ * @since 3.14.0
+ */
+public class TypedEqualsBuilder extends EqualsBuilder {
+
+private final T currentInstance;
+
+private boolean sameReference = false;
+private T other;
+
+@SuppressWarnings("unchecked")
+public TypedEqualsBuilder(T currentInstance, Object other) {
+Objects.requireNonNull(currentInstance);
+this.currentInstance = currentInstance;
+if (currentInstance == other) {
+sameReference = true;
+return;
+}
+Class currentInstanceClass = (Class) currentInstance.getClass();
+if (other == null || currentInstanceClass != other.getClass()) {
+isEquals = false;
+return;
+}
+this.other = (T) other;
+}
+
+@Override
+boolean shouldLeaveEarly() {

Review Comment:
   Leave what early? This methods needs a better name IMO?



##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.

Review Comment:
   Documentation needs a rework. I can't understand what this means.



##
src/main/java/org/apache/commons/lang3/builder/TypedEqualsBuilder.java:
##
@@ -0,0 +1,77 @@
+/*
+ * 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.lang3.builder;
+
+import java.util.Objects;
+import java.util.function.Function;
+
+/**
+ * An extension of {@link EqualsBuilder} aimed to perform additionally the 
base objects and class equals checks.
+ *
+ * It 

[GitHub] [commons-lang] garydgregory commented on pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


garydgregory commented on PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#issuecomment-1737220327

   Hello @Cousnouf 
   Please run `mvn` locally and fix issues before you push to avoid broken 
builds.


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Created] (LANG-1712) Complete the EqualsBuilder to manage type equivalence

2023-09-27 Thread Marc Cappelletti (Jira)
Marc Cappelletti created LANG-1712:
--

 Summary: Complete the EqualsBuilder to manage type equivalence
 Key: LANG-1712
 URL: https://issues.apache.org/jira/browse/LANG-1712
 Project: Commons Lang
  Issue Type: New Feature
Affects Versions: 3.13.0
Reporter: Marc Cappelletti


Extend the EqualsBuilder to manage the nullity and the class equality when 
building and equals method.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[GitHub] [commons-jxpath] garydgregory commented on pull request #25: Fix for Issue: CVE-2022-41852

2023-09-27 Thread via GitHub


garydgregory commented on PR #25:
URL: https://github.com/apache/commons-jxpath/pull/25#issuecomment-1737212833

   > Please fix the issue with CVS 2022-41852.
   
   Note that the CVE has been rejected. 


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [commons-lang] ecki commented on pull request #1114: Add TypedEqualsBuilder class and test

2023-09-27 Thread via GitHub


ecki commented on PR #1114:
URL: https://github.com/apache/commons-lang/pull/1114#issuecomment-1737138634

   Change looks quite good and complete. Not sure about the size, it might 
require a Apache contributor agreement. With this PR and Dev mail you probably 
don’t need an extra JIRA (or a committer can do that).
   
   Do you have an contributors agreement on file, by any chance? 
https://www.apache.org/licenses/contributor-agreements.html
   


-- 
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: issues-unsubscr...@commons.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[jira] [Created] (IO-810) Wrong JavaDoc regarding exception in FileUtils

2023-09-27 Thread Gregor Dschung (Jira)
Gregor Dschung created IO-810:
-

 Summary: Wrong JavaDoc regarding exception in FileUtils
 Key: IO-810
 URL: https://issues.apache.org/jira/browse/IO-810
 Project: Commons IO
  Issue Type: Bug
  Components: Utilities
Affects Versions: 2.13.0, 2.12.0
Reporter: Gregor Dschung


The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
{{FileNotFoundException}} is thrown if the file doesn't exist. This isn't true 
with version 2.12 and above, including the current 2.14 snapshot, where a 
{{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
exception is coming via {{Files#newByteChannel(...)}}.

Root cause seems to be, like in IO-800, [this 
commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
 from 2021, where {{openInputStream(file)}} (which is calling 
{{new FileInputStream(file)}} from {{java.io}}) is replaced by 
Files.newInputStream(file.toPath()) from {{java.nio}}. 

I'm unsure if just the JavaDoc should be updated or the old behavior be 
restored: I noticed the bug because we catch a {{FileNotFoundException}}, which 
doesn't work for 2.12 and above.

{code:title=Old Stacktrace}
java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
~[na:na]
at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
~[na:na]
at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
~[commons-io-2.11.0.jar:2.11.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
~[commons-io-2.11.0.jar:2.11.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
~[commons-io-2.11.0.jar:2.11.0]
{code}

{code:title=New Stacktrace}
java.nio.file.NoSuchFileException: doesnt-exist.txt
at 
java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
 ~[na:na]
at 
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) 
~[na:na]
at 
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) 
~[na:na]
at 
java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
 ~[na:na]
at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
at 
java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
 ~[na:na]
at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
at 
org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616) 
~[commons-io-2.13.0.jar:2.13.0]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
~[commons-io-2.13.0.jar:2.13.0]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
~[commons-io-2.13.0.jar:2.13.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
~[commons-io-2.13.0.jar:2.13.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
~[commons-io-2.13.0.jar:2.13.0]
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Updated] (IO-810) Wrong JavaDoc regarding exception in FileUtils

2023-09-27 Thread Gregor Dschung (Jira)


 [ 
https://issues.apache.org/jira/browse/IO-810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Gregor Dschung updated IO-810:
--
Description: 
The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
{{FileNotFoundException}} is thrown if the file doesn't exist. This isn't true 
with version 2.12 and above, including the current 2.14 snapshot, where a 
{{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
exception is coming via {{Files#newByteChannel(...)}}.

Root cause seems to be, like in IO-800, [this 
commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
 from 2021, where {{openInputStream(file)}} (which is calling 
{{new FileInputStream(file)}} from {{java.io}}) is replaced by 
{{Files.newInputStream(file.toPath())}} from {{java.nio}}. 

I'm unsure if just the JavaDoc should be updated or the old behavior be 
restored: I noticed the bug because we catch a {{FileNotFoundException}}, which 
doesn't work for 2.12 and above.

{code:title=Old Stacktrace}
java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
~[na:na]
at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
~[na:na]
at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
~[commons-io-2.11.0.jar:2.11.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
~[commons-io-2.11.0.jar:2.11.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2526) 
~[commons-io-2.11.0.jar:2.11.0]
{code}

{code:title=New Stacktrace}
java.nio.file.NoSuchFileException: doesnt-exist.txt
at 
java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
 ~[na:na]
at 
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111) 
~[na:na]
at 
java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116) 
~[na:na]
at 
java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
 ~[na:na]
at java.base/java.nio.file.Files.newByteChannel(Files.java:371) ~[na:na]
at java.base/java.nio.file.Files.newByteChannel(Files.java:422) ~[na:na]
at 
java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
 ~[na:na]
at java.base/java.nio.file.Files.newInputStream(Files.java:156) ~[na:na]
at 
org.apache.commons.io.FileUtils.lambda$readFileToString$12(FileUtils.java:2616) 
~[commons-io-2.13.0.jar:2.13.0]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:3177) 
~[commons-io-2.13.0.jar:2.13.0]
at org.apache.commons.io.IOUtils.toString(IOUtils.java:3152) 
~[commons-io-2.13.0.jar:2.13.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2616) 
~[commons-io-2.13.0.jar:2.13.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2599) 
~[commons-io-2.13.0.jar:2.13.0]
{code}

  was:
The JavaDoc of {{FileUtils#readFileToString(...)}} is stating that a 
{{FileNotFoundException}} is thrown if the file doesn't exist. This isn't true 
with version 2.12 and above, including the current 2.14 snapshot, where a 
{{NoSuchFileException}} is thrown. I haven't tested, but I guess that other 
methods like {{FileUtils#readFileToByteArray(...)}} are affected, too, as the 
exception is coming via {{Files#newByteChannel(...)}}.

Root cause seems to be, like in IO-800, [this 
commit|https://github.com/apache/commons-io/commit/dcb09db922e1edbd6dc6cb1531b827451d58aa83#diff-0bd8160a11e12ea1f96476a00e78d0a95b965d07c7fe126e1af498c08511dd70]
 from 2021, where {{openInputStream(file)}} (which is calling 
{{new FileInputStream(file)}} from {{java.io}}) is replaced by 
Files.newInputStream(file.toPath()) from {{java.nio}}. 

I'm unsure if just the JavaDoc should be updated or the old behavior be 
restored: I noticed the bug because we catch a {{FileNotFoundException}}, which 
doesn't work for 2.12 and above.

{code:title=Old Stacktrace}
java.io.FileNotFoundException: doesnt-exist.txt (No such file or directory)
at java.base/java.io.FileInputStream.open0(Native Method) ~[na:na]
at java.base/java.io.FileInputStream.open(FileInputStream.java:219) 
~[na:na]
at java.base/java.io.FileInputStream.(FileInputStream.java:157) 
~[na:na]
at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:2388) 
~[commons-io-2.11.0.jar:2.11.0]
at 
org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:2506) 
~[commons-io-2.11.0.jar:2.11.0]
at