[jira] [Commented] (POOL-413) [GOP] Race condition while returning objects. maxIdle is ignored

2023-10-04 Thread Phil Steitz (Jira)


[ 
https://issues.apache.org/jira/browse/POOL-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17772042#comment-17772042
 ] 

Phil Steitz commented on POOL-413:
--

One option to consider here is to use the native capacity management capability 
of LinkedBlockingDeque for the final (or other) maxIdle check.  We would not 
want to raise ISE as the public method does, but instead examine the boolean 
returned by LinkFirst/LinkLast  That check is made while holding its internal 
lock so would be fully threadsafe.

> [GOP] Race condition while returning objects. maxIdle is ignored
> 
>
> Key: POOL-413
> URL: https://issues.apache.org/jira/browse/POOL-413
> Project: Commons Pool
>  Issue Type: Bug
>Reporter: Adrien Bernard
>Priority: Major
> Attachments: 
> 0001-Add-test-to-reproduce-concurrency-issue-when-returni.patch
>
>
> In a GenericObjectPool it is possible to configure a maximum number of idle 
> objects to be kept by the pool while they are not in use.
> In unfortunate circumstances, if several threads return an object to the pool 
> at the same time, the check on the maximum number of idle objects may be 
> dismissed. This results in pool keeping more idle objects than configured.
> I have build a unit test to reproduce the issue. I attach it as a patch made 
> on top of release 2.12.0. On my machine it randomly fails with a 10% rate.
> Looking into the source code of the returnObject method of the GOP, it seems 
> that there is no synchronisation between the moment the check is made for the 
> maxIdle configuration and the moment the object is destroyed :
> {code:java}
> final int maxIdleSave = getMaxIdle();
> if (isClosed() || maxIdleSave > -1 && maxIdleSave <= idleObjects.size()) {
> try {
> destroy(p, DestroyMode.NORMAL);
> } catch (final Exception e) {
> swallowException(e);
> }
> try {
> ensureIdle(1, false);
> } catch (final Exception e) {
> swallowException(e);
> }
> } {code}
> Have you thoughts on this ?



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


[jira] [Commented] (POOL-413) [GOP] Race condition while returning objects. maxIdle is ignored

2023-10-04 Thread Phil Steitz (Jira)


[ 
https://issues.apache.org/jira/browse/POOL-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17772023#comment-17772023
 ] 

Phil Steitz commented on POOL-413:
--

Thanks for reporting this.  The analysis looks correct to me.  It is possible 
for the first check to succeed and then another thread returns an instance 
before the first thread adds the instance to the idle pool.   Patches welcome 
for a fix.  One thing to bear in mind: this is a very "hot" method, so we want 
to avoid adding locks / sync if possible.

> [GOP] Race condition while returning objects. maxIdle is ignored
> 
>
> Key: POOL-413
> URL: https://issues.apache.org/jira/browse/POOL-413
> Project: Commons Pool
>  Issue Type: Bug
>Reporter: Adrien Bernard
>Priority: Major
> Attachments: 
> 0001-Add-test-to-reproduce-concurrency-issue-when-returni.patch
>
>
> In a GenericObjectPool it is possible to configure a maximum number of idle 
> objects to be kept by the pool while they are not in use.
> In unfortunate circumstances, if several threads return an object to the pool 
> at the same time, the check on the maximum number of idle objects may be 
> dismissed. This results in pool keeping more idle objects than configured.
> I have build a unit test to reproduce the issue. I attach it as a patch made 
> on top of release 2.12.0. On my machine it randomly fails with a 10% rate.
> Looking into the source code of the returnObject method of the GOP, it seems 
> that there is no synchronisation between the moment the check is made for the 
> maxIdle configuration and the moment the object is destroyed :
> {code:java}
> final int maxIdleSave = getMaxIdle();
> if (isClosed() || maxIdleSave > -1 && maxIdleSave <= idleObjects.size()) {
> try {
> destroy(p, DestroyMode.NORMAL);
> } catch (final Exception e) {
> swallowException(e);
> }
> try {
> ensureIdle(1, false);
> } catch (final Exception e) {
> swallowException(e);
> }
> } {code}
> Have you thoughts on this ?



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


