[GitHub] [commons-io] li-keguo commented on pull request #442: add filterReadeLines & consumerReadeLine

2023-03-22 Thread via GitHub


li-keguo commented on PR #442:
URL: https://github.com/apache/commons-io/pull/442#issuecomment-1480459920

   > Hello @li-keguo Why not use Java's Files.lines() APIs instead of these?
   
   HI @garydgregory 
   It is a good idea to implement filters using Files.lines.
   ```java
   Files.lines(file.toPath(), charset)
   .filter(filter)
   .collect(Collectors.toList());
   ```
   However, this is not consumer-friendly. The stream intermediate process does 
not trigger execution.


-- 
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] (VFS-833) org.apache.commons.vfs2.FileSystemOptions#options is not synchronized

2023-03-22 Thread Bernd Eckenfels (Jira)


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

Bernd Eckenfels commented on VFS-833:
-

Thanks for the report. Can you give an example when this actually happens - 
I.e. who changes why fs options. This does not really work very well since they 
are part of the Idendity of a filesystem instance. So I would say most of the 
time they have to be immutable. At least this is what VFS assumes why it does 
not synchronize. Maybe it’s enough if we do a defensive copy?

> org.apache.commons.vfs2.FileSystemOptions#options is not synchronized
> -
>
> Key: VFS-833
> URL: https://issues.apache.org/jira/browse/VFS-833
> Project: Commons VFS
>  Issue Type: Bug
>Affects Versions: 2.9.0
>Reporter: Kannan Ramamoorthy
>Priority: Major
>
> *Problem:*
> The map `org.apache.commons.vfs2.FileSystemOptions#options` is TreeMap. The 
> datastructure is  not thread-safe and resulting in situations like 
> [this|https://ivoanjo.me/blog/2018/07/21/writing-to-a-java-treemap-concurrently-can-lead-to-an-infinite-loop-during-reads/]
>   when used in multithreaded environments.
> *Workaround:*
> As a workaround, we have to synchronize the `FileSystemOptions` in all the 
> places of the code. 
> *Solution:*
>  *  If there is no issue, the constructor `
> protected FileSystemOptions(Map options)` can be 
> made public, so that users will have an option to pass a synchronized map 
> when they have to. * Or, wrap the `TreeMap` instance with 
> `java.util.Collections#synchronizedMap`, ensuring thread safety at the core.



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


[GitHub] [commons-collections] Simulant87 commented on pull request #276: COLLECTIONS-803: prevent duplicate call to convertKey on put for CaseInsensitiveMap

2023-03-22 Thread via GitHub


Simulant87 commented on PR #276:
URL: 
https://github.com/apache/commons-collections/pull/276#issuecomment-1480240789

   @Claudenw I saw you were active on other pull requests. Could you please 
review my pull request here as well? I just updated it to resolve a conflict.


-- 
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] Claudenw commented on a diff in pull request #308: COLLECTIONS-770 When creating an iterator chain containing other iterator chains flatten the resulting internal object

2023-03-22 Thread via GitHub


Claudenw commented on code in PR #308:
URL: 
https://github.com/apache/commons-collections/pull/308#discussion_r1145199169


##
src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java:
##
@@ -170,4 +177,60 @@ public void testEmptyChain() {
 );
 }
 
