[jira] [Commented] (COMPRESS-505) Multiple Reads of One SevenZArchiveEntry Fails

2020-03-04 Thread Peter Alfred Lee (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17050990#comment-17050990
 ] 

Peter Alfred Lee commented on COMPRESS-505:
---

This is a problem caused by the random access of 7z(which was published by me).

I'm working on this. I'll push a PR on github and update this issue.

> Multiple Reads of One SevenZArchiveEntry Fails
> --
>
> Key: COMPRESS-505
> URL: https://issues.apache.org/jira/browse/COMPRESS-505
> Project: Commons Compress
>  Issue Type: Bug
>Affects Versions: 1.20
>Reporter: Steven Fontaine
>Priority: Minor
> Attachments: CC0 Images.7z
>
>
> I've run into a bug which occurs when attempting to read the same 
> SevenZArchiveEntry stream multiple times. The following code illustrates the 
> problem.
> {code:java}
> File archive = new File("CC0 Images.7z");
> char[] password = "password".toCharArray();
> try (SevenZFile f = new SevenZFile(archive, password))
> {
>   SevenZArchiveEntry entry = 
> StreamSupport.stream(f.getEntries().spliterator(), false)
> .filter(e -> 
> "alberta-amazing-attraction-banff-417074.jpg".equals(e.getName()))
> .findFirst().orElseGet(null);
>   assert entry != null;
>   for (int i = 0; i < 100; i++)
>   {
> InputStream is = f.getInputStream(entry);
> BufferedImage img = ImageIO.read(is);
> assert img != null;
> System.out.println("Succeeded " + (i + 1) + " times");
>   }
> }{code}
> Below is the output I receive on version 1.20
> {code:java}
> Succeeded 1 times
> Succeeded 2 times
> Exception in thread "main" java.io.IOException: Checksum verification failed
> at 
> org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:61)
> at 
> org.apache.commons.compress.utils.ChecksumVerifyingInputStream.skip(ChecksumVerifyingInputStream.java:102)
> at org.apache.commons.compress.utils.IOUtils.skip(IOUtils.java:113)
> at 
> org.apache.commons.compress.archivers.sevenz.SevenZFile.getCurrentStream(SevenZFile.java:1318)
> at 
> org.apache.commons.compress.archivers.sevenz.SevenZFile.getInputStream(SevenZFile.java:1354)
> at org.abitoff.dmav.Test.main(Test.java:11)
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387513578
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
 
 Review comment:
   Correct the {@code ...} tag


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387513815
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
+ * 
+ * This hasher only accepts HashFunctions that are cyclic in nature.
+ * 
+ * @see DynamicHasher
+ * @see ProcessType
+ */
+public class CachingHasher implements Hasher {
+
+/**
+ * The list of byte arrays that are to be hashed.
+ */
+private final List buffers;
+
+/**
+ * The hash function identity
+ */
+private final HashFunctionIdentity functionIdentity;
+
+/**
+ * Constructs a CachingHasher from a list of arrays of hash values.
+ * 
+ * The list of hash values comprises a @code{List} where 
each @code{long[]}
 
 Review comment:
   {@code List} and {@code long[]}


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387513930
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
+ * 
+ * This hasher only accepts HashFunctions that are cyclic in nature.
+ * 
+ * @see DynamicHasher
+ * @see ProcessType
+ */
+public class CachingHasher implements Hasher {
+
+/**
+ * The list of byte arrays that are to be hashed.
+ */
+private final List buffers;
+
+/**
+ * The hash function identity
+ */
+private final HashFunctionIdentity functionIdentity;
+
+/**
+ * Constructs a CachingHasher from a list of arrays of hash values.
+ * 
+ * The list of hash values comprises a @code{List} where 
each @code{long[]}
+ * is comprises two (2) values that are the result of hashing the original 
buffer.  Thus a
+ * CachingHasher that was built from five (5) buffers will have five 
arrays of two @code{longs}
 
 Review comment:
   {@code long}s


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387514135
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
+ * 
+ * This hasher only accepts HashFunctions that are cyclic in nature.
+ * 
+ * @see DynamicHasher
+ * @see ProcessType
+ */
+public class CachingHasher implements Hasher {
+
+/**
+ * The list of byte arrays that are to be hashed.
+ */
+private final List buffers;
+
+/**
+ * The hash function identity
+ */
+private final HashFunctionIdentity functionIdentity;
+
+/**
+ * Constructs a CachingHasher from a list of arrays of hash values.
+ * 
+ * The list of hash values comprises a @code{List} where 
each @code{long[]}
+ * is comprises two (2) values that are the result of hashing the original 
buffer.  Thus a
+ * CachingHasher that was built from five (5) buffers will have five 
arrays of two @code{longs}
+ * each.
+ * 
+ * @param functionIdentity The identity of the function.
+ * @param buffers  a list of @code{long} arrays comprising two (2) 
values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, List 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = new ArrayList(buffers);
+}
+
+/**
+ * Constructs a CachingHasher from an array of arrys of hash values.
+ *
+ * @param functionIdentity The identity of the function.
+ * @param buffers  an array of @code{long} arrays comprising two 
(2) values.
 
 Review comment:
   I don't think the (2) adds anything.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387515514
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
+ * 
+ * This hasher only accepts HashFunctions that are cyclic in nature.
+ * 
+ * @see DynamicHasher
+ * @see ProcessType
+ */
+public class CachingHasher implements Hasher {
+
+/**
+ * The list of byte arrays that are to be hashed.
+ */
+private final List buffers;
+
+/**
+ * The hash function identity
+ */
+private final HashFunctionIdentity functionIdentity;
+
+/**
+ * Constructs a CachingHasher from a list of arrays of hash values.
+ * 
+ * The list of hash values comprises a @code{List} where 
each @code{long[]}
+ * is comprises two (2) values that are the result of hashing the original 
buffer.  Thus a
+ * CachingHasher that was built from five (5) buffers will have five 
arrays of two @code{longs}
+ * each.
+ * 
+ * @param functionIdentity The identity of the function.
+ * @param buffers  a list of @code{long} arrays comprising two (2) 
values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, List 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = new ArrayList(buffers);
+}
+
+/**
+ * Constructs a CachingHasher from an array of arrys of hash values.
+ *
+ * @param functionIdentity The identity of the function.
+ * @param buffers  an array of @code{long} arrays comprising two 
(2) values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, long[][] 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = Arrays.asList(buffers);
+}
+
+/**
+ * Checks that the name is valid for this hasher.
+ *
+ * @param functionIdentity the Function Identity to check.
+ */
+private static HashFunctionIdentity checkIdentity(HashFunctionIdentity 
functionIdentity) {
+if (functionIdentity.getProcessType() != ProcessType.CYCLIC) {
+throw new IllegalArgumentException("Only cyclic hash functions may 
be used in a caching hasher");
+}
+return functionIdentity;
+}
+
+@Override
+public HashFunctionIdentity getHashFunctionIdentity() {
+return functionIdentity;
+}
+
+@Override
+public boolean isEmpty() {
+return buffers.isEmpty();
+}
+
+
+@Override
+public PrimitiveIterator.OfInt getBits(Shape shape) {
+HashFunctionValidator.checkAreEqual(getHashFunctionIdentity(),
+shape.getHashFunctionIdentity());
+return new IntIterator(shape);
+}
+
+/**
+ * Gets the long representations of the buffers.
+ * 
 
 Review comment:
   A bit more doc would help here, i.e. the List will contains zero or 
more entries, each entry is a non-null array of length two containing the 
64-bit pair output from the cyclic hash function.


Th

[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387516238
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
+ * 
+ * This hasher only accepts HashFunctions that are cyclic in nature.
+ * 
+ * @see DynamicHasher
+ * @see ProcessType
+ */
+public class CachingHasher implements Hasher {
+
+/**
+ * The list of byte arrays that are to be hashed.
+ */
+private final List buffers;
+
+/**
+ * The hash function identity
+ */
+private final HashFunctionIdentity functionIdentity;
+
+/**
+ * Constructs a CachingHasher from a list of arrays of hash values.
+ * 
+ * The list of hash values comprises a @code{List} where 
each @code{long[]}
+ * is comprises two (2) values that are the result of hashing the original 
buffer.  Thus a
+ * CachingHasher that was built from five (5) buffers will have five 
arrays of two @code{longs}
+ * each.
+ * 
+ * @param functionIdentity The identity of the function.
+ * @param buffers  a list of @code{long} arrays comprising two (2) 
values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, List 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = new ArrayList(buffers);
+}
+
+/**
+ * Constructs a CachingHasher from an array of arrys of hash values.
+ *
+ * @param functionIdentity The identity of the function.
+ * @param buffers  an array of @code{long} arrays comprising two 
(2) values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, long[][] 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = Arrays.asList(buffers);
+}
+
+/**
+ * Checks that the name is valid for this hasher.
+ *
+ * @param functionIdentity the Function Identity to check.
+ */
+private static HashFunctionIdentity checkIdentity(HashFunctionIdentity 
functionIdentity) {
+if (functionIdentity.getProcessType() != ProcessType.CYCLIC) {
+throw new IllegalArgumentException("Only cyclic hash functions may 
be used in a caching hasher");
+}
+return functionIdentity;
+}
+
+@Override
+public HashFunctionIdentity getHashFunctionIdentity() {
+return functionIdentity;
+}
+
+@Override
+public boolean isEmpty() {
+return buffers.isEmpty();
+}
+
+
+@Override
+public PrimitiveIterator.OfInt getBits(Shape shape) {
+HashFunctionValidator.checkAreEqual(getHashFunctionIdentity(),
+shape.getHashFunctionIdentity());
+return new IntIterator(shape);
+}
+
+/**
+ * Gets the long representations of the buffers.
+ * 
+ * This method returns the long representations of the buffers.  This is 
commonly used
+ * to transmit the Hasher from one system to another.
+ * 
+ * @return a copy if the long buffer representation.
+ */
+public List getBuffers() {
+return new Arra

[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387516780
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/HashFunctionIdentityImpl.java
 ##
 @@ -51,7 +51,8 @@ public HashFunctionIdentityImpl(final HashFunctionIdentity 
identity) {
  * @param process the processes of the hash function.
  * @param signature the signature for the hash function.
  */
-public HashFunctionIdentityImpl(final String provider, final String name, 
final Signedness signedness, final ProcessType process,
+public HashFunctionIdentityImpl(final String provider, final String name, 
final Signedness signedness,
 
 Review comment:
   No need for the line wrap here. It is unrelated to the PR.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387516406
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasher.java
 ##
 @@ -0,0 +1,233 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+
+import 
org.apache.commons.collections4.bloomfilter.hasher.HashFunctionIdentity.ProcessType;
+
+/**
+ * An implementation of Hasher that attempts to leak as little data as 
possible.
+ * Each item in the hasher is represented by two (2) longs.  So this Hasher 
will
+ * still indicate how many items are in the hasher but will not leak the 
buffers
+ * that are being hashed as the @code DynamicHasher} does.
+ * 
+ * This hasher only accepts HashFunctions that are cyclic in nature.
+ * 
+ * @see DynamicHasher
+ * @see ProcessType
+ */
+public class CachingHasher implements Hasher {
+
+/**
+ * The list of byte arrays that are to be hashed.
+ */
+private final List buffers;
+
+/**
+ * The hash function identity
+ */
+private final HashFunctionIdentity functionIdentity;
+
+/**
+ * Constructs a CachingHasher from a list of arrays of hash values.
+ * 
+ * The list of hash values comprises a @code{List} where 
each @code{long[]}
+ * is comprises two (2) values that are the result of hashing the original 
buffer.  Thus a
+ * CachingHasher that was built from five (5) buffers will have five 
arrays of two @code{longs}
+ * each.
+ * 
+ * @param functionIdentity The identity of the function.
+ * @param buffers  a list of @code{long} arrays comprising two (2) 
values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, List 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = new ArrayList(buffers);
+}
+
+/**
+ * Constructs a CachingHasher from an array of arrys of hash values.
+ *
+ * @param functionIdentity The identity of the function.
+ * @param buffers  an array of @code{long} arrays comprising two 
(2) values.
+ * @throws IllegalArgumentException if the name does not indicate a cyclic
+ *  hashing function.
+ */
+public CachingHasher(HashFunctionIdentity functionIdentity, long[][] 
buffers) {
+this.functionIdentity = checkIdentity(functionIdentity);
+this.buffers = Arrays.asList(buffers);
+}
+
+/**
+ * Checks that the name is valid for this hasher.
+ *
+ * @param functionIdentity the Function Identity to check.
+ */
+private static HashFunctionIdentity checkIdentity(HashFunctionIdentity 
functionIdentity) {
+if (functionIdentity.getProcessType() != ProcessType.CYCLIC) {
+throw new IllegalArgumentException("Only cyclic hash functions may 
be used in a caching hasher");
+}
+return functionIdentity;
+}
+
+@Override
+public HashFunctionIdentity getHashFunctionIdentity() {
+return functionIdentity;
+}
+
+@Override
+public boolean isEmpty() {
+return buffers.isEmpty();
+}
+
+
+@Override
+public PrimitiveIterator.OfInt getBits(Shape shape) {
+HashFunctionValidator.checkAreEqual(getHashFunctionIdentity(),
+shape.getHashFunctionIdentity());
+return new IntIterator(shape);
+}
+
+/**
+ * Gets the long representations of the buffers.
+ * 
+ * This method returns the long representations of the buffers.  This is 
commonly used
+ * to transmit the Hasher from one system to another.
+ * 
+ * @return a copy if the long buffer representation.
+ */
+public List getBuffers() {
+return new Arra

[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387517823
 
 

 ##
 File path: 
src/main/java/org/apache/commons/collections4/bloomfilter/hasher/HashFunctionValidator.java
 ##
 @@ -20,7 +20,7 @@
 /**
  * Contains validation for hash functions.
  */
-final class HashFunctionValidator {
+public final class HashFunctionValidator {
 
 Review comment:
   Why make this public here? That would fix it in the API. Currently it is 
only used internally.
   
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387518406
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherBuilderTest.java
 ##
 @@ -0,0 +1,103 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * {@link CachingHasher.Builder} tests.
+ */
+public class CachingHasherBuilderTest {
+
+private CachingHasher.Builder builder;
+private final Shape shape = new Shape(new MD5Cyclic(), 1, 
Integer.MAX_VALUE, 1);
+
+/**
+ * Tests that hashing a byte works as expected.
+ */
+@Test
+public void buildTest_byte() {
+final CachingHasher hasher = builder.with((byte) 0x1).build();
+
+final int expected = 1483089307;
+
+final OfInt iter = hasher.getBits(shape);
+
+assertTrue(iter.hasNext());
+assertEquals(expected, iter.nextInt());
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that hashing a byte array works as expected.
+ */
+@Test
+public void buildTest_byteArray() {
+final CachingHasher hasher = builder.with("Hello".getBytes()).build();
+final int expected = 1519797563;
+
+final OfInt iter = hasher.getBits(shape);
+
+assertTrue(iter.hasNext());
+assertEquals(expected, iter.nextInt());
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that an empty hasher works as expected.
+ */
+@Test
+public void buildTest_Empty() {
+final CachingHasher hasher = builder.build();
+
+final OfInt iter = hasher.getBits(shape);
+
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that hashing a string works as expected.
+ */
+@Test
+public void buildTest_String() {
+final CachingHasher hasher = builder.with("Hello").build();
+final int expected = 1519797563;
+
+final OfInt iter = hasher.getBits(shape);
+
+assertTrue(iter.hasNext());
+assertEquals(expected, iter.nextInt());
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Sets up the builder for testing.
+ */
+@Before
 
 Review comment:
   Move this to the top of the test


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387519064
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherTest.java
 ##
 @@ -0,0 +1,241 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CachingHasher}.
+ */
+public class CachingHasherTest {
+private CachingHasher.Builder builder;
+private Shape shape;
+
+private final HashFunctionIdentity testFunction = new 
HashFunctionIdentity() {
+
+@Override
+public String getName() {
+return "Test Function";
+}
+
+@Override
+public ProcessType getProcessType() {
+return ProcessType.CYCLIC;
+}
+
+@Override
+public String getProvider() {
+return "Apache Commons Collection Tests";
+}
+
+@Override
+public long getSignature() {
+return 0;
+}
+
+@Override
+public Signedness getSignedness() {
+return Signedness.SIGNED;
+}
+};
+
+/**
+ * Sets up the CachingHasher.
+ */
+@Before
+public void setup() {
+builder = new CachingHasher.Builder(new MD5Cyclic());
+shape = new Shape(new MD5Cyclic(), 3, 72, 17);
+}
+
+/**
+ * Tests that the expected bits are returned from hashing.
+ */
+@Test
+public void testGetBits() {
+
 
 Review comment:
   Empty line


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387520802
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherTest.java
 ##
 @@ -0,0 +1,241 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CachingHasher}.
+ */
+public class CachingHasherTest {
+private CachingHasher.Builder builder;
+private Shape shape;
+
+private final HashFunctionIdentity testFunction = new 
HashFunctionIdentity() {
+
+@Override
+public String getName() {
+return "Test Function";
+}
+
+@Override
+public ProcessType getProcessType() {
+return ProcessType.CYCLIC;
+}
+
+@Override
+public String getProvider() {
+return "Apache Commons Collection Tests";
+}
+
+@Override
+public long getSignature() {
+return 0;
+}
+
+@Override
+public Signedness getSignedness() {
+return Signedness.SIGNED;
+}
+};
+
+/**
+ * Sets up the CachingHasher.
+ */
+@Before
+public void setup() {
+builder = new CachingHasher.Builder(new MD5Cyclic());
+shape = new Shape(new MD5Cyclic(), 3, 72, 17);
+}
+
+/**
+ * Tests that the expected bits are returned from hashing.
+ */
+@Test
+public void testGetBits() {
+
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62 };
+
+final Hasher hasher = builder.with("Hello").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that bits from multiple hashes are returned correctly.
+ */
+@Test
+public void testGetBits_MultipleHashes() {
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7,
+69, 59, 49, 39, 13, 3, 65, 55, 45, 35, 25 };
+
+final Hasher hasher = builder.with("Hello").with("World").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSuchElementException ignore) {
+// do nothing
+}
+}
+
+/**
+ * Tests that retrieving bits for the wrong shape throws an exception.
+ */
+@Test
+public void testGetBits_WongShape() {
+
+final Hasher hasher = builder.with("Hello").build();
+
+try {
+hasher.getBits(new Shape(testFunction, 3, 72, 17));
+fail("Should have thown IllegalArgumentException");
+} catch (final IllegalArgumentException expected) {
+// do nothing
+}
+}
+
+/**
+ * Tests if isEmpty() reports correctly and the iterator returns no values.
+ */
+@Test
+public void testIsEmpty() {
+CachingHasher hasher = builder.build();
+assertTrue(hasher.isEmpty());
+final OfInt iter = hasher.getBits(shape);
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSu

[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387520915
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherTest.java
 ##
 @@ -0,0 +1,241 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CachingHasher}.
+ */
+public class CachingHasherTest {
+private CachingHasher.Builder builder;
+private Shape shape;
+
+private final HashFunctionIdentity testFunction = new 
HashFunctionIdentity() {
 
 Review comment:
   Cleaner to use HashFunctionIdentityImpl here.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387521613
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherTest.java
 ##
 @@ -0,0 +1,241 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CachingHasher}.
+ */
+public class CachingHasherTest {
+private CachingHasher.Builder builder;
+private Shape shape;
+
+private final HashFunctionIdentity testFunction = new 
HashFunctionIdentity() {
+
+@Override
+public String getName() {
+return "Test Function";
+}
+
+@Override
+public ProcessType getProcessType() {
+return ProcessType.CYCLIC;
+}
+
+@Override
+public String getProvider() {
+return "Apache Commons Collection Tests";
+}
+
+@Override
+public long getSignature() {
+return 0;
+}
+
+@Override
+public Signedness getSignedness() {
+return Signedness.SIGNED;
+}
+};
+
+/**
+ * Sets up the CachingHasher.
+ */
+@Before
+public void setup() {
+builder = new CachingHasher.Builder(new MD5Cyclic());
+shape = new Shape(new MD5Cyclic(), 3, 72, 17);
+}
+
+/**
+ * Tests that the expected bits are returned from hashing.
+ */
+@Test
+public void testGetBits() {
+
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62 };
+
+final Hasher hasher = builder.with("Hello").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that bits from multiple hashes are returned correctly.
+ */
+@Test
+public void testGetBits_MultipleHashes() {
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7,
+69, 59, 49, 39, 13, 3, 65, 55, 45, 35, 25 };
+
+final Hasher hasher = builder.with("Hello").with("World").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSuchElementException ignore) {
+// do nothing
+}
+}
+
+/**
+ * Tests that retrieving bits for the wrong shape throws an exception.
+ */
+@Test
+public void testGetBits_WongShape() {
+
 
 Review comment:
   empty line


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387521443
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherTest.java
 ##
 @@ -0,0 +1,241 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CachingHasher}.
+ */
+public class CachingHasherTest {
+private CachingHasher.Builder builder;
+private Shape shape;
+
+private final HashFunctionIdentity testFunction = new 
HashFunctionIdentity() {
+
+@Override
+public String getName() {
+return "Test Function";
+}
+
+@Override
+public ProcessType getProcessType() {
+return ProcessType.CYCLIC;
+}
+
+@Override
+public String getProvider() {
+return "Apache Commons Collection Tests";
+}
+
+@Override
+public long getSignature() {
+return 0;
+}
+
+@Override
+public Signedness getSignedness() {
+return Signedness.SIGNED;
+}
+};
+
+/**
+ * Sets up the CachingHasher.
+ */
+@Before
+public void setup() {
+builder = new CachingHasher.Builder(new MD5Cyclic());
+shape = new Shape(new MD5Cyclic(), 3, 72, 17);
+}
+
+/**
+ * Tests that the expected bits are returned from hashing.
+ */
+@Test
+public void testGetBits() {
+
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62 };
+
+final Hasher hasher = builder.with("Hello").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that bits from multiple hashes are returned correctly.
+ */
+@Test
+public void testGetBits_MultipleHashes() {
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7,
+69, 59, 49, 39, 13, 3, 65, 55, 45, 35, 25 };
+
+final Hasher hasher = builder.with("Hello").with("World").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSuchElementException ignore) {
+// do nothing
+}
+}
+
+/**
+ * Tests that retrieving bits for the wrong shape throws an exception.
+ */
+@Test
+public void testGetBits_WongShape() {
+
+final Hasher hasher = builder.with("Hello").build();
+
+try {
+hasher.getBits(new Shape(testFunction, 3, 72, 17));
+fail("Should have thown IllegalArgumentException");
+} catch (final IllegalArgumentException expected) {
+// do nothing
+}
+}
+
+/**
+ * Tests if isEmpty() reports correctly and the iterator returns no values.
+ */
+@Test
+public void testIsEmpty() {
+CachingHasher hasher = builder.build();
+assertTrue(hasher.isEmpty());
+final OfInt iter = hasher.getBits(shape);
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSu

[GitHub] [commons-collections] aherbert commented on a change in pull request #131: Added caching hasher

2020-03-04 Thread GitBox
aherbert commented on a change in pull request #131: Added caching hasher
URL: 
https://github.com/apache/commons-collections/pull/131#discussion_r387521241
 
 

 ##
 File path: 
src/test/java/org/apache/commons/collections4/bloomfilter/hasher/CachingHasherTest.java
 ##
 @@ -0,0 +1,241 @@
+/*
+ * 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.collections4.bloomfilter.hasher;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.PrimitiveIterator;
+import java.util.PrimitiveIterator.OfInt;
+
+import org.apache.commons.collections4.bloomfilter.hasher.function.MD5Cyclic;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests the {@link CachingHasher}.
+ */
+public class CachingHasherTest {
+private CachingHasher.Builder builder;
+private Shape shape;
+
+private final HashFunctionIdentity testFunction = new 
HashFunctionIdentity() {
+
+@Override
+public String getName() {
+return "Test Function";
+}
+
+@Override
+public ProcessType getProcessType() {
+return ProcessType.CYCLIC;
+}
+
+@Override
+public String getProvider() {
+return "Apache Commons Collection Tests";
+}
+
+@Override
+public long getSignature() {
+return 0;
+}
+
+@Override
+public Signedness getSignedness() {
+return Signedness.SIGNED;
+}
+};
+
+/**
+ * Sets up the CachingHasher.
+ */
+@Before
+public void setup() {
+builder = new CachingHasher.Builder(new MD5Cyclic());
+shape = new Shape(new MD5Cyclic(), 3, 72, 17);
+}
+
+/**
+ * Tests that the expected bits are returned from hashing.
+ */
+@Test
+public void testGetBits() {
+
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62 };
+
+final Hasher hasher = builder.with("Hello").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+}
+
+/**
+ * Tests that bits from multiple hashes are returned correctly.
+ */
+@Test
+public void testGetBits_MultipleHashes() {
+final int[] expected = { 6, 69, 44, 19, 10, 57, 48, 23, 70, 61, 36, 
11, 2, 49, 24, 15, 62, 1, 63, 53, 43, 17, 7,
+69, 59, 49, 39, 13, 3, 65, 55, 45, 35, 25 };
+
+final Hasher hasher = builder.with("Hello").with("World").build();
+
+final OfInt iter = hasher.getBits(shape);
+
+for (final int element : expected) {
+assertTrue(iter.hasNext());
+assertEquals(element, iter.nextInt());
+}
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSuchElementException ignore) {
+// do nothing
+}
+}
+
+/**
+ * Tests that retrieving bits for the wrong shape throws an exception.
+ */
+@Test
+public void testGetBits_WongShape() {
+
+final Hasher hasher = builder.with("Hello").build();
+
+try {
+hasher.getBits(new Shape(testFunction, 3, 72, 17));
+fail("Should have thown IllegalArgumentException");
+} catch (final IllegalArgumentException expected) {
+// do nothing
+}
+}
+
+/**
+ * Tests if isEmpty() reports correctly and the iterator returns no values.
+ */
+@Test
+public void testIsEmpty() {
+CachingHasher hasher = builder.build();
+assertTrue(hasher.isEmpty());
+final OfInt iter = hasher.getBits(shape);
+assertFalse(iter.hasNext());
+try {
+iter.next();
+fail("Should have thown NoSuchElementException");
+} catch (final NoSu

[jira] [Work logged] (CODEC-285) Upgrade to JUnit v5.6.0

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/CODEC-285?focusedWorklogId=397363&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397363
 ]

ASF GitHub Bot logged work on CODEC-285:


Author: ASF GitHub Bot
Created on: 04/Mar/20 08:49
Start Date: 04/Mar/20 08:49
Worklog Time Spent: 10m 
  Work Description: nhojpatrick commented on pull request #43: CODEC-285 
Base32InputStreamTest testReadOutOfBounds
URL: https://github.com/apache/commons-codec/pull/43
 
 
   Follow up for PR https://github.com/apache/commons-codec/pull/39
   
   From experience people write tests that don't check exceptions correctly, 
either they are not thrown, or a different than expected line throws that 
exception, or it's the wrong exception, or wrong message.
   
   Using assertAll and assertThrows to explicitly check the expected line 
throws the expected exception, and all done in parallel not sequentially.
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 397363)
Remaining Estimate: 0h
Time Spent: 10m

> Upgrade to JUnit v5.6.0
> ---
>
> Key: CODEC-285
> URL: https://issues.apache.org/jira/browse/CODEC-285
> Project: Commons Codec
>  Issue Type: Improvement
>Reporter: John Patrick
>Priority: Major
>  Labels: pull-request-available
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> As Per Email 2020/03/01 11:07, "Java Modules Codec, Collections, IO and 
> Lang", and 
> https://github.com/apache/commons-collections/blob/master/CONTRIBUTING.md.
> Step 3, update to junit v5.6 (jupiter and vintage)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-codec] nhojpatrick opened a new pull request #43: CODEC-285 Base32InputStreamTest testReadOutOfBounds

2020-03-04 Thread GitBox
nhojpatrick opened a new pull request #43: CODEC-285 Base32InputStreamTest 
testReadOutOfBounds
URL: https://github.com/apache/commons-codec/pull/43
 
 
   Follow up for PR https://github.com/apache/commons-codec/pull/39
   
   From experience people write tests that don't check exceptions correctly, 
either they are not thrown, or a different than expected line throws that 
exception, or it's the wrong exception, or wrong message.
   
   Using assertAll and assertThrows to explicitly check the expected line 
throws the expected exception, and all done in parallel not sequentially.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-codec] coveralls commented on issue #43: CODEC-285 Base32InputStreamTest testReadOutOfBounds

2020-03-04 Thread GitBox
coveralls commented on issue #43: CODEC-285 Base32InputStreamTest 
testReadOutOfBounds
URL: https://github.com/apache/commons-codec/pull/43#issuecomment-594402309
 
 
   
   [![Coverage 
Status](https://coveralls.io/builds/29118864/badge)](https://coveralls.io/builds/29118864)
   
   Coverage remained the same at 93.84% when pulling 
**8fb8d750767a2d29fd91230f986b6b991168b9b0 on 
nhojpatrick:CODEC-285_Base32InputStreamTest_testReadOutOfBounds** into 
**126f90424cc8f62d928686ec20c6c8bd944b527b on apache: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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Created] (CONFIGURATION-782) OverrideCombiner does not work properly when key contains list

2020-03-04 Thread Gisle Grimen (Jira)
Gisle Grimen created CONFIGURATION-782:
--

 Summary: OverrideCombiner does not work properly when key contains 
list
 Key: CONFIGURATION-782
 URL: https://issues.apache.org/jira/browse/CONFIGURATION-782
 Project: Commons Configuration
  Issue Type: Bug
  Components: Format
Reporter: Gisle Grimen


It seems that the OverrideCombiner does not work properly in some cases when 
key contains a list. The problem is best illustrated with an example:

 

In your Base Config File you following key values:

idp.auth.methods = NO-BANKID, NO-BANKID-MOBILE

And in our Specialty configuration, the one that overrides duplicates in the 
base config file contains following key:

idp.auth.methods.1443 = SE-BANKID, SE-BANKID-MOBILE

 

The expected result after combining these two configuration files would be:

 

idp.auth.methods = NO-BANKID, NO-BANKID-MOBILE

idp.auth.methods.1443 = SE-BANKID, SE-BANKID-MOBILE

 

However the actual result of current implementation is as follows:

idp.auth.methods.1443 = SE-BANKID, SE-BANKID-MOBILE

 

So even though that the config file that overrides the base configuration file 
does not have any overriding configuration for idp.auth.methods. The config in 
the base config connected to key idp.autyh.methods are not added to the 
combined configuration.

 

If this is not a bug but a feature, then i would like to know which combiner i 
should use as it is not obvious from the documentation. The objective is to be 
able to have one file that contains extra configuration which also can include 
configuration keys that should override configuration keys from the base 
configuration file.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (JEXL-328) JXLT template scripts evaluation do not process pragmas

2020-03-04 Thread Henri Biestro (Jira)
Henri Biestro created JEXL-328:
--

 Summary: JXLT template scripts evaluation do not process pragmas
 Key: JEXL-328
 URL: https://issues.apache.org/jira/browse/JEXL-328
 Project: Commons JEXL
  Issue Type: Bug
Affects Versions: 3.1
Reporter: Henri Biestro
Assignee: Henri Biestro
 Fix For: 3.2


If a template defines a pragma, it is never processed.
The same code in a JEXL script gets its pragma processed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1523) Avoid unnecessary allocation in StringUtils.wrapIfMissing

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1523?focusedWorklogId=397497&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397497
 ]

ASF GitHub Bot logged work on LANG-1523:


Author: ASF GitHub Bot
Created on: 04/Mar/20 11:04
Start Date: 04/Mar/20 11:04
Worklog Time Spent: 10m 
  Work Description: nstdio commented on pull request #496: LANG-1523: Avoid 
unnecessary allocation in StringUtils.wrapIfMissing.
URL: https://github.com/apache/commons-lang/pull/496#discussion_r387595656
 
 

 ##
 File path: src/main/java/org/apache/commons/lang3/StringUtils.java
 ##
 @@ -9508,20 +9514,27 @@ public static String wrapIfMissing(final String str, 
final char wrapWith) {
  * @param str
  *the string to be wrapped, may be {@code null}
  * @param wrapWith
- *the char that will wrap {@code str}
+ *the string that will wrap {@code str}
  * @return the wrapped string, or {@code null} if {@code str==null}
  * @since 3.5
  */
 public static String wrapIfMissing(final String str, final String 
wrapWith) {
 if (isEmpty(str) || isEmpty(wrapWith)) {
 return str;
 }
+
+final boolean wrapStart = !str.startsWith(wrapWith);
+final boolean wrapEnd = !str.endsWith(wrapWith);
+if (!wrapStart && !wrapEnd) {
+return str;
+}
+
 final StringBuilder builder = new StringBuilder(str.length() + 
wrapWith.length() + wrapWith.length());
 
 Review comment:
   @garydgregory Sure, that makes sense. Done.
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 397497)
Time Spent: 0.5h  (was: 20m)

> Avoid unnecessary allocation in StringUtils.wrapIfMissing
> -
>
> Key: LANG-1523
> URL: https://issues.apache.org/jira/browse/LANG-1523
> Project: Commons Lang
>  Issue Type: Improvement
>  Components: lang.*
>Affects Versions: 3.9
>Reporter: Edgar Asatryan
>Priority: Major
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The *StringUtils.wrapIfMissing* creates a new instance of *StringBuilder* 
> regardless of whether the input is wrapped or not.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-lang] nstdio commented on a change in pull request #496: LANG-1523: Avoid unnecessary allocation in StringUtils.wrapIfMissing.

2020-03-04 Thread GitBox
nstdio commented on a change in pull request #496: LANG-1523: Avoid unnecessary 
allocation in StringUtils.wrapIfMissing.
URL: https://github.com/apache/commons-lang/pull/496#discussion_r387595656
 
 

 ##
 File path: src/main/java/org/apache/commons/lang3/StringUtils.java
 ##
 @@ -9508,20 +9514,27 @@ public static String wrapIfMissing(final String str, 
final char wrapWith) {
  * @param str
  *the string to be wrapped, may be {@code null}
  * @param wrapWith
- *the char that will wrap {@code str}
+ *the string that will wrap {@code str}
  * @return the wrapped string, or {@code null} if {@code str==null}
  * @since 3.5
  */
 public static String wrapIfMissing(final String str, final String 
wrapWith) {
 if (isEmpty(str) || isEmpty(wrapWith)) {
 return str;
 }
+
+final boolean wrapStart = !str.startsWith(wrapWith);
+final boolean wrapEnd = !str.endsWith(wrapWith);
+if (!wrapStart && !wrapEnd) {
+return str;
+}
+
 final StringBuilder builder = new StringBuilder(str.length() + 
wrapWith.length() + wrapWith.length());
 
 Review comment:
   @garydgregory Sure, that makes sense. Done.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Commented] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-04 Thread Kleyson Rios (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051131#comment-17051131
 ] 

Kleyson Rios commented on BSF-45:
-

[~b.eckenfels] your suggestion worked fine.

Should I keep this as a issue ?

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-04 Thread Kleyson Rios (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051131#comment-17051131
 ] 

Kleyson Rios edited comment on BSF-45 at 3/4/20, 11:48 AM:
---

[~b.eckenfels] your suggestion worked fine.

Should I keep this as an issue ?


was (Author: kleysonr):
[~b.eckenfels] your suggestion worked fine.

Should I keep this as a issue ?

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-04 Thread Bernd Eckenfels (Jira)


[ 
https://issues.apache.org/jira/browse/BSF-45?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051134#comment-17051134
 ] 

Bernd Eckenfels commented on BSF-45:


hm, strangely i cant edit this issue. I would close it, since the beanshell 
syntax is nothing BSF itself can/wants to change. Thanks for responding, 
Kleyson, if you can close it as invalid that would be fine.

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Resolved] (BSF-45) Error trying to access a MongoDB collection under Apache BSF script

2020-03-04 Thread Sebb (Jira)


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

Sebb resolved BSF-45.
-
Resolution: Information Provided

> Error trying to access a MongoDB collection under Apache BSF script
> ---
>
> Key: BSF-45
> URL: https://issues.apache.org/jira/browse/BSF-45
> Project: Commons BSF
>  Issue Type: Bug
>  Components: BSF-2.x
>Affects Versions: BSF-2.4
> Environment: Java 8
> BSF 2.4.0
>Reporter: Kleyson Rios
>Priority: Major
> Attachments: exception.txt
>
>
> I'm trying to access a MongoDB collection from a java code to be 'eval' by 
> BSF.
> I tried configure the MongoDB connection in both ways coding the driver 
> connection and following the tutorial 
> [https://mongodb.github.io/mongo-java-driver/3.10/driver/tutorials/jndi/] , 
> but in both cases the same error.
> Below the code to be executed by BSF:
>  
> {code:java}
> import javax.naming.InitialContext;
> import com.mongodb.MongoClient;
> import com.mongodb.client.MongoDatabase;
> import com.mongodb.client.MongoCollection;
> import org.bson.Document;
> InitialContext cxt = new InitialContext();
> if ( cxt == null ) {
>    throw new Exception("Uh oh -- no context!");
> }
> MongoClient ds = (MongoClient) cxt.lookup( 
> "java:/comp/env/mongodb/MongoClient" );
> if ( ds == null ) {
>    throw new Exception("Data source not found!");
> }
> MongoDatabase database = ds.getDatabase("ssp");
> //MongoCollection collection = database.getCollection("customer");
> {code}
>  
> The code above runs fine, but If I uncomment the last line 
> *MongoCollection collection = database.getCollection("customer")* , 
> the BSF throw a exception. See the attached *exception.txt* file.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (LANG-1523) Avoid unnecessary allocation in StringUtils.wrapIfMissing

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/LANG-1523?focusedWorklogId=397609&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397609
 ]

ASF GitHub Bot logged work on LANG-1523:


Author: ASF GitHub Bot
Created on: 04/Mar/20 14:11
Start Date: 04/Mar/20 14:11
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #496: LANG-1523: 
Avoid unnecessary allocation in StringUtils.wrapIfMissing.
URL: https://github.com/apache/commons-lang/pull/496
 
 
   
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 397609)
Time Spent: 40m  (was: 0.5h)

> Avoid unnecessary allocation in StringUtils.wrapIfMissing
> -
>
> Key: LANG-1523
> URL: https://issues.apache.org/jira/browse/LANG-1523
> Project: Commons Lang
>  Issue Type: Improvement
>  Components: lang.*
>Affects Versions: 3.9
>Reporter: Edgar Asatryan
>Priority: Major
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> The *StringUtils.wrapIfMissing* creates a new instance of *StringBuilder* 
> regardless of whether the input is wrapped or not.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-lang] garydgregory merged pull request #496: LANG-1523: Avoid unnecessary allocation in StringUtils.wrapIfMissing.

2020-03-04 Thread GitBox
garydgregory merged pull request #496: LANG-1523: Avoid unnecessary allocation 
in StringUtils.wrapIfMissing.
URL: https://github.com/apache/commons-lang/pull/496
 
 
   


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Resolved] (JEXL-328) JXLT template scripts evaluation do not process pragmas

2020-03-04 Thread Henri Biestro (Jira)


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

Henri Biestro resolved JEXL-328.

Resolution: Fixed

Changeset: 8e4f41de2f8407bc3b9e42bbbac7749944c1d538
Author:henrib 
Date:  2020-03-04 17:44
Message:   JEXL-328: ensure creation of options before evaluation do call 
pragma processing, added tests

> JXLT template scripts evaluation do not process pragmas
> ---
>
> Key: JEXL-328
> URL: https://issues.apache.org/jira/browse/JEXL-328
> Project: Commons JEXL
>  Issue Type: Bug
>Affects Versions: 3.1
>Reporter: Henri Biestro
>Assignee: Henri Biestro
>Priority: Minor
> Fix For: 3.2
>
>
> If a template defines a pragma, it is never processed.
> The same code in a JEXL script gets its pragma processed.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (BEANUTILS-533) If expression contains ")", DefaultResolver #getKey return wrong value

2020-03-04 Thread Melloware (Jira)


[ 
https://issues.apache.org/jira/browse/BEANUTILS-533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051623#comment-17051623
 ] 

Melloware commented on BEANUTILS-533:
-

Care to submit a PR on the GitHub page fixing the issue with unit tests?

> If expression contains ")", DefaultResolver #getKey return wrong value
> --
>
> Key: BEANUTILS-533
> URL: https://issues.apache.org/jira/browse/BEANUTILS-533
> Project: Commons BeanUtils
>  Issue Type: Bug
>  Components: Bean / Property Utils
>Affects Versions: 1.7.0, 1.8.0, 1.9.0, 1.9.3
>Reporter: Maxime Garenne
>Priority: Blocker
>
> h2. Context
> I use BeanUtils to return a map that contain properties.
> I had a failure in my code because this property causes a fail in the 
> BeanUtils "getMappedProperty" method :
> test(myvalue(ineedthisparenthis))
> h2. Explanation
> In DefaultResolver #getKey(String expression), if the expression contains a 
> ")", the returned value is incorrect because the algorithm stops at the first 
> ")" character (#indefOf is used).
> In my example, the method now returns : "myvalue(ineedthisparenthis". It 
> should be "myvalue(ineedthisparenthis) with proprerty name = "test".
> Instead of using :
> {code:java}
> final int end = expression.indexOf(MAPPED_END, i);{code}
> It would be better to just check if the last character of "expression" is a 
> ")" and then substring between "i+1" and last character index.
> Then my example would not fail. 
>  
> This occurs in version 1.7.
> I checked in upper versions, the method is different but still wrong because 
> the method indexOf is still used (taking again the first ")" found). 
>  # escape # parenthesis # bracket # DefaultResolver # getKey # expression
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (BEANUTILS-533) If expression contains ")", DefaultResolver #getKey return wrong value

2020-03-04 Thread Melloware (Jira)


[ 
https://issues.apache.org/jira/browse/BEANUTILS-533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051629#comment-17051629
 ] 

Melloware commented on BEANUTILS-533:
-

I just updated the DefaultResolverTestCase unit test with you new property 
values against the code in MASTER and its working fine.

{code:java}
// Mapped Properties Test Data
private final String[] validMapProperties = new String[] {"a(b)", "c(de)", 
"fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1], 
test(myvalue(ineedthisparenthis))"};
private final String[] validMapNames  = new String[] {"a","c", 
"fg","ij", "mno","tuv", "test"};
private final String[] validMapKeys   = new String[] {"b","de",
"h", "kl", "pqr.s",  "wx",  "myvalue(ineedthisparenthis)"};
{code}

> If expression contains ")", DefaultResolver #getKey return wrong value
> --
>
> Key: BEANUTILS-533
> URL: https://issues.apache.org/jira/browse/BEANUTILS-533
> Project: Commons BeanUtils
>  Issue Type: Bug
>  Components: Bean / Property Utils
>Affects Versions: 1.7.0, 1.8.0, 1.9.0, 1.9.3
>Reporter: Maxime Garenne
>Priority: Blocker
>
> h2. Context
> I use BeanUtils to return a map that contain properties.
> I had a failure in my code because this property causes a fail in the 
> BeanUtils "getMappedProperty" method :
> test(myvalue(ineedthisparenthis))
> h2. Explanation
> In DefaultResolver #getKey(String expression), if the expression contains a 
> ")", the returned value is incorrect because the algorithm stops at the first 
> ")" character (#indefOf is used).
> In my example, the method now returns : "myvalue(ineedthisparenthis". It 
> should be "myvalue(ineedthisparenthis) with proprerty name = "test".
> Instead of using :
> {code:java}
> final int end = expression.indexOf(MAPPED_END, i);{code}
> It would be better to just check if the last character of "expression" is a 
> ")" and then substring between "i+1" and last character index.
> Then my example would not fail. 
>  
> This occurs in version 1.7.
> I checked in upper versions, the method is different but still wrong because 
> the method indexOf is still used (taking again the first ")" found). 
>  # escape # parenthesis # bracket # DefaultResolver # getKey # expression
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (BEANUTILS-533) If expression contains ")", DefaultResolver #getKey return wrong value

2020-03-04 Thread Melloware (Jira)


[ 
https://issues.apache.org/jira/browse/BEANUTILS-533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051629#comment-17051629
 ] 

Melloware edited comment on BEANUTILS-533 at 3/4/20, 9:07 PM:
--

I just updated the DefaultResolverTestCase unit test with you new property 
values against the code in MASTER and its working fine.

{code:java}
// Mapped Properties Test Data
private final String[] validMapProperties = new String[] {"a(b)", "c(de)", 
"fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1], 
test(myvalue(ineedthisparenthis))"};
private final String[] validMapNames  = new String[] {"a","c", 
"fg","ij", "mno","tuv", "test"};
private final String[] validMapKeys   = new String[] {"b","de","h", 
"kl", "pqr.s",  "wx",  "myvalue(ineedthisparenthis)"};
{code}


was (Author: melloware):
I just updated the DefaultResolverTestCase unit test with you new property 
values against the code in MASTER and its working fine.

{code:java}
// Mapped Properties Test Data
private final String[] validMapProperties = new String[] {"a(b)", "c(de)", 
"fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1], 
test(myvalue(ineedthisparenthis))"};
private final String[] validMapNames  = new String[] {"a","c", 
"fg","ij", "mno","tuv", "test"};
private final String[] validMapKeys   = new String[] {"b","de",
"h", "kl", "pqr.s",  "wx",  "myvalue(ineedthisparenthis)"};
{code}

> If expression contains ")", DefaultResolver #getKey return wrong value
> --
>
> Key: BEANUTILS-533
> URL: https://issues.apache.org/jira/browse/BEANUTILS-533
> Project: Commons BeanUtils
>  Issue Type: Bug
>  Components: Bean / Property Utils
>Affects Versions: 1.7.0, 1.8.0, 1.9.0, 1.9.3
>Reporter: Maxime Garenne
>Priority: Blocker
>
> h2. Context
> I use BeanUtils to return a map that contain properties.
> I had a failure in my code because this property causes a fail in the 
> BeanUtils "getMappedProperty" method :
> test(myvalue(ineedthisparenthis))
> h2. Explanation
> In DefaultResolver #getKey(String expression), if the expression contains a 
> ")", the returned value is incorrect because the algorithm stops at the first 
> ")" character (#indefOf is used).
> In my example, the method now returns : "myvalue(ineedthisparenthis". It 
> should be "myvalue(ineedthisparenthis) with proprerty name = "test".
> Instead of using :
> {code:java}
> final int end = expression.indexOf(MAPPED_END, i);{code}
> It would be better to just check if the last character of "expression" is a 
> ")" and then substring between "i+1" and last character index.
> Then my example would not fail. 
>  
> This occurs in version 1.7.
> I checked in upper versions, the method is different but still wrong because 
> the method indexOf is still used (taking again the first ")" found). 
>  # escape # parenthesis # bracket # DefaultResolver # getKey # expression
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (BEANUTILS-533) If expression contains ")", DefaultResolver #getKey return wrong value

2020-03-04 Thread Melloware (Jira)


[ 
https://issues.apache.org/jira/browse/BEANUTILS-533?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051629#comment-17051629
 ] 

Melloware edited comment on BEANUTILS-533 at 3/4/20, 9:09 PM:
--

I just updated the DefaultResolverTestCase unit test with your new property 
values and verified your issue.

{code:java}
// Mapped Properties Test Data
private final String[] validMapProperties = new String[] {"a(b)", "c(de)", 
"fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1]", 
"test(myvalue(ineedthisparenthis))"};
private final String[] validMapNames  = new String[] {"a","c", 
"fg","ij", "mno","tuv", "test"};
private final String[] validMapKeys   = new String[] {"b","de","h", 
"kl", "pqr.s",  "wx",  "myvalue(ineedthisparenthis)"};
{code}


was (Author: melloware):
I just updated the DefaultResolverTestCase unit test with you new property 
values against the code in MASTER and its working fine.

{code:java}
// Mapped Properties Test Data
private final String[] validMapProperties = new String[] {"a(b)", "c(de)", 
"fg(h)", "ij(kl)", "mno(pqr.s)", "tuv(wx).yz[1], 
test(myvalue(ineedthisparenthis))"};
private final String[] validMapNames  = new String[] {"a","c", 
"fg","ij", "mno","tuv", "test"};
private final String[] validMapKeys   = new String[] {"b","de","h", 
"kl", "pqr.s",  "wx",  "myvalue(ineedthisparenthis)"};
{code}

> If expression contains ")", DefaultResolver #getKey return wrong value
> --
>
> Key: BEANUTILS-533
> URL: https://issues.apache.org/jira/browse/BEANUTILS-533
> Project: Commons BeanUtils
>  Issue Type: Bug
>  Components: Bean / Property Utils
>Affects Versions: 1.7.0, 1.8.0, 1.9.0, 1.9.3
>Reporter: Maxime Garenne
>Priority: Blocker
>
> h2. Context
> I use BeanUtils to return a map that contain properties.
> I had a failure in my code because this property causes a fail in the 
> BeanUtils "getMappedProperty" method :
> test(myvalue(ineedthisparenthis))
> h2. Explanation
> In DefaultResolver #getKey(String expression), if the expression contains a 
> ")", the returned value is incorrect because the algorithm stops at the first 
> ")" character (#indefOf is used).
> In my example, the method now returns : "myvalue(ineedthisparenthis". It 
> should be "myvalue(ineedthisparenthis) with proprerty name = "test".
> Instead of using :
> {code:java}
> final int end = expression.indexOf(MAPPED_END, i);{code}
> It would be better to just check if the last character of "expression" is a 
> ")" and then substring between "i+1" and last character index.
> Then my example would not fail. 
>  
> This occurs in version 1.7.
> I checked in upper versions, the method is different but still wrong because 
> the method indexOf is still used (taking again the first ")" found). 
>  # escape # parenthesis # bracket # DefaultResolver # getKey # expression
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread Frank Gasdorf (Jira)
Frank Gasdorf created DBCP-562:
--

 Summary: Password should not be exposed via JMXBean
 Key: DBCP-562
 URL: https://issues.apache.org/jira/browse/DBCP-562
 Project: Commons DBCP
  Issue Type: Bug
Affects Versions: 2.7.0, 2.5.0
Reporter: Frank Gasdorf


if a BasicDataSource is created with jmxName set, password property is 
exposed/exported via jmx and is visible for everybody who is connected to jmx 
port.

 

Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Updated] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread Frank Gasdorf (Jira)


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

Frank Gasdorf updated DBCP-562:
---
Labels: security  (was: )

> Password should not be exposed via JMXBean
> --
>
> Key: DBCP-562
> URL: https://issues.apache.org/jira/browse/DBCP-562
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.5.0, 2.7.0
>Reporter: Frank Gasdorf
>Priority: Critical
>  Labels: security
>
> if a BasicDataSource is created with jmxName set, password property is 
> exposed/exported via jmx and is visible for everybody who is connected to jmx 
> port.
>  
> Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread Gary D. Gregory (Jira)


[ 
https://issues.apache.org/jira/browse/DBCP-562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051656#comment-17051656
 ] 

Gary D. Gregory commented on DBCP-562:
--

Hi [~fgdrf]

Feel-free to provide a patch on GitHub (which does not break binary 
compatibility.)

 

> Password should not be exposed via JMXBean
> --
>
> Key: DBCP-562
> URL: https://issues.apache.org/jira/browse/DBCP-562
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.5.0, 2.7.0
>Reporter: Frank Gasdorf
>Priority: Critical
>  Labels: security
>
> if a BasicDataSource is created with jmxName set, password property is 
> exposed/exported via jmx and is visible for everybody who is connected to jmx 
> port.
>  
> Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-dbcp] fgdrf opened a new pull request #38: [DBCP-562] avoids exposing password via JMX

2020-03-04 Thread GitBox
fgdrf opened a new pull request #38: [DBCP-562] avoids exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38
 
 
   for see details see https://issues.apache.org/jira/browse/DBCP-562
   
   Signed-off-by: Frank Gasdorf 


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Work logged] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-562?focusedWorklogId=397915&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397915
 ]

ASF GitHub Bot logged work on DBCP-562:
---

Author: ASF GitHub Bot
Created on: 04/Mar/20 22:07
Start Date: 04/Mar/20 22:07
Worklog Time Spent: 10m 
  Work Description: fgdrf commented on pull request #38: [DBCP-562] avoids 
exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38
 
 
   for see details see https://issues.apache.org/jira/browse/DBCP-562
   
   Signed-off-by: Frank Gasdorf 
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 397915)
Remaining Estimate: 0h
Time Spent: 10m

> Password should not be exposed via JMXBean
> --
>
> Key: DBCP-562
> URL: https://issues.apache.org/jira/browse/DBCP-562
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.5.0, 2.7.0
>Reporter: Frank Gasdorf
>Priority: Critical
>  Labels: security
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> if a BasicDataSource is created with jmxName set, password property is 
> exposed/exported via jmx and is visible for everybody who is connected to jmx 
> port.
>  
> Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Work logged] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-562?focusedWorklogId=397917&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397917
 ]

ASF GitHub Bot logged work on DBCP-562:
---

Author: ASF GitHub Bot
Created on: 04/Mar/20 22:09
Start Date: 04/Mar/20 22:09
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on pull request #38: [DBCP-562] 
avoids exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38#discussion_r387964778
 
 

 ##
 File path: src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
 ##
 @@ -201,13 +201,6 @@ default String getDefaultSchema() {
  */
 int getNumIdle();
 
-/**
 
 Review comment:
   -1: You cannot break binary compatibility, as I mentioned on the mailing 
list already.
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 397917)
Time Spent: 20m  (was: 10m)

> Password should not be exposed via JMXBean
> --
>
> Key: DBCP-562
> URL: https://issues.apache.org/jira/browse/DBCP-562
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.5.0, 2.7.0
>Reporter: Frank Gasdorf
>Priority: Critical
>  Labels: security
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> if a BasicDataSource is created with jmxName set, password property is 
> exposed/exported via jmx and is visible for everybody who is connected to jmx 
> port.
>  
> Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-dbcp] garydgregory commented on a change in pull request #38: [DBCP-562] avoids exposing password via JMX

2020-03-04 Thread GitBox
garydgregory commented on a change in pull request #38: [DBCP-562] avoids 
exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38#discussion_r387964778
 
 

 ##
 File path: src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
 ##
 @@ -201,13 +201,6 @@ default String getDefaultSchema() {
  */
 int getNumIdle();
 
-/**
 
 Review comment:
   -1: You cannot break binary compatibility, as I mentioned on the mailing 
list already.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [commons-dbcp] fgdrf commented on a change in pull request #38: [DBCP-562] avoids exposing password via JMX

2020-03-04 Thread GitBox
fgdrf commented on a change in pull request #38: [DBCP-562] avoids exposing 
password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38#discussion_r387979387
 
 

 ##
 File path: src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
 ##
 @@ -201,13 +201,6 @@ default String getDefaultSchema() {
  */
 int getNumIdle();
 
-/**
 
 Review comment:
   @garydgregory Thanks for your fast feedback, I'll investigate if its 
possible to "filter" by attribute while register MBean. Since the method was 
public its exported. Any suggestions?


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Work logged] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-562?focusedWorklogId=397937&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-397937
 ]

ASF GitHub Bot logged work on DBCP-562:
---

Author: ASF GitHub Bot
Created on: 04/Mar/20 22:44
Start Date: 04/Mar/20 22:44
Worklog Time Spent: 10m 
  Work Description: fgdrf commented on pull request #38: [DBCP-562] avoids 
exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38#discussion_r387979387
 
 

 ##
 File path: src/main/java/org/apache/commons/dbcp2/BasicDataSourceMXBean.java
 ##
 @@ -201,13 +201,6 @@ default String getDefaultSchema() {
  */
 int getNumIdle();
 
-/**
 
 Review comment:
   @garydgregory Thanks for your fast feedback, I'll investigate if its 
possible to "filter" by attribute while register MBean. Since the method was 
public its exported. Any suggestions?
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 397937)
Time Spent: 0.5h  (was: 20m)

> Password should not be exposed via JMXBean
> --
>
> Key: DBCP-562
> URL: https://issues.apache.org/jira/browse/DBCP-562
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.5.0, 2.7.0
>Reporter: Frank Gasdorf
>Priority: Critical
>  Labels: security
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> if a BasicDataSource is created with jmxName set, password property is 
> exposed/exported via jmx and is visible for everybody who is connected to jmx 
> port.
>  
> Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-dbcp] garydgregory commented on issue #38: [DBCP-562] avoids exposing password via JMX

2020-03-04 Thread GitBox
garydgregory commented on issue #38: [DBCP-562] avoids exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38#issuecomment-594991633
 
 
   Well, since we cannot get rid of the method within a major release, we need 
to workaround that by perhaps making it return always null but only when 
publishing an implementation as a JMX object, which might mean creating a 
wrapper class that delegates all methods except getPassword().


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Work logged] (DBCP-562) Password should not be exposed via JMXBean

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/DBCP-562?focusedWorklogId=398074&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-398074
 ]

ASF GitHub Bot logged work on DBCP-562:
---

Author: ASF GitHub Bot
Created on: 05/Mar/20 02:14
Start Date: 05/Mar/20 02:14
Worklog Time Spent: 10m 
  Work Description: garydgregory commented on issue #38: [DBCP-562] avoids 
exposing password via JMX
URL: https://github.com/apache/commons-dbcp/pull/38#issuecomment-594991633
 
 
   Well, since we cannot get rid of the method within a major release, we need 
to workaround that by perhaps making it return always null but only when 
publishing an implementation as a JMX object, which might mean creating a 
wrapper class that delegates all methods except getPassword().
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 398074)
Time Spent: 40m  (was: 0.5h)

> Password should not be exposed via JMXBean
> --
>
> Key: DBCP-562
> URL: https://issues.apache.org/jira/browse/DBCP-562
> Project: Commons DBCP
>  Issue Type: Bug
>Affects Versions: 2.5.0, 2.7.0
>Reporter: Frank Gasdorf
>Priority: Critical
>  Labels: security
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> if a BasicDataSource is created with jmxName set, password property is 
> exposed/exported via jmx and is visible for everybody who is connected to jmx 
> port.
>  
> Expectation : Do not export it via BasicDataSourceMXBean Interface



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-lang] Isira-Seneviratne opened a new pull request #501: Expand Streams functionality.

2020-03-04 Thread GitBox
Isira-Seneviratne opened a new pull request #501: Expand Streams functionality.
URL: https://github.com/apache/commons-lang/pull/501
 
 
   Add failable streams, map and flatMap operations for primitive types and 
move streams and functional interfaces to org.apache.commons.lang3.stream and 
org.apache.commons.lang3.function, respectively.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Work logged] (COMPRESS-505) Multiple Reads of One SevenZArchiveEntry Fails

2020-03-04 Thread ASF GitHub Bot (Jira)


 [ 
https://issues.apache.org/jira/browse/COMPRESS-505?focusedWorklogId=398179&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-398179
 ]

ASF GitHub Bot logged work on COMPRESS-505:
---

Author: ASF GitHub Bot
Created on: 05/Mar/20 07:37
Start Date: 05/Mar/20 07:37
Worklog Time Spent: 10m 
  Work Description: PeterAlfreadLee commented on pull request #95: 
COMPRESS-505 : bug fix for random access of 7z
URL: https://github.com/apache/commons-compress/pull/95
 
 
   There are some problems in my PR about random access of 7z 
[#83](COMPRESS-342 random access of 7z files) :
   
   1. I was thinking that the `currentFolderInputStream` can be repositioned by 
changing the position of the `channel`, which turns out to be impossible. This 
PR fixesit by reopening the `currentFolderInputStream`.
   
   2. There are 2 ways to access the content of a 7z archive now : by 
sequential access(getNextEntry) and by random access(getInputStream). They may 
be used one after another. So there're some conditions we need to deal with :
   
   2.1 In a random access, if `currentEntryIndex` == `entryIndex` && the entry 
has not been read yet :
   This means the input stream of the entry we want has already been put in the 
`deferredBlockStreams` as the last array member. We SHOULD NOT build a new 
input stream for the entry again, because this will make same the existed 
stream in `deferredBlockStreams` be skipped. We should just do nothing cause 
the input stream is already in the `deferredBlockStreams`.
   
   2.2 In a random access, if `currentEntryIndex` == `entryIndex` && the entry 
has already been read :
   This means the entry we want has been read(maybe some of entry or all of the 
entry has been read, it does not matter). Then we should reopen the 
`currentFolderInputStream` and skip all the entries before the entry we want.
   BTW : we could determine if the file has been read or not by comparing the 
`bytesRemaining` of the input stream(as a `CRC32VerifyingInputStream`) and the 
actual size of the file.
   
   2.3 In a random access, if `currentEntryIndex` < `entryIndex` && the last 
entry in `deferredBlockStreams` has not been read :
   The input streams whose index equals or less than `currentEntryIndex` has 
already been put into the 
   `deferredBlockStreams`. We could just add the remaining entries to the 
`deferredBlockStreams`.
   
   2.4 In a random access, if `currentEntryIndex` < `entryIndex` && the last 
entry in `deferredBlockStreams` has already been read :
   Like 2.2, we have no other choices but reopen the `currentFolderInputStream` 
and skip all the entries again.
   
   2.5 In a random access, if `currentEntryIndex` > `entryIndex` :
   This means the entry we want has already been read or skipped beforehand. We 
could only reopen the `currentFolderInputStream` and skip all the entries again.
   
   In short, we should do nothing in 2.1, skip the remaining entries in 2.3, 
and reopen the `currentFolderInputStream` in 2.2/2.4/2.5. I have to admit this 
is a bit complicated, but I didn't find any other better ideas building the 
logic. :(
   
   I made some refactoring and added some new comments to make the code more 
clear. The corresponding testcases are also included in this PR.
 

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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
---

Worklog Id: (was: 398179)
Remaining Estimate: 0h
Time Spent: 10m

> Multiple Reads of One SevenZArchiveEntry Fails
> --
>
> Key: COMPRESS-505
> URL: https://issues.apache.org/jira/browse/COMPRESS-505
> Project: Commons Compress
>  Issue Type: Bug
>Affects Versions: 1.20
>Reporter: Steven Fontaine
>Priority: Minor
> Attachments: CC0 Images.7z
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> I've run into a bug which occurs when attempting to read the same 
> SevenZArchiveEntry stream multiple times. The following code illustrates the 
> problem.
> {code:java}
> File archive = new File("CC0 Images.7z");
> char[] password = "password".toCharArray();
> try (SevenZFile f = new SevenZFile(archive, password))
> {
>   SevenZArchiveEntry entry = 
> StreamSupport.stream(f.getEntries().spliterator(), false)
> .filter(e -> 
> "alberta-amazing-attraction-banff-417074.jpg".equals(e.getName()))
> .findFirst().orElseGet(null);
>   assert entry != null;
>   for (int i = 0; i < 100; i++)
>   {
> InputStream is = f.getInputStream(entry);
> BufferedImage img = ImageIO.read(is);
>

[GitHub] [commons-compress] PeterAlfreadLee opened a new pull request #95: COMPRESS-505 : bug fix for random access of 7z

2020-03-04 Thread GitBox
PeterAlfreadLee opened a new pull request #95: COMPRESS-505 : bug fix for 
random access of 7z
URL: https://github.com/apache/commons-compress/pull/95
 
 
   There are some problems in my PR about random access of 7z 
[#83](COMPRESS-342 random access of 7z files) :
   
   1. I was thinking that the `currentFolderInputStream` can be repositioned by 
changing the position of the `channel`, which turns out to be impossible. This 
PR fixesit by reopening the `currentFolderInputStream`.
   
   2. There are 2 ways to access the content of a 7z archive now : by 
sequential access(getNextEntry) and by random access(getInputStream). They may 
be used one after another. So there're some conditions we need to deal with :
   
   2.1 In a random access, if `currentEntryIndex` == `entryIndex` && the entry 
has not been read yet :
   This means the input stream of the entry we want has already been put in the 
`deferredBlockStreams` as the last array member. We SHOULD NOT build a new 
input stream for the entry again, because this will make same the existed 
stream in `deferredBlockStreams` be skipped. We should just do nothing cause 
the input stream is already in the `deferredBlockStreams`.
   
   2.2 In a random access, if `currentEntryIndex` == `entryIndex` && the entry 
has already been read :
   This means the entry we want has been read(maybe some of entry or all of the 
entry has been read, it does not matter). Then we should reopen the 
`currentFolderInputStream` and skip all the entries before the entry we want.
   BTW : we could determine if the file has been read or not by comparing the 
`bytesRemaining` of the input stream(as a `CRC32VerifyingInputStream`) and the 
actual size of the file.
   
   2.3 In a random access, if `currentEntryIndex` < `entryIndex` && the last 
entry in `deferredBlockStreams` has not been read :
   The input streams whose index equals or less than `currentEntryIndex` has 
already been put into the 
   `deferredBlockStreams`. We could just add the remaining entries to the 
`deferredBlockStreams`.
   
   2.4 In a random access, if `currentEntryIndex` < `entryIndex` && the last 
entry in `deferredBlockStreams` has already been read :
   Like 2.2, we have no other choices but reopen the `currentFolderInputStream` 
and skip all the entries again.
   
   2.5 In a random access, if `currentEntryIndex` > `entryIndex` :
   This means the entry we want has already been read or skipped beforehand. We 
could only reopen the `currentFolderInputStream` and skip all the entries again.
   
   In short, we should do nothing in 2.1, skip the remaining entries in 2.3, 
and reopen the `currentFolderInputStream` in 2.2/2.4/2.5. I have to admit this 
is a bit complicated, but I didn't find any other better ideas building the 
logic. :(
   
   I made some refactoring and added some new comments to make the code more 
clear. The corresponding testcases are also included in this PR.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[jira] [Commented] (COMPRESS-505) Multiple Reads of One SevenZArchiveEntry Fails

2020-03-04 Thread Peter Alfred Lee (Jira)


[ 
https://issues.apache.org/jira/browse/COMPRESS-505?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17051863#comment-17051863
 ] 

Peter Alfred Lee commented on COMPRESS-505:
---

I investigated into the code and realized I made some mistakes in the original 
code. Sorry about my careless. The fix for it has already been pushed with PR 
#95.

I can run the test code in this issue successfully with the new fix.

I believe there would be no exceptions if you do not read a sing file multiple 
time, or you can just using the sequential access(by calling 
SevenZFile.getNextEntry and SevenZFile.read)

But it seems you got to wait another release of commons compress if you really 
need to do this using SevenZFile.getInputStream.

> Multiple Reads of One SevenZArchiveEntry Fails
> --
>
> Key: COMPRESS-505
> URL: https://issues.apache.org/jira/browse/COMPRESS-505
> Project: Commons Compress
>  Issue Type: Bug
>Affects Versions: 1.20
>Reporter: Steven Fontaine
>Priority: Minor
> Attachments: CC0 Images.7z
>
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> I've run into a bug which occurs when attempting to read the same 
> SevenZArchiveEntry stream multiple times. The following code illustrates the 
> problem.
> {code:java}
> File archive = new File("CC0 Images.7z");
> char[] password = "password".toCharArray();
> try (SevenZFile f = new SevenZFile(archive, password))
> {
>   SevenZArchiveEntry entry = 
> StreamSupport.stream(f.getEntries().spliterator(), false)
> .filter(e -> 
> "alberta-amazing-attraction-banff-417074.jpg".equals(e.getName()))
> .findFirst().orElseGet(null);
>   assert entry != null;
>   for (int i = 0; i < 100; i++)
>   {
> InputStream is = f.getInputStream(entry);
> BufferedImage img = ImageIO.read(is);
> assert img != null;
> System.out.println("Succeeded " + (i + 1) + " times");
>   }
> }{code}
> Below is the output I receive on version 1.20
> {code:java}
> Succeeded 1 times
> Succeeded 2 times
> Exception in thread "main" java.io.IOException: Checksum verification failed
> at 
> org.apache.commons.compress.utils.ChecksumVerifyingInputStream.read(ChecksumVerifyingInputStream.java:61)
> at 
> org.apache.commons.compress.utils.ChecksumVerifyingInputStream.skip(ChecksumVerifyingInputStream.java:102)
> at org.apache.commons.compress.utils.IOUtils.skip(IOUtils.java:113)
> at 
> org.apache.commons.compress.archivers.sevenz.SevenZFile.getCurrentStream(SevenZFile.java:1318)
> at 
> org.apache.commons.compress.archivers.sevenz.SevenZFile.getInputStream(SevenZFile.java:1354)
> at org.abitoff.dmav.Test.main(Test.java:11)
> {code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[GitHub] [commons-imaging] kinow opened a new pull request #70: Add tests for ImageInfo

2020-03-04 Thread GitBox
kinow opened a new pull request #70: Add tests for ImageInfo
URL: https://github.com/apache/commons-imaging/pull/70
 
 
   Reviewing this class I think there's a lot that needs changing. The `dump` 
method can probably be removed. The `toString()` could be simplified and also 
defensive against `null` values. But that's for another issue. For the moment, 
just adding tests.


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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services