Re: [PR] [IMAGING-339] Basic WebP Support [commons-imaging]

2023-10-04 Thread via GitHub


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

   Well, this is as much as I could get today.
   
   
![image](https://github.com/apache/commons-imaging/assets/304786/d5686342-54d6-4bd2-a4b1-d0edd2f4d8d8)
   
   
![image](https://github.com/apache/commons-imaging/assets/304786/3467fc07-3ffa-466f-959a-a76fc81ad6a0)
   


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

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

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



[jira] [Commented] (IMAGING-319) updateExifMetadataLossless lost the first character of a String

2023-10-04 Thread Sicheng Yang (Jira)


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

Sicheng Yang commented on IMAGING-319:
--

It is glad to see that the bug is fixed. I really appreciate that my effort is 
noticed. You guys debug process also benefits me a lot. Have a nice day!

> updateExifMetadataLossless lost the first character of a String
> ---
>
> Key: IMAGING-319
> URL: https://issues.apache.org/jira/browse/IMAGING-319
> Project: Commons Imaging
>  Issue Type: Bug
>  Components: Format: JPEG
>Affects Versions: 1.0-alpha2
>Reporter: Sicheng Yang
>Assignee: Bruno P. Kinoshita
>Priority: Major
> Attachments: Screen Shot 2021-11-26 at 4.01.06 PM-1.png, Screen Shot 
> 2021-11-26 at 4.01.21 PM-1.png, iPhone12-geotag.JPG
>
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> I try to use TiffOutputSet to generate a new image. However, if a tag that 
> contains String, the program may miss the first character of the String.
>  
> import java.io.*;
> import org.apache.commons.imaging.ImageReadException;
> import org.apache.commons.imaging.ImageWriteException;
> import org.apache.commons.imaging.Imaging;
> import org.apache.commons.imaging.common.ImageMetadata;
> import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
> import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
> import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
> import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
> public class LibraryTest {
>     public static void main(String[] args) throws ImageReadException, 
> IOException, ImageWriteException {
>         File source = new File("./assets/iPhone12-geotag.JPG");
>         File result = new 
> File("./assets/results/editted-iPhone12-geotag.JPG");
>         final ImageMetadata metadata = Imaging.getMetadata(source);
>         final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
>         final TiffImageMetadata exif = jpegMetadata.getExif();
>         TiffOutputSet outputSet = exif.getOutputSet();
>         BufferedOutputStream bufferedOutputStream = new 
> BufferedOutputStream(new FileOutputStream(result));
>         new ExifRewriter().updateExifMetadataLossless(source, 
> bufferedOutputStream, outputSet);
>     }
> }
>  
> This is the sample code.
> Tag value in original image
> !image-2021-11-26-16-01-58-645.png!
> Tag value in output image
> !image-2021-11-26-16-04-12-185.png!



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


Re: [PR] [IMAGING-339] Basic WebP Support [commons-imaging]

2023-10-04 Thread via GitHub


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

   I hope we can get coverage above 90%.


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

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

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



Re: [PR] [IMAGING-339] Basic WebP Support [commons-imaging]

2023-10-04 Thread via GitHub


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


##
src/main/java/org/apache/commons/imaging/formats/webp/chunks/WebPChunkVp8x.java:
##
@@ -42,76 +45,105 @@
  * }
  *
  * @see https://developers.google.com/speed/webp/docs/riff_container#extended_file_format;>Extended
 File Format
- *
  * @since 1.0-alpha4
  */
-public final class WebPChunkVP8X extends WebPChunk {
-private final boolean hasICC;
+public final class WebPChunkVp8x extends WebPChunk {
+private final boolean hasIcc;
 private final boolean hasAlpha;
 private final boolean hasExif;
 private final boolean hasXmp;
-private final boolean isAnimation;
+private final boolean hasAnimation;
 private final int canvasWidth;
 private final int canvasHeight;
 
-public WebPChunkVP8X(int type, int size, byte[] bytes) throws 
ImagingException {
+/**
+ * Create a VP8x chunk.
+ *
+ * @param type  VP8X chunk type
+ * @param size  VP8X chunk size
+ * @param bytes VP8X chunk data
+ * @throws ImagingException if the chunk data and the size provided do not 
match,
+ *  or if the other parameters provided are 
invalid.
+ */
+public WebPChunkVp8x(int type, int size, byte[] bytes) throws 
ImagingException {
 super(type, size, bytes);
 
 if (size != 10) {
 throw new ImagingException("VP8X chunk size must be 10");
 }
 
 int mark = bytes[0] & 0xFF;
-this.hasICC = (mark & 0b0010_) != 0;
+this.hasIcc = (mark & 0b0010_) != 0;
 this.hasAlpha = (mark & 0b0001_) != 0;
 this.hasExif = (mark & 0b_1000) != 0;
 this.hasXmp = (mark & 0b_0100) != 0;
-this.isAnimation = (mark & 0b_0010) != 0;
+this.hasAnimation = (mark & 0b_0010) != 0;
 
-this.canvasWidth = (bytes[4] & 0xFF) + ((bytes[5] & 0xFF) << 8) + 
((bytes[6] & 0xFF) << 16) + 1;
-this.canvasHeight = (bytes[7] & 0xFF) + ((bytes[8] & 0xFF) << 8) + 
((bytes[9] & 0xFF) << 16) + 1;
+this.canvasWidth = SafeOperations.add((bytes[4] & 0xFF), ((bytes[5] & 
0xFF) << 8), ((bytes[6] & 0xFF) << 16), 1);
+this.canvasHeight = SafeOperations.add((bytes[7] & 0xFF), ((bytes[8] & 
0xFF) << 8), ((bytes[9] & 0xFF) << 16), 1);

Review Comment:
   You were right @glavo, reverted the change :+1: 



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

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

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



[jira] [Resolved] (NUMBERS-205) Add isZero() to interface Addition and isOne() to Multiplications

2023-10-04 Thread Alex Herbert (Jira)


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

Alex Herbert resolved NUMBERS-205.
--
Fix Version/s: 1.2
   Resolution: Implemented

Added in commit:

a514149aadea1542c9c4a0367f8ee2247c95

> Add isZero() to interface Addition and isOne() to Multiplications
> -
>
> Key: NUMBERS-205
> URL: https://issues.apache.org/jira/browse/NUMBERS-205
> Project: Commons Numbers
>  Issue Type: New Feature
>  Components: core
>Affects Versions: 1.1
>Reporter: Harald Kirsch
>Priority: Major
> Fix For: 1.2
>
>
> h2. Rationale
> While coding polynomial computations over differing fields with commons math3 
> where the field is a generic parameter in the implementation of monomials and 
> polynomials, I coded the comparison with {{zero}} and {{one}} as 
> {{coefficient.getField().getZero().equals(coefficient)}}.
> With commons-numbers this gets slightly less cumbersome as 
> {{coefficient.zero().equals(coefficient)}}, but cumbersome and somewhat weird 
> looking it is still.
> But the look of it is not the only problem: employing async-profiler I saw 
> that the {{equals()}} required a non-negligible amount of CPU power, in 
> particular for the BigFraction field, which in some cases near-duplicates the 
> value to be compared due to calls to negate().
> h2. Requirement
>  * Add a method {{isZero()}} to interface Addition which returns true iff the 
> object is semantically equivalent to the object returned by {{zero()}}.
>  * Add a method {{isOne()}} to interface Multiplication which returns true 
> iff the object is semantically equivalent to the value returned by {{one()}}.



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


Re: [PR] NUMBERS-205: Introduces isZero() to Addition and isOne() to Multiplication [commons-numbers]

2023-10-04 Thread via GitHub


aherbert closed pull request #138: NUMBERS-205: Introduces isZero() to Addition 
and isOne() to Multiplication
URL: https://github.com/apache/commons-numbers/pull/138


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

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

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



Re: [PR] NUMBERS-205: Introduces isZero() to Addition and isOne() to Multiplication [commons-numbers]

2023-10-04 Thread via GitHub


aherbert commented on PR #138:
URL: https://github.com/apache/commons-numbers/pull/138#issuecomment-1747243724

   Closed by a514149aadea1542c9c4a0367f8ee2247c95.
   
   Thanks for the contribution.


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

To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org

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