Adding multiple text redaction annotations throws an error in Java

After doing two text redaction the application brokes with a modal error saying “Something went wrong, Server is not available” and in the server log we can see the following exception:

Log:
Git project: GitHub - groupdocs-annotation/GroupDocs.Annotation-for-Java: GroupDocs.Annotation for Java examples, plugins, and showcase
Git branch: master
Git revision: aeb3d5d9
Browser: Chrome Version 92.0.4515.159 (Official Build) (64-bit)
SO: Windows 10
Java version: 1.8.0_281
log-text-redaction-annotation.7z (14.4 KB)

@john.mcqueide

Please keep track of this GitHub issue. We’ll notify you here as well in case of any update.

@john.mcqueide we could not reproduce this error, could you please specify steps to reproduce ?

The steps are simple, I just made an annotation and saved the document, after that when I try to do another one and save the file again I get an error. I figure out the issue cause. The problem is when the coordinates are calculated. The minX and minY is always 0, because the code is comparing the properties that has the initial value equals zero with the annotation position for example 30. Zero is always less than 30 so it never change the property value. My change was set the initial value of minX and minY properties to Float.MAX_VALUE, this way when the code makes the comparison it will change the property value.

public class AnnotationMapper {
    ...
    public static AnnotationDataEntity mapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo) {
        //before changes
        //float maxY = 0, minY = 0, maxX = 0, minX = 0;
        //suggestion
        float maxY = 0, minY = Float.MAX_VALUE, maxX = 0, minX = Float.MAX_VALUE;
        float boxX = 0, boxY = 0, boxHeight = 0, boxWidth = 0;
        String svgPath = "";
        //annotationTypeName (java.lang.String) "Watermark"
        if (annotationInfo instanceof IPoints) {
            List<Point> points = ((IPoints)annotationInfo).getPoints();
            for (Point point : points) {
                maxY = point.getY() > maxY ? point.getY(): maxY;
                maxX = point.getX() > maxX ? point.getX(): maxX;
                minY = point.getY() < minY ? point.getY(): minY;
                minX = point.getX() < minX ? point.getX(): minX;
            }
        }
        ...
    }
}

@john.mcqueide We will further look into this scenario. Thanks for the details.

The issues you have found earlier (filed as ANNOTATIONJAVA-1329) have been fixed in this update. This message was posted using Bugs notification tool by vitaliy.rezchikov