+@Test
+public void testChainOfChains() {
+final Iterator iteratorChain1 = new 
IteratorChain<>(list1.iterator(), list2.iterator());
+final Iterator iteratorChain2 = new 
IteratorChain<>(list3.iterator(), list4.iterator());
+final Iterator iteratorChainOfChains = new 
IteratorChain<>(iteratorChain1, iteratorChain2);
+
+for (final String testValue : testArray1234) {
+final Object iterValue = iteratorChainOfChains.next();
+
+assertEquals( "Iteration value is correct", testValue, iterValue );
+}
+
+assertFalse("Iterator should now be empty", 
iteratorChainOfChains.hasNext());
+
+try {
+iteratorChainOfChains.next();
+} catch (final Exception e) {
+assertEquals("NoSuchElementException must be thrown", 
e.getClass(), NoSuchElementException.class);
+}
+}
+
+@Test
+public void testChainOfUnmodifiableChains() {
+final Iterator iteratorChain1 = new 
IteratorChain<>(list1.iterator(), list2.iterator());
+final Iterator unmodifiableChain1 = 
IteratorUtils.unmodifiableIterator(iteratorChain1);
+final Iterator iteratorChain2 = new 
IteratorChain<>(list3.iterator(), list4.iterator());
+final Iterator unmodifiableChain2 = 
IteratorUtils.unmodifiableIterator(iteratorChain2);
+final Iterator iteratorChainOfChains = new 
IteratorChain<>(unmodifiableChain1, unmodifiableChain2);
+
+for (final String testValue : testArray1234) {
+final Object iterValue = iteratorChainOfChains.next();
+
+assertEquals( "Iteration value is correct", testValue, iterValue );
+}
+
+assertFalse("Iterator should now be empty", 
iteratorChainOfChains.hasNext());
+
+try {
+iteratorChainOfChains.next();
+} catch (final Exception e) {
+assertEquals("NoSuchElementException must be thrown", 
e.getClass(), NoSuchElementException.class);
+}

Review Comment:
   Replace this with `assertThrows()`



##
src/test/java/org/apache/commons/collections4/iterators/IteratorChainTest.java:
##
@@ -170,4 +177,60 @@ public void testEmptyChain() {
 );
 }
 
+@Test
+public void testChainOfChains() {
+final Iterator iteratorChain1 = new 
IteratorChain<>(list1.iterator(), list2.iterator());
+final Iterator iteratorChain2 = new 
IteratorChain<>(list3.iterator(), list4.iterator());
+final Iterator iteratorChainOfChains = new 
IteratorChain<>(iteratorChain1, iteratorChain2);
+
+for (final String testValue : testArray1234) {
+final Object iterValue = iteratorChainOfChains.next();
+
+assertEquals( "Iteration value is correct", testValue, iterValue );
+}
+
+assertFalse("Iterator should now be empty", 
iteratorChainOfChains.hasNext());
+
+try {
+iteratorChainOfChains.next();
+} catch (final Exception e) {
+assertEquals("NoSuchElementException must be thrown", 
e.getClass(), NoSuchElementException.class);
+}

Review Comment:
   Replace this with `assertThrows()`



-- 
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-io] garydgregory commented on pull request #442: add filterReadeLines & consumerReadeLine

2023-03-22 Thread via GitHub


garydgregory commented on PR #442:
URL: https://github.com/apache/commons-io/pull/442#issuecomment-1479917825

   Hello @li-keguo 
   Why not use Java's Files.lines() APIs?


-- 
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-io] garydgregory commented on pull request #442: add filterReadeLines & consumerReadeLine

2023-03-22 Thread via GitHub


garydgregory commented on PR #442:
URL: https://github.com/apache/commons-io/pull/442#issuecomment-1479794819

   -1: no unit tests, and the build breaks.


-- 
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] (VFS-833) org.apache.commons.vfs2.FileSystemOptions#options is not synchronized

2023-03-22 Thread Kannan Ramamoorthy (Jira)
Kannan Ramamoorthy created VFS-833:
--

 Summary: org.apache.commons.vfs2.FileSystemOptions#options is not 
synchronized
 Key: VFS-833
 URL: https://issues.apache.org/jira/browse/VFS-833
 Project: Commons VFS
  Issue Type: Bug
Affects Versions: 2.9.0
Reporter: Kannan Ramamoorthy


*Problem:*

The map `org.apache.commons.vfs2.FileSystemOptions#options` is TreeMap. The 
datastructure is  not thread-safe and resulting in situations like 
[this|https://ivoanjo.me/blog/2018/07/21/writing-to-a-java-treemap-concurrently-can-lead-to-an-infinite-loop-during-reads/]
  when used in multithreaded environments.

*Workaround:*

As a workaround, we have to synchronize the `FileSystemOptions` in all the 
places of the code. 

*Solution:*
 *  If there is no issue, the constructor `

protected FileSystemOptions(Map options)` can be 
made public, so that users will have an option to pass a synchronized map when 
they have to. * Or, wrap the `TreeMap` instance with 
`java.util.Collections#synchronizedMap`, ensuring thread safety at the core.



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