(commons-parent) 01/02: Documentation [skip ci]
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-parent.git commit f67a11682c5061ebe17e5f17c4e6ec5ac468663e Author: Sebb AuthorDate: Sat Dec 23 23:28:22 2023 + Documentation [skip ci] --- src/assembly/src.xml | 8 1 file changed, 8 insertions(+) diff --git a/src/assembly/src.xml b/src/assembly/src.xml index 9365a6c..6babb3e 100644 --- a/src/assembly/src.xml +++ b/src/assembly/src.xml @@ -33,6 +33,14 @@ Licensed to the Apache Software Foundation (ASF) under one or more NOTICE* RELEASE-NOTES.txt pom.xml +
(commons-parent) 02/02: Add AL header [skip ci]
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-parent.git commit b1bf3d653654f097a12debf521456724631400c5 Author: Sebb AuthorDate: Sat Dec 23 23:32:47 2023 + Add AL header [skip ci] --- COMPONENTS.md | 16 1 file changed, 16 insertions(+) diff --git a/COMPONENTS.md b/COMPONENTS.md index 5d97078..8b98864 100644 --- a/COMPONENTS.md +++ b/COMPONENTS.md @@ -1,3 +1,19 @@ + # Commons components The table below is currently manually maintained from the corresponding component README files, and may get out of date. Please report any errors to the Commons Project.
(commons-parent) branch master updated (6e7bbb1 -> b1bf3d6)
This is an automated email from the ASF dual-hosted git repository. sebb pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-parent.git from 6e7bbb1 Add links to component builds new f67a116 Documentation [skip ci] new b1bf3d6 Add AL header [skip ci] The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: COMPONENTS.md| 16 src/assembly/src.xml | 8 2 files changed, 24 insertions(+)
(commons-math) branch master updated: ExcessiveMethodLength/ClassLength are deprecated
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new a1e0382ae ExcessiveMethodLength/ClassLength are deprecated a1e0382ae is described below commit a1e0382ae47d2e42de493ae7bb9aa35bfca7a41c Author: Sebb AuthorDate: Sat Dec 23 22:54:30 2023 + ExcessiveMethodLength/ClassLength are deprecated Too dependent on coding style ... [skip ci] --- src/main/resources/pmd/pmd-ruleset.xml | 17 - 1 file changed, 17 deletions(-) diff --git a/src/main/resources/pmd/pmd-ruleset.xml b/src/main/resources/pmd/pmd-ruleset.xml index 000228d76..36d98f911 100644 --- a/src/main/resources/pmd/pmd-ruleset.xml +++ b/src/main/resources/pmd/pmd-ruleset.xml @@ -97,14 +97,6 @@ or @Image='BigFraction']"/> - - - - - - - - - - - -
(commons-imaging) 01/02: Refactor constant
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit bed82950e570c4723f8015e1d635e67bf5053a7b Author: Gary Gregory AuthorDate: Sat Dec 23 15:18:30 2023 -0500 Refactor constant - Make defensive copies of arrays - Format tweaks --- .../org/apache/commons/imaging/ImageFormats.java | 29 +++--- .../imaging/formats/pnm/PnmImageParser.java| 29 -- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/ImageFormats.java b/src/main/java/org/apache/commons/imaging/ImageFormats.java index dbe462ba..6fa3beb0 100644 --- a/src/main/java/org/apache/commons/imaging/ImageFormats.java +++ b/src/main/java/org/apache/commons/imaging/ImageFormats.java @@ -17,12 +17,35 @@ package org.apache.commons.imaging; /** - * Enum of known image formats. + * Enumerates known image formats. */ public enum ImageFormats implements ImageFormat { -UNKNOWN(), BMP("bmp", "dib"), DCX("dcx"), GIF("gif"), ICNS("icns"), ICO("ico"), JBIG2(), JPEG("jpg", "jpeg"), PAM("pam"), PSD("psd"), PBM("pbm"), -PGM("pgm"), PNM("pnm"), PPM("ppm"), PCX("pcx", "pcc"), PNG("png"), RGBE("hdr", "pic"), TGA(), TIFF("tif", "tiff"), WBMP("wbmp"), WEBP("webp"), XBM("xbm"), + +// @formatter:off +UNKNOWN(), +BMP("bmp", "dib"), +DCX("dcx"), +GIF("gif"), +ICNS("icns"), +ICO("ico"), +JBIG2(), +JPEG("jpg", "jpeg"), +PAM("pam"), +PSD("psd"), +PBM("pbm"), +PGM("pgm"), +PNM("pnm"), +PPM("ppm"), +PCX("pcx", "pcc"), +PNG("png"), +RGBE("hdr", "pic"), +TGA(), +TIFF("tif", "tiff"), +WBMP("wbmp"), +WEBP("webp"), +XBM("xbm"), XPM("xpm"); +// @formatter:on private final String[] extensions; diff --git a/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java b/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java index b40c116e..c3aaa235 100644 --- a/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java @@ -28,6 +28,7 @@ import java.nio.ByteOrder; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; +import java.util.stream.Stream; import org.apache.commons.imaging.AbstractImageParser; import org.apache.commons.imaging.ImageFormat; @@ -41,10 +42,23 @@ import org.apache.commons.imaging.palette.PaletteFactory; public class PnmImageParser extends AbstractImageParser { +private static final int DPI = 72; +private static final ImageFormat[] IMAGE_FORMATS; private static final String DEFAULT_EXTENSION = ImageFormats.PNM.getDefaultExtension(); -private static final String[] ACCEPTED_EXTENSIONS = { ImageFormats.PAM.getDefaultExtension(), ImageFormats.PBM.getDefaultExtension(), -ImageFormats.PGM.getDefaultExtension(), ImageFormats.PNM.getDefaultExtension(), ImageFormats.PPM.getDefaultExtension() }; - +private static final String[] ACCEPTED_EXTENSIONS; + +static { +IMAGE_FORMATS = new ImageFormat[] { +// @formatter:off +ImageFormats.PAM, +ImageFormats.PBM, +ImageFormats.PGM, +ImageFormats.PNM, +ImageFormats.PPM +// @formatter:on +}; +ACCEPTED_EXTENSIONS = Stream.of(IMAGE_FORMATS).map(ImageFormat::getDefaultExtension).toArray(String[]::new); +} public PnmImageParser() { super(ByteOrder.LITTLE_ENDIAN); } @@ -67,12 +81,12 @@ public class PnmImageParser extends AbstractImageParser { @Override protected String[] getAcceptedExtensions() { -return ACCEPTED_EXTENSIONS; +return ACCEPTED_EXTENSIONS.clone(); } @Override protected ImageFormat[] getAcceptedTypes() { -return new ImageFormat[] { ImageFormats.PBM, ImageFormats.PGM, ImageFormats.PPM, ImageFormats.PNM, ImageFormats.PAM }; +return IMAGE_FORMATS.clone(); } @Override @@ -121,9 +135,9 @@ public class PnmImageParser extends AbstractImageParser { // boolean progressive = (fPNGChunkIHDR.InterlaceMethod != 0); // -final int physicalWidthDpi = 72; +final int physicalWidthDpi = DPI; final float physicalWidthInch = (float) ((double) info.width / (double) physicalWidthDpi); -final int physicalHeightDpi = 72; +final int physicalHeightDpi = DPI; final float physicalHeightInch = (float) ((double) info.height / (double) physicalHeightDpi); final String formatDetails = info.getImageTypeDescription(); @@ -141,7 +155,6 @@ public class PnmImageParser extends AbstractImageParser { @Override public Dimension getImageSize(final ByteSource byteSource, final
(commons-imaging) 02/02: Refactor common code
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 82a466828fa5a13aa508764a9d040496da592457 Author: Gary Gregory AuthorDate: Sat Dec 23 15:20:59 2023 -0500 Refactor common code --- .../imaging/formats/pnm/PnmImageParser.java| 27 +- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java b/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java index c3aaa235..d78f2de1 100644 --- a/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/pnm/PnmImageParser.java @@ -63,6 +63,13 @@ public class PnmImageParser extends AbstractImageParser { super(ByteOrder.LITTLE_ENDIAN); } +private int checkHasMoreTokens(final StringTokenizer tokenizer, final String type) throws ImagingException { +if (!tokenizer.hasMoreTokens()) { +throw new ImagingException("PAM header has no " + type + " value"); +} +return Integer.parseInt(tokenizer.nextToken()); +} + @Override public boolean dumpImageFile(final PrintWriter pw, final ByteSource byteSource) throws ImagingException, IOException { pw.println("pnm.dumpImageFile"); @@ -248,28 +255,16 @@ public class PnmImageParser extends AbstractImageParser { final String type = tokenizer.nextToken(); if ("WIDTH".equals(type)) { seenWidth = true; -if (!tokenizer.hasMoreTokens()) { -throw new ImagingException("PAM header has no WIDTH value"); -} -width = Integer.parseInt(tokenizer.nextToken()); +width = checkHasMoreTokens(tokenizer, type); } else if ("HEIGHT".equals(type)) { seenHeight = true; -if (!tokenizer.hasMoreTokens()) { -throw new ImagingException("PAM header has no HEIGHT value"); -} -height = Integer.parseInt(tokenizer.nextToken()); +height = checkHasMoreTokens(tokenizer, type); } else if ("DEPTH".equals(type)) { seenDepth = true; -if (!tokenizer.hasMoreTokens()) { -throw new ImagingException("PAM header has no DEPTH value"); -} -depth = Integer.parseInt(tokenizer.nextToken()); +depth = checkHasMoreTokens(tokenizer, type); } else if ("MAXVAL".equals(type)) { seenMaxVal = true; -if (!tokenizer.hasMoreTokens()) { -throw new ImagingException("PAM header has no MAXVAL value"); -} -maxVal = Integer.parseInt(tokenizer.nextToken()); +maxVal = checkHasMoreTokens(tokenizer, type); } else if ("TUPLTYPE".equals(type)) { seenTupleType = true; if (!tokenizer.hasMoreTokens()) {
(commons-imaging) branch master updated (cf67360e -> 82a46682)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git from cf67360e Remove obsolete SpotBugs exclusions new bed82950 Refactor constant new 82a46682 Refactor common code The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../org/apache/commons/imaging/ImageFormats.java | 29 +-- .../imaging/formats/pnm/PnmImageParser.java| 56 -- 2 files changed, 58 insertions(+), 27 deletions(-)
(commons-imaging) 05/08: Better use of Objects.requireNonNull()
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 181b526f6951e470b0cda11c7452572f5cd0b3d0 Author: Gary Gregory AuthorDate: Sat Dec 23 14:49:31 2023 -0500 Better use of Objects.requireNonNull() --- .../org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java index bea1d350..06d38c79 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java @@ -29,10 +29,8 @@ public class IptcBlock { private final byte[] blockData; public IptcBlock(final int blockType, final byte[] blockNameBytes, final byte[] blockData) { -Objects.requireNonNull(blockNameBytes, "blockNameBytes"); -Objects.requireNonNull(blockData, "blockData"); -this.blockData = blockData; -this.blockNameBytes = blockNameBytes; +this.blockData = Objects.requireNonNull(blockData, "blockData"); +this.blockNameBytes = Objects.requireNonNull(blockNameBytes, "blockNameBytes"); this.blockType = blockType; }
(commons-imaging) 06/08: Javadoc
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 2fb3075d762077fc7faa8df8f5e590ea5e15960a Author: Gary Gregory AuthorDate: Sat Dec 23 14:49:38 2023 -0500 Javadoc --- .../java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java index 06d38c79..d0544325 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBlock.java @@ -20,9 +20,11 @@ import java.util.Objects; /** * Represents an IPTC block, a set of key-value pairs of Photoshop IPTC data. + * + * The class is used in public API parameter types. + * */ public class IptcBlock { -// N.B. The class is used in public API parameter types private final int blockType; private final byte[] blockNameBytes;
(commons-imaging) 03/08: Manage SpotBugs configuration
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 886fde3e38a546e08912ad46c2c84ce93c1d5b52 Author: Gary Gregory AuthorDate: Sat Dec 23 14:45:30 2023 -0500 Manage SpotBugs configuration --- pom.xml | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 3cdf0bb2..f55191a4 100644 --- a/pom.xml +++ b/pom.xml @@ -156,9 +156,6 @@ com.github.spotbugs spotbugs-maven-plugin - - ${commons.conf.dir}/spotbugs-exclude-filter.xml - org.apache.maven.plugins @@ -179,6 +176,13 @@ target/** + + com.github.spotbugs + spotbugs-maven-plugin + + ${commons.conf.dir}/spotbugs-exclude-filter.xml + + org.apache.maven.plugins maven-scm-publish-plugin
(commons-imaging) 04/08: Remove obsolete SpotBugs exclusions
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 1b63210b54dead129f65f285878ea13327561c26 Author: Gary Gregory AuthorDate: Sat Dec 23 14:47:49 2023 -0500 Remove obsolete SpotBugs exclusions --- src/conf/spotbugs-exclude-filter.xml | 9 - 1 file changed, 9 deletions(-) diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index 5804374c..826117a1 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -26,15 +26,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd;> - - - - - - - - -
(commons-imaging) 07/08: Remove obsolete SpotBugs exclusions
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit fc286853b5b57b4cca9f09a41834c59eba45dca0 Author: Gary Gregory AuthorDate: Sat Dec 23 14:49:45 2023 -0500 Remove obsolete SpotBugs exclusions --- src/conf/spotbugs-exclude-filter.xml | 4 1 file changed, 4 deletions(-) diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index 826117a1..b522e4c4 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -26,10 +26,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd;> - - - -
(commons-imaging) 01/08: Sort members
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 90dcacfa80d73f17f3aaa43a842d163b98262308 Author: Gary Gregory AuthorDate: Sat Dec 23 11:39:48 2023 -0500 Sort members --- .../commons/imaging/formats/png/PngWriterTest.java | 34 +++--- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/test/java/org/apache/commons/imaging/formats/png/PngWriterTest.java b/src/test/java/org/apache/commons/imaging/formats/png/PngWriterTest.java index dec62c57..3497c7a1 100644 --- a/src/test/java/org/apache/commons/imaging/formats/png/PngWriterTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/png/PngWriterTest.java @@ -36,23 +36,6 @@ import org.junit.jupiter.api.Test; */ public class PngWriterTest extends AbstractPngTest { -private static int countColors(final byte[] bytes) throws IOException { -final BufferedImage imageParsed = Imaging.getBufferedImage(bytes); -return new PaletteFactory().makeExactRgbPaletteSimple(imageParsed, Integer.MAX_VALUE).length(); -} - -private static byte[] getImageBytes(final BufferedImage image, final PngImagingParameters params, final PaletteFactory paletteFactory) throws IOException { -try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { -new PngWriter().writeImage(image, os, params, paletteFactory); -return os.toByteArray(); -} -} - -private File getPngFile(String name) { -final File pngFolder = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, "png"); -return new File(pngFolder, name); -} - // The form of the test set is //0. target file name //1. Expected colour count (as String) - for testPaletteFactory @@ -70,6 +53,23 @@ public class PngWriterTest extends AbstractPngTest { {"5/trns-rgb.png", "26"}, }; +private static int countColors(final byte[] bytes) throws IOException { +final BufferedImage imageParsed = Imaging.getBufferedImage(bytes); +return new PaletteFactory().makeExactRgbPaletteSimple(imageParsed, Integer.MAX_VALUE).length(); +} + +private static byte[] getImageBytes(final BufferedImage image, final PngImagingParameters params, final PaletteFactory paletteFactory) throws IOException { +try (ByteArrayOutputStream os = new ByteArrayOutputStream()) { +new PngWriter().writeImage(image, os, params, paletteFactory); +return os.toByteArray(); +} +} + +private File getPngFile(String name) { +final File pngFolder = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, "png"); +return new File(pngFolder, name); +} + @Test public void testNullParameters() throws IOException { for (String[] testTarget : testSet) {
(commons-imaging) branch master updated (a6a9a9d5 -> cf67360e)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git from a6a9a9d5 Avoid NullPointerException in TiffImageParser.checkForSubImage(TiffImagingParameters) #304 new 90dcacfa Sort members new 8c44dfd7 Format consistently new 886fde3e Manage SpotBugs configuration new 1b63210b Remove obsolete SpotBugs exclusions new 181b526f Better use of Objects.requireNonNull() new 2fb3075d Javadoc new fc286853 Remove obsolete SpotBugs exclusions new cf67360e Remove obsolete SpotBugs exclusions The 8 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: pom.xml| 10 +- src/conf/spotbugs-exclude-filter.xml | 18 - .../commons/imaging/AbstractImageParser.java | 671 - .../org/apache/commons/imaging/ColorTools.java | 71 +-- .../apache/commons/imaging/FormatCompliance.java | 31 +- .../org/apache/commons/imaging/ImageFormats.java | 26 +- .../java/org/apache/commons/imaging/ImageInfo.java | 77 +-- .../java/org/apache/commons/imaging/Imaging.java | 421 ++--- .../apache/commons/imaging/ImagingConstants.java | 7 +- .../commons/imaging/ImagingFormatException.java| 11 +- .../apache/commons/imaging/ImagingParameters.java | 18 +- .../commons/imaging/ImagingRuntimeException.java | 14 +- .../org/apache/commons/imaging/PixelDensity.java | 8 +- .../imaging/bytesource/InputStreamByteSource.java | 4 +- .../commons/imaging/bytesource/package-info.java | 1 - .../apache/commons/imaging/color/ColorCieLab.java | 19 +- .../apache/commons/imaging/color/ColorCieLch.java | 14 +- .../apache/commons/imaging/color/ColorCieLuv.java | 16 +- .../org/apache/commons/imaging/color/ColorCmy.java | 19 +- .../apache/commons/imaging/color/ColorCmyk.java| 21 +- .../commons/imaging/color/ColorConversions.java| 146 +++-- .../commons/imaging/color/ColorDin99Lab.java | 5 +- .../org/apache/commons/imaging/color/ColorHsl.java | 16 +- .../org/apache/commons/imaging/color/ColorHsv.java | 16 +- .../commons/imaging/color/ColorHunterLab.java | 16 +- .../org/apache/commons/imaging/color/ColorXyz.java | 19 +- .../apache/commons/imaging/common/Allocator.java | 13 +- .../commons/imaging/common/BasicCParser.java | 95 ++- .../common/BigEndianBinaryOutputStream.java| 12 +- .../commons/imaging/common/BinaryFileParser.java | 3 +- .../commons/imaging/common/BinaryFunctions.java| 149 ++--- .../imaging/common/BufferedImageFactory.java | 6 +- .../commons/imaging/common/ByteConversions.java| 177 +++--- .../commons/imaging/common/ImageBuilder.java | 168 ++ .../common/LittleEndianBinaryOutputStream.java | 12 +- .../apache/commons/imaging/common/PackBits.java| 17 +- .../commons/imaging/common/RationalNumber.java | 87 ++- .../imaging/common/RgbBufferedImageFactory.java| 6 +- .../imaging/common/SimpleBufferedImageFactory.java | 6 +- .../commons/imaging/common/XmpEmbeddable.java | 19 +- .../apache/commons/imaging/common/ZlibDeflate.java | 8 +- .../commons/imaging/common/package-info.java | 4 +- .../commons/imaging/formats/bmp/BmpHeaderInfo.java | 14 +- .../imaging/formats/bmp/BmpImageParser.java| 102 ++-- .../imaging/formats/bmp/BmpWriterPalette.java | 12 +- .../commons/imaging/formats/bmp/BmpWriterRgb.java | 8 +- .../imaging/formats/bmp/PixelParserBitFields.java | 26 +- .../imaging/formats/bmp/PixelParserRgb.java| 26 +- .../imaging/formats/bmp/PixelParserRle.java| 26 +- .../commons/imaging/formats/bmp/package-info.java | 1 - .../imaging/formats/dcx/DcxImageParser.java| 34 +- .../commons/imaging/formats/dcx/package-info.java | 1 - .../imaging/formats/gif/DisposalMethod.java| 4 +- .../commons/imaging/formats/gif/GifHeaderInfo.java | 9 +- .../imaging/formats/gif/GifImageContents.java | 3 +- .../imaging/formats/gif/GifImageParser.java| 343 --- .../formats/gif/GraphicControlExtension.java | 4 +- .../imaging/formats/gif/ImageDescriptor.java | 9 +- .../commons/imaging/formats/gif/package-info.java | 1 - .../commons/imaging/formats/icns/IcnsDecoder.java | 158 ++--- .../imaging/formats/icns/IcnsImageParser.java | 59 +- .../commons/imaging/formats/icns/IcnsType.java | 130 ++-- .../imaging/formats/icns/Rle24Compression.java | 4 +- .../commons/imaging/formats/icns/package-info.java | 1 - .../imaging/formats/ico/IcoImageParser.java| 234 --- .../commons/imaging/formats/ico/package-info.java | 1 -
(commons-imaging) 08/08: Remove obsolete SpotBugs exclusions
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit cf67360ed5287b306d9c104dbe459bb840cb4b74 Author: Gary Gregory AuthorDate: Sat Dec 23 14:51:52 2023 -0500 Remove obsolete SpotBugs exclusions --- src/conf/spotbugs-exclude-filter.xml | 5 - 1 file changed, 5 deletions(-) diff --git a/src/conf/spotbugs-exclude-filter.xml b/src/conf/spotbugs-exclude-filter.xml index b522e4c4..ebefe41f 100644 --- a/src/conf/spotbugs-exclude-filter.xml +++ b/src/conf/spotbugs-exclude-filter.xml @@ -163,11 +163,6 @@ - - - - -
(commons-statistics) 01/02: Add random test case data for integer sum statistics
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git commit 90e0ae3760d43a21d5da202b8d226cdd82a7a7c0 Author: Alex Herbert AuthorDate: Sat Dec 23 19:39:59 2023 + Add random test case data for integer sum statistics --- .../apache/commons/statistics/descriptive/IntSumTest.java | 14 +++--- .../apache/commons/statistics/descriptive/LongSumTest.java | 14 +++--- .../apache/commons/statistics/descriptive/TestHelper.java | 3 ++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/IntSumTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/IntSumTest.java index 10c90dd..27bc0d3 100644 --- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/IntSumTest.java +++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/IntSumTest.java @@ -19,6 +19,7 @@ package org.apache.commons.statistics.descriptive; import java.math.BigInteger; import java.util.Arrays; import java.util.stream.Stream; +import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.statistics.distribution.DoubleTolerance; import org.apache.commons.statistics.distribution.DoubleTolerances; import org.junit.jupiter.api.Assertions; @@ -53,7 +54,8 @@ final class IntSumTest extends BaseIntStatisticTest { @Override protected DoubleTolerance getToleranceAsDouble() { // Floating-point sum may be inexact. -// Currently the double sum matches on the standard test data. +// Currently the double sum matches on the standard test data +// and larger random data added in streamTestData(). return DoubleTolerances.equals(); } @@ -73,9 +75,15 @@ final class IntSumTest extends BaseIntStatisticTest { @Override protected Stream streamTestData() { +// A null seed will create a different RNG each time +final UniformRandomProvider rng = TestHelper.createRNG(null); return Stream.of( -addCase(Integer.MAX_VALUE, 1, 2, 3, 4, Integer.MAX_VALUE), -addCase(Integer.MIN_VALUE, -1, -2, -3, -4, Integer.MIN_VALUE) +addCase(Integer.MAX_VALUE, 1, 2, 3, 4, -20, Integer.MAX_VALUE), +addCase(Integer.MIN_VALUE, -1, -2, -3, -4, 20, Integer.MIN_VALUE), +addCase(rng.ints(5).toArray()), +addCase(rng.ints(10).toArray()), +addCase(rng.ints(20).toArray()), +addCase(rng.ints(40).toArray()) ); } diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/LongSumTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/LongSumTest.java index 9207112..de203f7 100644 --- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/LongSumTest.java +++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/LongSumTest.java @@ -19,6 +19,7 @@ package org.apache.commons.statistics.descriptive; import java.math.BigInteger; import java.util.Arrays; import java.util.stream.Stream; +import org.apache.commons.rng.UniformRandomProvider; import org.apache.commons.statistics.distribution.DoubleTolerance; import org.apache.commons.statistics.distribution.DoubleTolerances; import org.junit.jupiter.api.Assertions; @@ -54,7 +55,8 @@ final class LongSumTest extends BaseLongStatisticTest { protected DoubleTolerance getToleranceAsDouble() { // Floating-point sum may be inexact. // Currently the double sum matches on the standard test data. -return DoubleTolerances.equals(); +// It fails on large random data added in streamTestData(). +return DoubleTolerances.ulps(5); } @Override @@ -74,9 +76,15 @@ final class LongSumTest extends BaseLongStatisticTest { @Override protected Stream streamTestData() { +// A null seed will create a different RNG each time +final UniformRandomProvider rng = TestHelper.createRNG(null); return Stream.of( -addCase(Long.MAX_VALUE, 1, 2, 3, 4, Long.MAX_VALUE), -addCase(Long.MIN_VALUE, -1, -2, -3, -4, Long.MIN_VALUE) +addCase(Long.MAX_VALUE, 1, 2, 3, 4, -20, Long.MAX_VALUE), +addCase(Long.MIN_VALUE, -1, -2, -3, -4, 20, Long.MIN_VALUE), +addCase(rng.longs(5).toArray()), +addCase(rng.longs(10).toArray()), +addCase(rng.longs(20).toArray()), +addCase(rng.longs(40).toArray()) ); } diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/TestHelper.java
(commons-statistics) 02/02: STATISTICS-81: Add integer sum of squares implementation
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git commit b560d2aad985b656ee0194f2ea798e780d6186b4 Author: Alex Herbert AuthorDate: Sat Dec 23 19:43:41 2023 + STATISTICS-81: Add integer sum of squares implementation --- .../statistics/descriptive/IntSumOfSquares.java| 206 + .../statistics/descriptive/LongSumOfSquares.java | 181 ++ .../commons/statistics/descriptive/UInt128.java| 25 +++ .../commons/statistics/descriptive/UInt192.java| 25 +++ .../descriptive/IntSumOfSquaresTest.java | 115 .../descriptive/LongSumOfSquaresTest.java | 119 .../statistics/descriptive/UInt128Test.java| 35 .../statistics/descriptive/UInt192Test.java| 51 + 8 files changed, 757 insertions(+) diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntSumOfSquares.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntSumOfSquares.java new file mode 100644 index 000..fde3728 --- /dev/null +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntSumOfSquares.java @@ -0,0 +1,206 @@ +/* + * 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.statistics.descriptive; + +import java.math.BigInteger; + +/** + * Returns the sum of the squares of the available values. Uses the following definition: + * + * \[ \sum_{i=1}^n x_i^2 \] + * + * where \( n \) is the number of samples. + * + * + * The result is zero if no values are observed. + * + * + * The implementation uses an exact integer sum to compute the sum of squared values. + * It supports up to 263 values. The exact sum is + * returned using {@link #getAsBigInteger()}. Methods that return {@code int} or + * {@code long} primitives will raise an exception if the result overflows. + * + * Note that the implementation does not use {@code BigInteger} arithmetic; for + * performance the sum is computed using primitives to create an unsigned 128-bit integer. + * + * This class is designed to work with (though does not require) + * {@linkplain java.util.stream streams}. + * + * This implementation is not thread safe. + * If multiple threads access an instance of this class concurrently, + * and at least one of the threads invokes the {@link java.util.function.IntConsumer#accept(int) accept} or + * {@link StatisticAccumulator#combine(StatisticResult) combine} method, it must be synchronized externally. + * + * However, it is safe to use {@link java.util.function.IntConsumer#accept(int) accept} + * and {@link StatisticAccumulator#combine(StatisticResult) combine} + * as {@code accumulator} and {@code combiner} functions of + * {@link java.util.stream.Collector Collector} on a parallel stream, + * because the parallel implementation of {@link java.util.stream.Stream#collect Stream.collect()} + * provides the necessary partitioning, isolation, and merging of results for + * safe and efficient parallel execution. + * + * @since 1.1 + */ +public final class IntSumOfSquares implements IntStatistic, StatisticAccumulator { +/** Small array sample size. + * Used to avoid computing with UInt96 then converting to UInt128. */ +private static final int SMALL_SAMPLE = 10; + +/** Sum of the squared values. */ +private final UInt128 sumSq; + +/** + * Create an instance. + */ +private IntSumOfSquares() { +this(UInt128.create()); +} + +/** + * Create an instance. + * + * @param sumSq Sum of the squared values. + */ +private IntSumOfSquares(UInt128 sumSq) { +this.sumSq = sumSq; +} + +/** + * Creates an instance. + * + * The initial result is zero. + * + * @return {@code IntSumOfSquares} instance. + */ +public static IntSumOfSquares create() { +return new IntSumOfSquares(); +} + +/** + * Returns an instance populated using the input {@code values}. + * + * @param values Values. + *
(commons-statistics) branch master updated (9d116ce -> b560d2a)
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git from 9d116ce Javadoc corrections new 90e0ae3 Add random test case data for integer sum statistics new b560d2a STATISTICS-81: Add integer sum of squares implementation The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../{IntSum.java => IntSumOfSquares.java} | 111 - .../{IntSum.java => LongSumOfSquares.java} | 90 - .../commons/statistics/descriptive/UInt128.java| 25 + .../commons/statistics/descriptive/UInt192.java| 25 + .../{IntSumTest.java => IntSumOfSquaresTest.java} | 36 --- .../commons/statistics/descriptive/IntSumTest.java | 14 ++- ...{LongSumTest.java => LongSumOfSquaresTest.java} | 37 --- .../statistics/descriptive/LongSumTest.java| 14 ++- .../commons/statistics/descriptive/TestHelper.java | 3 +- .../statistics/descriptive/UInt128Test.java| 35 +++ .../statistics/descriptive/UInt192Test.java| 51 ++ 11 files changed, 315 insertions(+), 126 deletions(-) copy commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/{IntSum.java => IntSumOfSquares.java} (57%) copy commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/{IntSum.java => LongSumOfSquares.java} (65%) copy commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/{IntSumTest.java => IntSumOfSquaresTest.java} (71%) copy commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/{LongSumTest.java => LongSumOfSquaresTest.java} (70%)
(commons-imaging) 01/03: Fail-fast on null inputs in AbstractPixelParser constructor (oss-fuzz 34180) #183
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 65b32d6c8aa94debb6e549cb2b0eab928e88d440 Author: Gary Gregory AuthorDate: Sat Dec 23 11:01:48 2023 -0500 Fail-fast on null inputs in AbstractPixelParser constructor (oss-fuzz 34180) #183 --- src/changes/changes.xml | 3 +++ .../imaging/formats/bmp/AbstractPixelParser.java| 17 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 2a7bcbd0..f3190321 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -78,6 +78,9 @@ The type attribute can be add,update,fix,remove. Make ImageInfo state correct color type #337. + +Fail-fast on null inputs in AbstractPixelParser constructor (oss-fuzz 34180) #183. + [PngWriter] Allow custom PaletteFactory #294. diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java b/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java index dafdd594..b5fee061 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java @@ -19,6 +19,7 @@ package org.apache.commons.imaging.formats.bmp; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.Objects; import org.apache.commons.imaging.ImagingException; import org.apache.commons.imaging.common.ImageBuilder; @@ -31,19 +32,19 @@ abstract class AbstractPixelParser { final InputStream is; -AbstractPixelParser(final BmpHeaderInfo bhi, final byte[] colorTable, final byte[] imageData) { -this.bhi = bhi; +AbstractPixelParser(final BmpHeaderInfo bmpHeaderInfo, final byte[] colorTable, final byte[] imageData) { +this.bhi = Objects.requireNonNull(bmpHeaderInfo, "bmpHeaderInfo"); this.colorTable = colorTable; -this.imageData = imageData; +this.imageData = Objects.requireNonNull(imageData, "imageData"); is = new ByteArrayInputStream(imageData); } -int getColorTableRgb(int index) { -index *= 4; -final int blue = 0xff & colorTable[index + 0]; -final int green = 0xff & colorTable[index + 1]; -final int red = 0xff & colorTable[index + 2]; +int getColorTableRgb(int actual) { +actual *= 4; +final int blue = 0xff & colorTable[actual + 0]; +final int green = 0xff & colorTable[actual + 1]; +final int red = 0xff & colorTable[actual + 2]; final int alpha = 0xff; return (alpha << 24)
(commons-imaging) 03/03: Avoid NullPointerException in TiffImageParser.checkForSubImage(TiffImagingParameters) #304
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit a6a9a9d5c5743fbf0b6af95e6f71c0b3ae6e1624 Author: Gary Gregory AuthorDate: Sat Dec 23 11:32:07 2023 -0500 Avoid NullPointerException in TiffImageParser.checkForSubImage(TiffImagingParameters) #304 --- src/changes/changes.xml| 3 +++ .../java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index f3190321..b6570cf2 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -81,6 +81,9 @@ The type attribute can be add,update,fix,remove. Fail-fast on null inputs in AbstractPixelParser constructor (oss-fuzz 34180) #183. + +Avoid NullPointerException in TiffImageParser.checkForSubImage(TiffImagingParameters) #304. + [PngWriter] Allow custom PaletteFactory #294. diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java index d44e1099..b01874b4 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java @@ -84,7 +84,7 @@ public class TiffImageParser extends AbstractImageParser // dimensions of the image that is being read. This method // returns the sub-image specification, if any, and leaves // further tests to the calling module. -if (params.isSubImageSet()) { +if (params != null && params.isSubImageSet()) { final int ix0 = params.getSubImageX(); final int iy0 = params.getSubImageY(); final int iwidth = params.getSubImageWidth();
(commons-imaging) 02/03: Use final
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git commit 154174857f2ed3abff9b7916242ff64d6e9de476 Author: Gary Gregory AuthorDate: Sat Dec 23 11:03:23 2023 -0500 Use final Remove paren noise --- .../apache/commons/imaging/formats/bmp/AbstractPixelParser.java | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java b/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java index b5fee061..bdb81586 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/AbstractPixelParser.java @@ -40,17 +40,14 @@ abstract class AbstractPixelParser { is = new ByteArrayInputStream(imageData); } -int getColorTableRgb(int actual) { -actual *= 4; +int getColorTableRgb(final int index) { +final int actual = index * 4; final int blue = 0xff & colorTable[actual + 0]; final int green = 0xff & colorTable[actual + 1]; final int red = 0xff & colorTable[actual + 2]; final int alpha = 0xff; -return (alpha << 24) -| (red << 16) -| (green << 8) -| (blue << 0); +return alpha << 24 | red << 16 | green << 8 | blue << 0; } public abstract void processImage(ImageBuilder imageBuilder) throws ImagingException, IOException;
(commons-imaging) branch master updated (9d6c4ca1 -> a6a9a9d5)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git from 9d6c4ca1 [IMAGING-355] Add option to skip reading GIF metadata #301 new 65b32d6c Fail-fast on null inputs in AbstractPixelParser constructor (oss-fuzz 34180) #183 new 15417485 Use final new a6a9a9d5 Avoid NullPointerException in TiffImageParser.checkForSubImage(TiffImagingParameters) #304 The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: src/changes/changes.xml| 6 ++ .../imaging/formats/bmp/AbstractPixelParser.java | 22 ++ .../imaging/formats/tiff/TiffImageParser.java | 2 +- 3 files changed, 17 insertions(+), 13 deletions(-)
(commons-statistics) branch master updated: Javadoc corrections
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git The following commit(s) were added to refs/heads/master by this push: new 9d116ce Javadoc corrections 9d116ce is described below commit 9d116ce5ae789e78c6dfcacf7e726f237c00a057 Author: Alex Herbert AuthorDate: Sat Dec 23 16:31:03 2023 + Javadoc corrections --- .../java/org/apache/commons/statistics/descriptive/LongSum.java | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/LongSum.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/LongSum.java index 61efaa8..aacf80b 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/LongSum.java +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/LongSum.java @@ -29,8 +29,6 @@ import java.math.BigInteger; * values as the count \( n \) is maintained as a {@code long}. The exact sum is * returned using {@link #getAsBigInteger()}. Methods that return {@code int} or * {@code long} primitives will raise an exception if the result overflows. - * The {@code long} value is safe up to the maximum array length for any input - * {@code int[]} data. The {@code long} value can overflow when instances are combined. * * Note that the implementation does not use {@code BigInteger} arithmetic; for * performance the sum is computed using primitives to create a signed 128-bit integer. @@ -78,7 +76,7 @@ public final class LongSum implements LongStatistic, StatisticAccumulatorThe initial result is zero. * - * @return {@code IntSum} instance. + * @return {@code LongSum} instance. */ public static LongSum create() { return new LongSum(); @@ -90,7 +88,7 @@ public final class LongSum implements LongStatistic, StatisticAccumulatorWhen the input is an empty array, the result is zero. * * @param values Values. - * @return {@code IntSum} instance. + * @return {@code LongSum} instance. */ public static LongSum of(long... values) { final Int128 s = Int128.create();
(commons-statistics) branch master updated: STATISTICS-81: Add integer sum implementation
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git The following commit(s) were added to refs/heads/master by this push: new 171b29a STATISTICS-81: Add integer sum implementation 171b29a is described below commit 171b29a5780ccbbbf06ff3a08a5e63ec5dedd673 Author: Alex Herbert AuthorDate: Sat Dec 23 16:26:42 2023 + STATISTICS-81: Add integer sum implementation --- .../commons/statistics/descriptive/Int128.java | 62 +++ .../commons/statistics/descriptive/IntMath.java| 4 +- .../commons/statistics/descriptive/IntSum.java | 185 + .../commons/statistics/descriptive/LongSum.java| 180 .../commons/statistics/descriptive/UInt128.java| 2 +- .../commons/statistics/descriptive/UInt192.java| 4 +- .../commons/statistics/descriptive/Int128Test.java | 27 +++ .../statistics/descriptive/IntMathTest.java| 6 +- .../statistics/descriptive/IntMeanTest.java| 2 +- .../{IntMeanTest.java => IntSumTest.java} | 67 .../statistics/descriptive/LongMeanTest.java | 2 +- .../{LongMeanTest.java => LongSumTest.java}| 74 - 12 files changed, 522 insertions(+), 93 deletions(-) diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Int128.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Int128.java index 5ae6357..bf0b99e 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Int128.java +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/Int128.java @@ -195,6 +195,44 @@ final class Int128 { .putLong(h).putLong(l).array()); } +/** + * Convert to a {@code double}. + * + * @return the value + */ +double toDouble() { +long h = hi; +long l = lo; +// Special cases +if (h == 0) { +return l; +} +if (l == 0) { +return h * 0x1.0p64; +} +// Both h and l are non-zero and can be negated to a positive magnitude. +// Use the same logic as toBigInteger to create magnitude (h, l) and a sign. +int sign = 1; +if ((h ^ l) < 0) { +// Here we rearrange to [2^64 * (hi64-1)] + [2^64 - lo64]. +if (h >= 0) { +h = h - 1; +} else { +// As above with negation +h = ~h; // -h - 1 +l = -l; +sign = -1; +} +} else if (h < 0) { +// Invert negative values to create the equivalent positive magnitude. +h = -h; +l = -l; +sign = -1; +} +final double x = IntMath.uint128ToDouble(h, l); +return sign < 0 ? -x : x; +} + /** * Convert to a double-double. * @@ -211,6 +249,30 @@ final class Int128 { return DD.of(lo).add((hi & MASK32) * 0x1.0p64).add((hi >> Integer.SIZE) * 0x1.0p96); } +/** + * Convert to an {@code int}; throwing an exception if the value overflows an {@code int}. + * + * @return the value + * @throws ArithmeticException if the value overflows an {@code int}. + * @see Math#toIntExact(long) + */ +int toIntExact() { +return Math.toIntExact(toLongExact()); +} + +/** + * Convert to a {@code long}; throwing an exception if the value overflows a {@code long}. + * + * @return the value + * @throws ArithmeticException if the value overflows a {@code long}. + */ +long toLongExact() { +if (hi != 0) { +throw new ArithmeticException("long integer overflow"); +} +return lo; +} + /** * Return the lower 64-bits as a {@code long} value. * diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntMath.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntMath.java index 714fc41..2309750 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntMath.java +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/IntMath.java @@ -212,7 +212,7 @@ final class IntMath { // Implicit conversion to a double. return lo; } -return uin128ToDouble(unsignedMultiplyHigh(x, y), lo); +return uint128ToDouble(unsignedMultiplyHigh(x, y), lo); } /** @@ -222,7 +222,7 @@ final class IntMath { * @param lo Low 64-bits. * @return the double */ -static double uin128ToDouble(long hi, long lo) { +static double uint128ToDouble(long hi, long lo) { //
(commons-io) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git The following commit(s) were added to refs/heads/master by this push: new 72da9c20 Use StandardCharsets 72da9c20 is described below commit 72da9c20951b420854cf38dce415b9195dedd5a7 Author: Gary Gregory AuthorDate: Sat Dec 23 11:21:10 2023 -0500 Use StandardCharsets --- .../java/org/apache/commons/io/FileUtilsTest.java | 24 +++--- .../java/org/apache/commons/io/IOUtilsTest.java| 4 ++-- .../org/apache/commons/io/IOUtilsWriteTest.java| 8 .../io/input/CharSequenceInputStreamTest.java | 2 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/test/java/org/apache/commons/io/FileUtilsTest.java b/src/test/java/org/apache/commons/io/FileUtilsTest.java index 45ef7a41..78d0866f 100644 --- a/src/test/java/org/apache/commons/io/FileUtilsTest.java +++ b/src/test/java/org/apache/commons/io/FileUtilsTest.java @@ -538,7 +538,7 @@ public class FileUtilsTest extends AbstractTempDirTest { // create a test file final String text = "Imagination is more important than knowledge - Einstein"; final File file = new File(tempDirFile, "checksum-test.txt"); -FileUtils.writeStringToFile(file, text, "US-ASCII"); +FileUtils.writeStringToFile(file, text, StandardCharsets.US_ASCII.name()); // compute the expected checksum final Checksum expectedChecksum = new CRC32(); @@ -559,7 +559,7 @@ public class FileUtilsTest extends AbstractTempDirTest { // create a test file final String text = "Imagination is more important than knowledge - Einstein"; final File file = new File(tempDirFile, "checksum-test.txt"); -FileUtils.writeStringToFile(file, text, "US-ASCII"); +FileUtils.writeStringToFile(file, text, StandardCharsets.US_ASCII.name()); // compute the expected checksum final Checksum expectedChecksum = new CRC32(); @@ -577,12 +577,12 @@ public class FileUtilsTest extends AbstractTempDirTest { // create a test file final String text1 = "Imagination is more important than knowledge - Einstein"; final File file1 = new File(tempDirFile, "checksum-test.txt"); -FileUtils.writeStringToFile(file1, text1, "US-ASCII"); +FileUtils.writeStringToFile(file1, text1, StandardCharsets.US_ASCII.name()); // create a second test file final String text2 = "To be or not to be - Shakespeare"; final File file2 = new File(tempDirFile, "checksum-test2.txt"); -FileUtils.writeStringToFile(file2, text2, "US-ASCII"); +FileUtils.writeStringToFile(file2, text2, StandardCharsets.US_ASCII.name()); // compute the expected checksum final Checksum expectedChecksum = new CRC32(); @@ -609,7 +609,7 @@ public class FileUtilsTest extends AbstractTempDirTest { // create a test file final String text = "Imagination is more important than knowledge - Einstein"; final File file = new File(tempDirFile, "checksum-test.txt"); -FileUtils.writeStringToFile(file, text, "US-ASCII"); +FileUtils.writeStringToFile(file, text, StandardCharsets.US_ASCII.name()); assertThrows(NullPointerException.class, () -> FileUtils.checksum(file, null)); } @@ -2925,12 +2925,12 @@ public class FileUtilsTest extends AbstractTempDirTest { final List list = Arrays.asList(data); final File file = TestUtils.newFile(tempDirFile, "lines.txt"); -FileUtils.writeLines(file, "US-ASCII", list); +FileUtils.writeLines(file, StandardCharsets.US_ASCII.name(), list); final String expected = "hello" + System.lineSeparator() + "world" + System.lineSeparator() + System.lineSeparator() + "this is" + System.lineSeparator() + System.lineSeparator() + "some text" + System.lineSeparator(); -final String actual = FileUtils.readFileToString(file, "US-ASCII"); +final String actual = FileUtils.readFileToString(file, StandardCharsets.US_ASCII.name()); assertEquals(expected, actual); } @@ -2972,10 +2972,10 @@ public class FileUtilsTest extends AbstractTempDirTest { final List list = Arrays.asList(data); final File file = TestUtils.newFile(tempDirFile, "lines.txt"); -FileUtils.writeLines(file, "US-ASCII", list, "*"); +FileUtils.writeLines(file, StandardCharsets.US_ASCII.name(), list, "*"); final String expected = "hello*world**this is**some text*"; -final String actual = FileUtils.readFileToString(file, "US-ASCII"); +final String actual = FileUtils.readFileToString(file, StandardCharsets.US_ASCII.name()); assertEquals(expected, actual); } @@ -2986,19 +2986,19 @@ public class FileUtilsTest extends
(commons-daemon) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-daemon.git The following commit(s) were added to refs/heads/master by this push: new 0879ce0 Use StandardCharsets 0879ce0 is described below commit 0879ce011e3757a73d56b833d05f6dac0c011675 Author: Gary Gregory AuthorDate: Sat Dec 23 11:19:25 2023 -0500 Use StandardCharsets --- src/samples/SimpleApplication.java | 3 ++- src/samples/SimpleDaemon.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/samples/SimpleApplication.java b/src/samples/SimpleApplication.java index a35c3b1..fb796ef 100644 --- a/src/samples/SimpleApplication.java +++ b/src/samples/SimpleApplication.java @@ -24,6 +24,7 @@ import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.net.ServerSocket; import java.net.Socket; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Enumeration; @@ -256,7 +257,7 @@ public class SimpleApplication implements Runnable { public void handle(InputStream in, OutputStream os) { PrintStream out = null; try { -out = new PrintStream(os, true, "US-ASCII"); +out = new PrintStream(os, true, StandardCharsets.US_ASCII.name()); } catch (UnsupportedEncodingException ex) { out = new PrintStream(os, true); } diff --git a/src/samples/SimpleDaemon.java b/src/samples/SimpleDaemon.java index 1471591..cec9b2d 100644 --- a/src/samples/SimpleDaemon.java +++ b/src/samples/SimpleDaemon.java @@ -24,6 +24,7 @@ import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.net.ServerSocket; import java.net.Socket; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Enumeration; @@ -239,7 +240,7 @@ public class SimpleDaemon implements Daemon, Runnable { public void handle(InputStream in, OutputStream os) { PrintStream out = null; try { -out = new PrintStream(os, true, "US-ASCII"); +out = new PrintStream(os, true, StandardCharsets.US_ASCII.name()); } catch (UnsupportedEncodingException ex) { out = new PrintStream(os, true); }
(commons-codec) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git The following commit(s) were added to refs/heads/master by this push: new 275ab531 Use StandardCharsets 275ab531 is described below commit 275ab531c546a3edb612aa48e6ac38c5c1579720 Author: Gary Gregory AuthorDate: Sat Dec 23 11:19:01 2023 -0500 Use StandardCharsets --- src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java b/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java index a0ce7926..34ed662d 100644 --- a/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java @@ -118,7 +118,7 @@ public class StringUtilsTest { @Test public void testGetBytesUsAscii() throws UnsupportedEncodingException { -final String charsetName = "US-ASCII"; +final String charsetName = StandardCharsets.US_ASCII.name(); testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesUsAscii(STRING_FIXTURE);
(commons-codec) branch master updated: Javadoc
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-codec.git The following commit(s) were added to refs/heads/master by this push: new 6f706497 Javadoc 6f706497 is described below commit 6f70649795787cdd558bdec84c80a08f952ab644 Author: Gary Gregory AuthorDate: Sat Dec 23 11:17:58 2023 -0500 Javadoc --- src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java b/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java index 878e0473..a0ce7926 100644 --- a/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/codec/binary/StringUtilsTest.java @@ -93,7 +93,7 @@ public class StringUtilsTest { @Test public void testGetBytesIso8859_1() throws UnsupportedEncodingException { -final String charsetName = "ISO-8859-1"; +final String charsetName = StandardCharsets.ISO_8859_1.name(); testGetBytesUnchecked(charsetName); final byte[] expected = STRING_FIXTURE.getBytes(charsetName); final byte[] actual = StringUtils.getBytesIso8859_1(STRING_FIXTURE); @@ -174,7 +174,7 @@ public class StringUtilsTest { @Test public void testNewStringIso8859_1() throws UnsupportedEncodingException { -final String charsetName = "ISO-8859-1"; +final String charsetName = StandardCharsets.ISO_8859_1.name(); testNewString(charsetName); final String expected = new String(BYTES_FIXTURE, charsetName); final String actual = StringUtils.newStringIso8859_1(BYTES_FIXTURE);
(commons-net) branch master updated: Javadoc
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-net.git The following commit(s) were added to refs/heads/master by this push: new 3bca8a12 Javadoc 3bca8a12 is described below commit 3bca8a12316091d3f154a3360914fc508b499d82 Author: Gary Gregory AuthorDate: Sat Dec 23 11:17:21 2023 -0500 Javadoc --- src/main/java/org/apache/commons/net/smtp/SMTP.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/net/smtp/SMTP.java b/src/main/java/org/apache/commons/net/smtp/SMTP.java index 92a9a6fc..71cf4c66 100644 --- a/src/main/java/org/apache/commons/net/smtp/SMTP.java +++ b/src/main/java/org/apache/commons/net/smtp/SMTP.java @@ -64,9 +64,9 @@ public class SMTP extends SocketClient { /** The default SMTP port (25). */ public static final int DEFAULT_PORT = 25; -// We have to ensure that the protocol communication is in ASCII, -// but we use ISO-8859-1 just in case 8-bit characters cross -// the wire. +/** + * We have to ensure that the protocol communication is in ASCII, but we use ISO-8859-1 just in case 8-bit characters cross the wire. + */ private static final String DEFAULT_ENCODING = StandardCharsets.ISO_8859_1.name(); /**
(commons-net) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-net.git The following commit(s) were added to refs/heads/master by this push: new 56e30314 Use StandardCharsets 56e30314 is described below commit 56e30314bb60724ae77cceddf063fd72fca2ab96 Author: Gary Gregory AuthorDate: Sat Dec 23 11:16:50 2023 -0500 Use StandardCharsets --- src/main/java/org/apache/commons/net/ftp/FTP.java | 3 ++- src/main/java/org/apache/commons/net/smtp/SMTP.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/commons/net/ftp/FTP.java b/src/main/java/org/apache/commons/net/ftp/FTP.java index 9c860fdb..9ddca241 100644 --- a/src/main/java/org/apache/commons/net/ftp/FTP.java +++ b/src/main/java/org/apache/commons/net/ftp/FTP.java @@ -28,6 +28,7 @@ import java.net.Inet6Address; import java.net.InetAddress; import java.net.SocketException; import java.net.SocketTimeoutException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import org.apache.commons.net.MalformedServerReplyException; @@ -157,7 +158,7 @@ public class FTP extends SocketClient { * The default character encoding used for communicating over an FTP control connection. The default encoding is an ASCII-compatible encoding. Some FTP * servers expect other encodings. You can change the encoding used by an FTP instance with {@link #setControlEncoding setControlEncoding}. */ -public static final String DEFAULT_CONTROL_ENCODING = "ISO-8859-1"; +public static final String DEFAULT_CONTROL_ENCODING = StandardCharsets.ISO_8859_1.name(); /** Length of the FTP reply code (3 alphanumerics) */ public static final int REPLY_CODE_LEN = 3; diff --git a/src/main/java/org/apache/commons/net/smtp/SMTP.java b/src/main/java/org/apache/commons/net/smtp/SMTP.java index 589d402d..92a9a6fc 100644 --- a/src/main/java/org/apache/commons/net/smtp/SMTP.java +++ b/src/main/java/org/apache/commons/net/smtp/SMTP.java @@ -22,6 +22,7 @@ import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import org.apache.commons.net.MalformedServerReplyException; @@ -66,7 +67,7 @@ public class SMTP extends SocketClient { // We have to ensure that the protocol communication is in ASCII, // but we use ISO-8859-1 just in case 8-bit characters cross // the wire. -private static final String DEFAULT_ENCODING = "ISO-8859-1"; +private static final String DEFAULT_ENCODING = StandardCharsets.ISO_8859_1.name(); /** * The encoding to use (user-settable).
(commons-io) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-io.git The following commit(s) were added to refs/heads/master by this push: new a9cab986 Use StandardCharsets a9cab986 is described below commit a9cab986b8014cd2a4a19599b79e80b40ab9f30c Author: Gary Gregory AuthorDate: Sat Dec 23 11:16:06 2023 -0500 Use StandardCharsets --- .../apache/commons/io/input/ReversedLinesFileReaderTestSimple.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java index 00e2100d..e8c5b0ec 100644 --- a/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java +++ b/src/test/java/org/apache/commons/io/input/ReversedLinesFileReaderTestSimple.java @@ -39,7 +39,7 @@ public class ReversedLinesFileReaderTestSimple { final int blockSize = 10; final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin"); try (ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize, -"ISO-8859-1")) { +StandardCharsets.ISO_8859_1.name())) { assertEqualsAndNoLineBreaks("987654321", reversedLinesFileReader.readLine()); assertEqualsAndNoLineBreaks("123456789", reversedLinesFileReader.readLine()); } @@ -50,7 +50,7 @@ public class ReversedLinesFileReaderTestSimple { final int blockSize = 10; final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin"); try (ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize, -"ISO-8859-1")) { +StandardCharsets.ISO_8859_1.name())) { assertThrows(IllegalArgumentException.class, () -> reversedLinesFileReader.readLines(-1)); assertTrue(reversedLinesFileReader.readLines(0).isEmpty()); final List lines = reversedLinesFileReader.readLines(2); @@ -66,7 +66,7 @@ public class ReversedLinesFileReaderTestSimple { final int blockSize = 10; final File testFile20Bytes = TestResources.getFile("/test-file-20byteslength.bin"); try (ReversedLinesFileReader reversedLinesFileReader = new ReversedLinesFileReader(testFile20Bytes, blockSize, -"ISO-8859-1")) { +StandardCharsets.ISO_8859_1.name())) { assertThrows(IllegalArgumentException.class, () -> reversedLinesFileReader.toString(-1)); assertTrue(reversedLinesFileReader.readLines(0).isEmpty()); final String lines = reversedLinesFileReader.toString(2);
(commons-fileupload) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git The following commit(s) were added to refs/heads/master by this push: new 96aa9a3e Use StandardCharsets 96aa9a3e is described below commit 96aa9a3e9ee6e1a2321306eecdcaee953ab30211 Author: Gary Gregory AuthorDate: Sat Dec 23 11:15:32 2023 -0500 Use StandardCharsets --- .../src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java index 667386b3..d8dce3c9 100644 --- a/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java +++ b/commons-fileupload2-core/src/main/java/org/apache/commons/fileupload2/core/MimeUtils.java @@ -70,8 +70,8 @@ final class MimeUtils { MIME2JAVA.put("ja_jp.eucjp", "EUCJIS"); MIME2JAVA.put("euc-kr", "KSC5601"); MIME2JAVA.put("euckr", "KSC5601"); -MIME2JAVA.put("us-ascii", "ISO-8859-1"); -MIME2JAVA.put("x-us-ascii", "ISO-8859-1"); +MIME2JAVA.put("us-ascii", StandardCharsets.ISO_8859_1.name()); +MIME2JAVA.put("x-us-ascii", StandardCharsets.ISO_8859_1.name()); } /**
(commons-email) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-email.git The following commit(s) were added to refs/heads/master by this push: new 891afed Use StandardCharsets 891afed is described below commit 891afedf8c3d0084f9c365c2a9b970da55017a34 Author: Gary Gregory AuthorDate: Sat Dec 23 11:14:46 2023 -0500 Use StandardCharsets --- src/test/java/org/apache/commons/mail/EmailLiveTest.java | 2 +- src/test/java/org/apache/commons/mail/EmailTest.java | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/mail/EmailLiveTest.java b/src/test/java/org/apache/commons/mail/EmailLiveTest.java index 6e77187..8715bc7 100644 --- a/src/test/java/org/apache/commons/mail/EmailLiveTest.java +++ b/src/test/java/org/apache/commons/mail/EmailLiveTest.java @@ -232,7 +232,7 @@ public class EmailLiveTest extends AbstractEmailTest { // use a simple HTML page with one image final File htmlFile = new File("./src/test/resources/html/www.apache.org.html"); -final String htmlMsg1 = FileUtils.readFileToString(htmlFile, "ISO-8859-1"); +final String htmlMsg1 = FileUtils.readFileToString(htmlFile, StandardCharsets.ISO_8859_1.name()); final ImageHtmlEmail email = (ImageHtmlEmail) create(ImageHtmlEmail.class); email.setDataSourceResolver(new DataSourceUrlResolver(htmlFile.getParentFile().toURI().toURL(), false)); diff --git a/src/test/java/org/apache/commons/mail/EmailTest.java b/src/test/java/org/apache/commons/mail/EmailTest.java index 458d184..b459406 100644 --- a/src/test/java/org/apache/commons/mail/EmailTest.java +++ b/src/test/java/org/apache/commons/mail/EmailTest.java @@ -412,7 +412,7 @@ public class EmailTest extends AbstractEmailTest { email.addTo("c...@d.com"); email.setSubject("test mail"); -email.setCharset("ISO-8859-1"); +email.setCharset(StandardCharsets.ISO_8859_1.name()); final File png = new File("./target/test-classes/images/logos/maven-feather.png"); email.setContent(png, "image/png"); email.buildMimeMessage(); @@ -438,7 +438,7 @@ public class EmailTest extends AbstractEmailTest { email.addTo("c...@d.com"); email.setSubject("test mail"); -email.setCharset("ISO-8859-1"); +email.setCharset(StandardCharsets.ISO_8859_1.name()); email.setContent("test content", "text/plain"); email.buildMimeMessage(); final MimeMessage msg = email.getMimeMessage(); @@ -459,7 +459,7 @@ public class EmailTest extends AbstractEmailTest { email.addTo("c...@d.com"); email.setSubject("test mail"); -email.setCharset("ISO-8859-1"); +email.setCharset(StandardCharsets.ISO_8859_1.name()); email.setContent("test content", "text/plain; charset=US-ASCII"); email.buildMimeMessage(); final MimeMessage msg = email.getMimeMessage(); @@ -480,7 +480,7 @@ public class EmailTest extends AbstractEmailTest { email.addTo("c...@d.com"); email.setSubject("test mail"); -email.setCharset("ISO-8859-1"); +email.setCharset(StandardCharsets.ISO_8859_1.name()); email.setContent("test content", "application/octet-stream"); email.buildMimeMessage(); final MimeMessage msg = email.getMimeMessage();
(commons-configuration) branch master updated: Use StandardCharsets
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-configuration.git The following commit(s) were added to refs/heads/master by this push: new 111e1f4b Use StandardCharsets 111e1f4b is described below commit 111e1f4b3ff76e0d476d7b733ec762d97fc13003 Author: Gary Gregory AuthorDate: Sat Dec 23 11:13:45 2023 -0500 Use StandardCharsets --- .../org/apache/commons/configuration2/PropertiesConfiguration.java | 3 ++- .../java/org/apache/commons/configuration2/TestXMLConfiguration.java | 2 +- .../commons/configuration2/builder/TestFileBasedBuilderParameters.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java b/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java index 7df8c981..3084ae76 100644 --- a/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java +++ b/src/main/java/org/apache/commons/configuration2/PropertiesConfiguration.java @@ -24,6 +24,7 @@ import java.io.LineNumberReader; import java.io.Reader; import java.io.Writer; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -995,7 +996,7 @@ public class PropertiesConfiguration extends BaseConfiguration implements FileBa /** * The default encoding (ISO-8859-1 as specified by https://docs.oracle.com/javase/8/docs/api/java/util/Properties.html) */ -public static final String DEFAULT_ENCODING = "ISO-8859-1"; +public static final String DEFAULT_ENCODING = StandardCharsets.ISO_8859_1.name(); /** Constant for the supported comment characters. */ static final String COMMENT_CHARS = "#!"; diff --git a/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java b/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java index 952fecc8..01ba754d 100644 --- a/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java +++ b/src/test/java/org/apache/commons/configuration2/TestXMLConfiguration.java @@ -92,7 +92,7 @@ public class TestXMLConfiguration { private static final String CATALOG_FILES = ConfigurationAssert.getTestFile("catalog.xml").getAbsolutePath(); /** Constant for the used encoding. */ -static final String ENCODING = "ISO-8859-1"; +static final String ENCODING = StandardCharsets.ISO_8859_1.name(); /** Constant for the test system ID. */ static final String SYSTEM_ID = "properties.dtd"; diff --git a/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedBuilderParameters.java b/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedBuilderParameters.java index 50ef47c3..764b27e0 100644 --- a/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedBuilderParameters.java +++ b/src/test/java/org/apache/commons/configuration2/builder/TestFileBasedBuilderParameters.java @@ -242,7 +242,7 @@ public class TestFileBasedBuilderParameters { */ @Test public void testSetEncoding() { -final String enc = "ISO-8859-1"; +final String enc = StandardCharsets.ISO_8859_1.name(); final FileBasedBuilderParametersImpl params = new FileBasedBuilderParametersImpl(); assertSame(params, params.setEncoding(enc)); assertSame(enc, params.getFileHandler().getEncoding());
(commons-imaging) branch master updated: [IMAGING-355] Add option to skip reading GIF metadata #301
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git The following commit(s) were added to refs/heads/master by this push: new 9d6c4ca1 [IMAGING-355] Add option to skip reading GIF metadata #301 9d6c4ca1 is described below commit 9d6c4ca1a6aa6208a3a63c923e9e6719746b58c2 Author: Gary Gregory AuthorDate: Sat Dec 23 10:46:56 2023 -0500 [IMAGING-355] Add option to skip reading GIF metadata #301 --- src/changes/changes.xml | 3 +++ .../apache/commons/imaging/formats/gif/GifImageParser.java | 12 ++-- .../commons/imaging/formats/gif/GifImagingParameters.java| 5 + .../org/apache/commons/imaging/formats/gif/GifReadTest.java | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index aa7220c7..2a7bcbd0 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -94,6 +94,9 @@ The type attribute can be add,update,fix,remove. Basic WebP Support #254. + +Add option to skip reading GIF metadata #301. + Bump actions/cache #225, #228, #239, #240. diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java index 662cb861..4d31aa37 100644 --- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java @@ -409,11 +409,7 @@ public class GifImageParser extends AbstractImageParser im @Override public ImageInfo getImageInfo(final ByteSource byteSource, final GifImagingParameters params) throws ImagingException, IOException { -boolean stopReadingBeforeImageData = true; -if (params != null) { -stopReadingBeforeImageData = params.getStopReadingBeforeImageData(); -} -final GifImageContents blocks = readFile(byteSource, stopReadingBeforeImageData); +final GifImageContents blocks = readFile(byteSource, GifImagingParameters.getStopReadingBeforeImageData(params)); final GifHeaderInfo bhi = blocks.gifHeaderInfo; if (bhi == null) { @@ -488,11 +484,7 @@ public class GifImageParser extends AbstractImageParser im @Override public ImageMetadata getMetadata(final ByteSource byteSource, final GifImagingParameters params) throws ImagingException, IOException { -boolean stopReadingBeforeImageData = true; -if (params != null) { -stopReadingBeforeImageData = params.getStopReadingBeforeImageData(); -} -final GifImageContents imageContents = readFile(byteSource, stopReadingBeforeImageData); +final GifImageContents imageContents = readFile(byteSource, GifImagingParameters.getStopReadingBeforeImageData(params)); final GifHeaderInfo bhi = imageContents.gifHeaderInfo; if (bhi == null) { diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImagingParameters.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImagingParameters.java index 1bca589b..c759614c 100644 --- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImagingParameters.java +++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImagingParameters.java @@ -25,6 +25,11 @@ import org.apache.commons.imaging.common.XmpImagingParameters; * @since 1.0-alpha3 */ public class GifImagingParameters extends XmpImagingParameters { + +public static boolean getStopReadingBeforeImageData(final GifImagingParameters params) { +return params != null && params.getStopReadingBeforeImageData(); +} + private boolean stopReadingBeforeImageData; public boolean getStopReadingBeforeImageData() { diff --git a/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java b/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java index 561fd974..17978815 100644 --- a/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java @@ -146,8 +146,8 @@ public class GifReadTest extends AbstractGifTest { final ImageMetadata metadata = Imaging.getMetadata(imageFile); assertNotNull(metadata); assertTrue(metadata instanceof GifImageMetadata); -assertTrue(((GifImageMetadata)metadata).getWidth() > 0); -assertTrue(((GifImageMetadata)metadata).getHeight() > 0); +assertTrue(((GifImageMetadata) metadata).getWidth() > 0); +assertTrue(((GifImageMetadata) metadata).getHeight() > 0); assertNotNull(metadata.getItems()); }
(commons-imaging) branch master updated (df36623d -> 888d6faf)
This is an automated email from the ASF dual-hosted git repository. ggregory pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git from df36623d Merge pull request #345 from apache/dependabot/github_actions/github/codeql-action-3.22.12 new a4983f3f IMAGING-355 - Large animated GIF takes too much heap memory in getMetadata new 52a6eead IMAGING-355 - Large animated GIF takes too much heap memory in getMetadata new 593976a2 Merge branch 'master' into IMAGING-355 new 2d267534 Use final and format tweak new c0c98466 Use final and sort methods new 888d6faf Merge pull request #301 from andrewmkhoury/IMAGING-355 The 2345 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../apache/commons/imaging/formats/gif/GifImageParser.java | 12 ++-- .../commons/imaging/formats/gif/GifImagingParameters.java | 11 ++- .../org/apache/commons/imaging/formats/gif/GifReadTest.java | 13 + 3 files changed, 29 insertions(+), 7 deletions(-)
(commons-math) branch master updated: Trigger on relevant source changes
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new 78dcee60d Trigger on relevant source changes 78dcee60d is described below commit 78dcee60d81b1a7c6d29b504c0573591b36f0c5d Author: Sebb AuthorDate: Sat Dec 23 15:32:42 2023 + Trigger on relevant source changes --- .github/workflows/maven_legacy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven_legacy.yml b/.github/workflows/maven_legacy.yml index 4f38d474f..7da8f57d5 100644 --- a/.github/workflows/maven_legacy.yml +++ b/.github/workflows/maven_legacy.yml @@ -22,6 +22,7 @@ on: push: include: - '**/workflows/maven_legacy.yml' + - 'commons-math-legacy/**' permissions: contents: read
(commons-math) branch master updated: Show limit in message [skip ci]
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new b0cefc56c Show limit in message [skip ci] b0cefc56c is described below commit b0cefc56c67bd41ec9f14311f058d319b05c0312 Author: Sebb AuthorDate: Sat Dec 23 15:19:52 2023 + Show limit in message [skip ci] --- .../optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java index b1ff2bf79..15ef3da80 100644 --- a/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java +++ b/commons-math-legacy/src/test/java/org/apache/commons/math4/legacy/optim/nonlinear/scalar/MultiStartMultivariateOptimizerTest.java @@ -73,8 +73,8 @@ public class MultiStartMultivariateOptimizerTest { } final int numEval = optimizer.getEvaluations(); -Assert.assertTrue("n=" + numEval, numEval > 750); -Assert.assertTrue("n=" + numEval, numEval < 950); +Assert.assertTrue("exp: n > 750, act: " + numEval, numEval > 750); +Assert.assertTrue("exp: n < 950, act: " + numEval, numEval < 950); Assert.assertEquals(3.1267527, optimum.getValue(), 1e-8); }
(commons-math) branch master updated: Add separate on-demand test for Legacy code
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new a8e7c2b8a Add separate on-demand test for Legacy code a8e7c2b8a is described below commit a8e7c2b8aaf0b460e0a921ac29aeaa2cfb71b9c9 Author: Sebb AuthorDate: Sat Dec 23 14:57:05 2023 + Add separate on-demand test for Legacy code --- .github/workflows/maven_legacy.yml | 50 ++ 1 file changed, 50 insertions(+) diff --git a/.github/workflows/maven_legacy.yml b/.github/workflows/maven_legacy.yml new file mode 100644 index 0..4f38d474f --- /dev/null +++ b/.github/workflows/maven_legacy.yml @@ -0,0 +1,50 @@ +# 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. + +name: Java CI (Legacy only) + +on: + # allow direct trigger + workflow_dispatch: + # self trigger + push: +include: + - '**/workflows/maven_legacy.yml' + +permissions: + contents: read + +jobs: + build: + +runs-on: ${{ matrix.os }} +strategy: + fail-fast: false # Run all the versions, but show overall status as failed if one fails + matrix: +os: [ ubuntu-latest, macos-latest, windows-latest ] +java: [ 8, 11, 17 ] + +steps: +- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + with: +persist-credentials: false +- name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0 + with: +distribution: temurin +java-version: ${{ matrix.java }} +cache: 'maven' +- name: Build with Maven + run: mvn -V --no-transfer-progress clean test -pl commons-math-legacy
(commons-math) branch master updated: Are the failures OS-related?
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new ced5f2669 Are the failures OS-related? ced5f2669 is described below commit ced5f266960f1d5e10a950b19f412cb73500ffbc Author: Sebb AuthorDate: Sat Dec 23 14:35:20 2023 + Are the failures OS-related? --- .github/workflows/maven.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index d24aaf24f..c644b22f8 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -34,10 +34,11 @@ permissions: jobs: build: -runs-on: ubuntu-latest +runs-on: ${{ matrix.os }} strategy: fail-fast: false # Run all the versions, but show overall status as failed if one fails matrix: +os: [ ubuntu-latest, macos-latest, windows-latest ] java: [ 8, 11, 17 ] steps:
(commons-math) branch master updated: Fix up triggers [skip ci]
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new 9fa9a9188 Fix up triggers [skip ci] 9fa9a9188 is described below commit 9fa9a91888f678444242a31745456e122a88a340 Author: Sebb AuthorDate: Sat Dec 23 14:32:29 2023 + Fix up triggers [skip ci] --- .github/workflows/coverage.yml | 13 - .github/workflows/maven.yml| 13 - 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 7c7005912..d1892882b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -15,7 +15,18 @@ name: Coverage -on: [push, pull_request] +on: + # allow direct trigger + workflow_dispatch: + # Don't trigger if other workfiles change + push: +paths-ignore: + - '**/workflows/*.yml' + - '!**/workflows/coverage.yml' + pull_request: +paths-ignore: + - '**/workflows/*.yml' + - '!**/workflows/coverage.yml' permissions: contents: read diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9e6879d23..d24aaf24f 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -15,7 +15,18 @@ name: Java CI -on: [push, pull_request] +on: + # allow direct trigger + workflow_dispatch: + # Don't trigger if other workfiles change + push: +paths-ignore: + - '**/workflows/*.yml' + - '!**/workflows/maven.yml' + pull_request: +paths-ignore: + - '**/workflows/*.yml' + - '!**/workflows/maven.yml' permissions: contents: read
(commons-math) branch master updated: Try to avoid unnecessary workflow fail
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new 2de43632d Try to avoid unnecessary workflow fail 2de43632d is described below commit 2de43632dfd3360157482690dae6719422d31381 Author: Sebb AuthorDate: Sat Dec 23 14:16:23 2023 + Try to avoid unnecessary workflow fail --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 938dd702f..7c7005912 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: -java: [ 8 ] +java: [ 11 ] # Use 11 rather than 8, as 8 fails currently steps: - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
(commons-math) branch master updated: Did any version fail?
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new 1220a9554 Did any version fail? 1220a9554 is described below commit 1220a95540911228d49474417f3d695945ca1305 Author: Sebb AuthorDate: Sat Dec 23 14:04:21 2023 + Did any version fail? --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 3dc4cdf04..9e6879d23 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,8 +24,8 @@ jobs: build: runs-on: ubuntu-latest -continue-on-error: true # Test if failure applies to all Java versions strategy: + fail-fast: false # Run all the versions, but show overall status as failed if one fails matrix: java: [ 8, 11, 17 ]
(commons-math) branch master updated: Test if failure occurs on all Java versions
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git The following commit(s) were added to refs/heads/master by this push: new b9b5f1876 Test if failure occurs on all Java versions b9b5f1876 is described below commit b9b5f18769f44b3ed98252c0353eba84890e927f Author: Sebb AuthorDate: Sat Dec 23 13:44:32 2023 + Test if failure occurs on all Java versions --- .github/workflows/maven.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 5926a84e8..3dc4cdf04 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -24,6 +24,7 @@ jobs: build: runs-on: ubuntu-latest +continue-on-error: true # Test if failure applies to all Java versions strategy: matrix: java: [ 8, 11, 17 ]
(commons-parent) branch master updated: Add links to component builds
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-parent.git The following commit(s) were added to refs/heads/master by this push: new 6e7bbb1 Add links to component builds 6e7bbb1 is described below commit 6e7bbb10a14c41f77ed0631db82abd2c79374e06 Author: Sebb AuthorDate: Sat Dec 23 13:32:26 2023 + Add links to component builds --- COMPONENTS.md | 47 +++ 1 file changed, 47 insertions(+) diff --git a/COMPONENTS.md b/COMPONENTS.md new file mode 100644 index 000..5d97078 --- /dev/null +++ b/COMPONENTS.md @@ -0,0 +1,47 @@ +# Commons components + +The table below is currently manually maintained from the corresponding component README files, and may get out of date. Please report any errors to the Commons Project. + +| Component | Java CI | Coverage Status | Maven Central | Javadocs | CodeQL | OpenSSF Scorecard | +| --- | --- | ---| --- | --- |--- | --- | +| [bcel](https://github.com/apache/commons-bcel) | [![Java CI](https://github.com/apache/commons-bcel/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-bcel/actions/workflows/maven.yml) | [![Coverage Status](https://codecov.io/gh/apache/commons-bcel/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-bcel) | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.bcel/bcel/badge.svg?gav=true)](https://maven-badges.heroku [...] +|[beanutils](https://github.com/apache/commons-beanutils)|[![Java CI](https://github.com/apache/commons-beanutils/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-beanutils/actions/workflows/maven.yml)|[![Coverage Status](https://codecov.io/gh/apache/commons-beanutils/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-beanutils/branch/master)|[![Maven Central](https://maven-badges.herokuapp.com/maven-central/commons-beanutils/commons-beanuti [...] +|[bsf](https://github.com/apache/commons-bsf)|[![Java CI](https://github.com/apache/commons-bsf/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-bsf/actions/workflows/maven.yml)|[![Coverage Status](https://coveralls.io/repos/apache/commons-bsf/badge.svg)](https://coveralls.io/r/apache/commons-bsf)|[![Maven Central](https://maven-badges.herokuapp.com/maven-central/bsf/bsf/badge.svg)](https://maven-badges.herokuapp.com/maven-central/bsf/bsf/)|[![Javadocs](https://j [...] +|[cli](https://github.com/apache/commons-cli)|[![Java CI](https://github.com/apache/commons-cli/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-cli/actions/workflows/maven.yml)|[![Coverage Status](https://codecov.io/gh/apache/commons-cli/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-cli/branch/master)|[![Maven Central](https://maven-badges.herokuapp.com/maven-central/commons-cli/commons-cli/badge.svg?gav=true)](https://maven-badges.her [...] +|[codec](https://github.com/apache/commons-codec)|[![Java CI](https://github.com/apache/commons-codec/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-codec/actions/workflows/maven.yml)|[![Coverage Status](https://codecov.io/gh/apache/commons-codec/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-codec)|[![Maven Central](https://maven-badges.herokuapp.com/maven-central/commons-codec/commons-codec/badge.svg?gav=true)](https://maven-badges.h [...] +|[collections](https://github.com/apache/commons-collections)|[![Java CI](https://github.com/apache/commons-collections/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-collections/actions/workflows/maven.yml)|[![Coverage Status](https://codecov.io/gh/apache/commons-collections/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-collections/branch/master)|[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/co [...] +|[compress](https://github.com/apache/commons-compress)|[![Java CI](https://github.com/apache/commons-compress/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-compress/actions/workflows/maven.yml)|[![Coverage Status](https://codecov.io/gh/apache/commons-compress/branch/master/graph/badge.svg)](https://app.codecov.io/gh/apache/commons-compress)|[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.apache.commons/commons-compress/badge.svg?gav=tru [...] +|[configuration](https://github.com/apache/commons-configuration)|[![Java CI](https://github.com/apache/commons-configuration/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-configuration/actions/workflows/maven.yml)|[![Coverage
(commons-rdf) branch master updated: Add coverage report
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rdf.git The following commit(s) were added to refs/heads/master by this push: new c03feb10 Add coverage report c03feb10 is described below commit c03feb104becbb81762f7c2a85cb668ee099da20 Author: Sebb AuthorDate: Sat Dec 23 12:35:01 2023 + Add coverage report --- .github/workflows/coverage.yml | 61 ++ 1 file changed, 61 insertions(+) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index ..6dca9bab --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,61 @@ +# 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. + +name: Coverage + +on: + workflow_dispatch: + push: +paths-ignore: + - '**/workflows/*.yml' + - '!**/workflows/coverage.yml' + pull_request: +paths-ignore: + - '**/workflows/*.yml' + - '!**/workflows/coverage.yml' + +permissions: + contents: read + +jobs: + build: + +runs-on: ubuntu-latest +strategy: + matrix: +java: [ 8 ] + +steps: +- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: +persist-credentials: false +- uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 + with: +path: ~/.m2/repository +key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} +restore-keys: | + ${{ runner.os }}-maven- +- name: Set up JDK ${{ matrix.java }} + uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + with: +distribution: 'temurin' +java-version: ${{ matrix.java }} +- name: Build with Maven + run: mvn --show-version --batch-mode --no-transfer-progress test jacoco:report + +- name: Upload coverage to Codecov + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: +files: ./target/site/jacoco/jacoco.xml
(commons-rdf) branch master updated: Wrong URL
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rdf.git The following commit(s) were added to refs/heads/master by this push: new 8c18eee6 Wrong URL 8c18eee6 is described below commit 8c18eee62d40f95c1fb26365136d80d0e79f4f55 Author: Sebb AuthorDate: Sat Dec 23 12:33:00 2023 + Wrong URL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30629a98..e1d9b341 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Apache Commons RDF [![Java CI](https://github.com/apache/commons-rdf/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-rdf/actions/workflows/maven.yml) -[![Coverage Status](https://codecov.io/gh/apache/commons-rdf/branch/master/graph/badge.svg?branch=master=github)](https://github.com/apache/commons-rdf/actions/workflows/codeql-analysis.yml) +[![Coverage Status](https://codecov.io/gh/apache/commons-rdf/branch/master/graph/badge.svg?branch=master=github)](https://app.codecov.io/gh/apache/commons-rdf) [Commons RDF](https://commons.apache.org/proper/commons-rdf/) aims to provide a common library for [RDF 1.1](http://www.w3.org/TR/rdf11-concepts/) with implementations
(commons-rdf) branch master updated: Add link to workfile
This is an automated email from the ASF dual-hosted git repository. sebb pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-rdf.git The following commit(s) were added to refs/heads/master by this push: new d6671359 Add link to workfile d6671359 is described below commit d667135910b1cc56ae35ffe813d49a2903cacb4d Author: Sebb AuthorDate: Sat Dec 23 12:24:49 2023 + Add link to workfile --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7bf02a0..30629a98 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Apache Commons RDF [![Java CI](https://github.com/apache/commons-rdf/actions/workflows/maven.yml/badge.svg)](https://github.com/apache/commons-rdf/actions/workflows/maven.yml) -[![Coverage Status](https://codecov.io/gh/apache/commons-rdf/branch/master/graph/badge.svg?branch=master=github)] +[![Coverage Status](https://codecov.io/gh/apache/commons-rdf/branch/master/graph/badge.svg?branch=master=github)](https://github.com/apache/commons-rdf/actions/workflows/codeql-analysis.yml) [Commons RDF](https://commons.apache.org/proper/commons-rdf/) aims to provide a common library for [RDF 1.1](http://www.w3.org/TR/rdf11-concepts/) with implementations
(commons-statistics) 01/06: STATISTICS-81: Add StatisticResult interface
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git commit 4b18caee0b82cf6b326b4dcf66a5a161598db384 Author: Alex Herbert AuthorDate: Mon Dec 18 11:19:20 2023 + STATISTICS-81: Add StatisticResult interface The result of a statistic is supported as int/long/double/BigInteger. --- .../statistics/descriptive/DoubleStatistic.java| 7 +- .../statistics/descriptive/StatisticResult.java| 101 + .../commons/statistics/descriptive/Statistics.java | 30 +++- .../descriptive/StatisticResultTest.java | 158 + src/conf/pmd/pmd-ruleset.xml | 7 + 5 files changed, 297 insertions(+), 6 deletions(-) diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistic.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistic.java index 4baa9c9..6be034c 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistic.java +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistic.java @@ -17,15 +17,12 @@ package org.apache.commons.statistics.descriptive; import java.util.function.DoubleConsumer; -import java.util.function.DoubleSupplier; /** - * Represents a state object for computing a single {@code Statistic} over {@code double} valued input(s). - * - * Base interface implemented by all statistics. + * Represents a state object for computing a statistic over {@code double} valued input(s). * * @since 1.1 */ -public interface DoubleStatistic extends DoubleConsumer, DoubleSupplier { +public interface DoubleStatistic extends DoubleConsumer, StatisticResult { // Composite interface } diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java new file mode 100644 index 000..56108e7 --- /dev/null +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java @@ -0,0 +1,101 @@ +/* + * 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.statistics.descriptive; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.function.DoubleSupplier; +import java.util.function.IntSupplier; +import java.util.function.LongSupplier; + +/** + * Represents the result of a statistic computed over a set of values. + * + * Base interface implemented by all statistics. + * + * @since 1.1 + */ +@FunctionalInterface +public interface StatisticResult extends DoubleSupplier, IntSupplier, LongSupplier { +/** + * {@inheritDoc} + * + * The default implementation uses the closest representable {@code int} value of + * the {@link #getAsDouble()} result. In the event of ties the result is towards + * positive infinity. This will raise an {@link ArithmeticException} if the closest + * integer result is not within the range {@code [-2^31, 2^31)}. + * + * @throws ArithmeticException if the {@code result} overflows an int, or is not + * finite + */ +@Override +default int getAsInt() { +// Note: Do not use (int) getAsLong() to avoid a narrowing primitive conversion. +final double x = getAsDouble(); +final double r = Statistics.roundToInteger(x); +if (r >= -0x1.0p31 && r < 0x1.0p31) { +return (int) r; +} +throw new ArithmeticException("integer overflow: " + x); +} + +/** + * {@inheritDoc} + * + * The default implementation uses the closest representable {@code long} value of + * the {@link #getAsDouble()} result. In the event of ties the result is rounded + * positive infinity. This will raise an {@link ArithmeticException} if the closest + * long integer result is not within the range {@code [-2^63, 2^63)}. + * + * @throws
(commons-statistics) 06/06: Correct javadoc in tests
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git commit 7239736fdab9864666b216f966e6bd9a53ccf78e Author: Alex Herbert AuthorDate: Sat Dec 23 10:27:46 2023 + Correct javadoc in tests --- .../descriptive/BaseDoubleStatisticTest.java | 36 +++--- .../descriptive/DoubleStatisticsTest.java | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java index a349e2f..8de8b44 100644 --- a/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java +++ b/commons-statistics-descriptive/src/test/java/org/apache/commons/statistics/descriptive/BaseDoubleStatisticTest.java @@ -51,10 +51,10 @@ import org.junit.jupiter.params.provider.MethodSource; * * {@link java.util.function.DoubleConsumer#accept accept} * {@link java.util.function.DoubleConsumer#accept accept} and - * {@link StatisticAccumulator#combine(DoubleStatistic) combine} + * {@link StatisticAccumulator#combine(StatisticResult) combine} * {@link #create(double...)} * {@link #create(double...)} and - * {@link StatisticAccumulator#combine(DoubleStatistic) combine} + * {@link StatisticAccumulator#combine(StatisticResult) combine} * * * A test implementation has to provide these method implementations: @@ -547,7 +547,7 @@ abstract class BaseDoubleStatisticTest * {@link java.util.function.DoubleConsumer#accept accept} * {@link java.util.function.DoubleConsumer#accept accept} and - * {@link StatisticAccumulator#combine(DoubleStatistic) combine} + * {@link StatisticAccumulator#combine(StatisticResult) combine} * {@link #create(double...)} * {@link #create(double...)} and - * {@link StatisticAccumulator#combine(DoubleStatistic) combine} + * {@link StatisticAccumulator#combine(StatisticResult) combine} * * * To test the {@code combine} method the data is split into approximately even groups @@ -822,7 +822,7 @@ abstract class BaseDoubleStatisticTestNote that this method uses the tolerance from {@link #getToleranceAcceptAndCombine()}. @@ -861,7 +861,7 @@ abstract class BaseDoubleStatisticTestNote: This method is similar to the @@ -1095,7 +1095,7 @@ abstract class BaseDoubleStatisticTestNote: This method is similar to the * {@link #testArrayAndCombine(double[][], double, DoubleTolerance)} method and uses @@ -1205,7 +1205,7 @@ abstract class BaseDoubleStatisticTest
(commons-statistics) branch master updated (d6e94e9 -> 7239736)
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a change to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git from d6e94e9 Pin GH plugin versions new 4b18cae STATISTICS-81: Add StatisticResult interface new 3b2ae69 STATISTICS-81: Add integer min and max implementation new 3fda895 STATISTICS-81: Add integer mean and variance implementation new 8e1ec4c Move default StatisticResult implementations to IntMath new 8c2cf0b Drop DoubleStatisticAccumulator interface new 7239736 Correct javadoc in tests The 6 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .github/workflows/maven.yml| 14 +- .../statistics/descriptive/DoubleStatistic.java|7 +- .../statistics/descriptive/DoubleStatistics.java |2 +- .../statistics/descriptive/FirstMoment.java|4 +- .../statistics/descriptive/GeometricMean.java |6 +- .../commons/statistics/descriptive/Int128.java | 237 +++ .../commons/statistics/descriptive/IntMath.java| 391 + .../descriptive/{Max.java => IntMax.java} | 61 +- .../commons/statistics/descriptive/IntMean.java| 144 ++ .../descriptive/{Min.java => IntMin.java} | 61 +- .../{package-info.java => IntStatistic.java} |9 +- .../statistics/descriptive/IntVariance.java| 248 +++ .../commons/statistics/descriptive/Kurtosis.java |6 +- .../descriptive/{Max.java => LongMax.java} | 74 +- .../commons/statistics/descriptive/LongMean.java | 141 ++ .../descriptive/{Min.java => LongMin.java} | 70 +- .../{package-info.java => LongStatistic.java} |9 +- .../statistics/descriptive/LongVariance.java | 226 +++ .../apache/commons/statistics/descriptive/Max.java |8 +- .../commons/statistics/descriptive/Mean.java |6 +- .../apache/commons/statistics/descriptive/Min.java |8 +- .../commons/statistics/descriptive/Product.java|6 +- .../commons/statistics/descriptive/Skewness.java |6 +- .../statistics/descriptive/StandardDeviation.java |6 +- ...cAccumulator.java => StatisticAccumulator.java} |6 +- .../statistics/descriptive/StatisticResult.java| 79 + .../commons/statistics/descriptive/Statistics.java | 35 +- .../apache/commons/statistics/descriptive/Sum.java |6 +- .../descriptive/SumOfCubedDeviations.java |4 +- .../descriptive/SumOfFourthDeviations.java |4 +- .../commons/statistics/descriptive/SumOfLogs.java |6 +- .../descriptive/SumOfSquaredDeviations.java|4 +- .../statistics/descriptive/SumOfSquares.java |6 +- .../commons/statistics/descriptive/UInt128.java| 238 +++ .../commons/statistics/descriptive/UInt192.java| 247 +++ .../commons/statistics/descriptive/UInt96.java | 155 ++ .../commons/statistics/descriptive/Variance.java |6 +- .../descriptive/BaseDoubleStatisticTest.java | 52 +- ...tatisticTest.java => BaseIntStatisticTest.java} | 706 ...atisticTest.java => BaseLongStatisticTest.java} | 706 .../statistics/descriptive/BaseStatisticTest.java | 347 .../descriptive/BigIntegerStatisticResult.java}| 29 +- .../descriptive/DoubleStatisticsTest.java | 10 +- .../commons/statistics/descriptive/Int128Test.java | 173 ++ .../statistics/descriptive/IntMathTest.java| 207 +++ .../descriptive/{MinTest.java => IntMaxTest.java} | 45 +- .../statistics/descriptive/IntMeanTest.java| 116 ++ .../descriptive/{MinTest.java => IntMinTest.java} | 45 +- .../descriptive/IntStatisticResult.java} | 29 +- .../statistics/descriptive/IntVarianceTest.java| 191 +++ .../descriptive/{MinTest.java => LongMaxTest.java} | 45 +- .../statistics/descriptive/LongMeanTest.java | 124 ++ .../descriptive/{MinTest.java => LongMinTest.java} | 45 +- .../descriptive/LongStatisticResult.java} | 29 +- .../statistics/descriptive/LongVarianceTest.java | 203 +++ .../statistics/descriptive/ResultType.java}| 16 +- .../descriptive/StatisticResultTest.java | 158 ++ .../descriptive/SumOfCubedDeviationsWrapper.java |2 +- .../descriptive/SumOfFourthDeviationsWrapper.java |2 +- .../commons/statistics/descriptive/TestHelper.java | 334 .../statistics/descriptive/UInt128Test.java| 239 +++ .../statistics/descriptive/UInt192Test.java| 208 +++ .../commons/statistics/descriptive/UInt96Test.java | 140 ++ commons-statistics-examples/examples-jmh/pom.xml | 25 +- .../examples/jmh/descriptive/Int128.java | 276 .../examples/jmh/descriptive/IntMath.java | 309
(commons-statistics) 05/06: Drop DoubleStatisticAccumulator interface
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git commit 8c2cf0b5fe56410d8c63abe2cdd780112c91d617 Author: Alex Herbert AuthorDate: Thu Dec 21 22:04:01 2023 + Drop DoubleStatisticAccumulator interface All StatisticResult implementations can use the StatisticAccumulator interface; the argument type for the statistic computation (int/long/double) is not relevant to the accumulator combine method. --- .../descriptive/DoubleStatisticAccumulator.java| 35 - .../statistics/descriptive/DoubleStatistics.java | 2 +- .../statistics/descriptive/FirstMoment.java| 4 +- .../statistics/descriptive/GeometricMean.java | 6 +-- .../commons/statistics/descriptive/Kurtosis.java | 6 +-- .../apache/commons/statistics/descriptive/Max.java | 6 +-- .../commons/statistics/descriptive/Mean.java | 6 +-- .../apache/commons/statistics/descriptive/Min.java | 6 +-- .../commons/statistics/descriptive/Product.java| 6 +-- .../commons/statistics/descriptive/Skewness.java | 6 +-- .../statistics/descriptive/StandardDeviation.java | 6 +-- .../apache/commons/statistics/descriptive/Sum.java | 6 +-- .../descriptive/SumOfCubedDeviations.java | 4 +- .../descriptive/SumOfFourthDeviations.java | 4 +- .../commons/statistics/descriptive/SumOfLogs.java | 6 +-- .../descriptive/SumOfSquaredDeviations.java| 4 +- .../statistics/descriptive/SumOfSquares.java | 6 +-- .../commons/statistics/descriptive/Variance.java | 6 +-- .../descriptive/BaseDoubleStatisticTest.java | 44 +++--- .../descriptive/DoubleStatisticsTest.java | 8 ++-- .../descriptive/SumOfCubedDeviationsWrapper.java | 2 +- .../descriptive/SumOfFourthDeviationsWrapper.java | 2 +- 22 files changed, 73 insertions(+), 108 deletions(-) diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatisticAccumulator.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatisticAccumulator.java deleted file mode 100644 index d06207c..000 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatisticAccumulator.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.statistics.descriptive; - -/** - * A mutable result container that accumulates a {@link DoubleStatistic}. - * - * @param {@link DoubleStatistic} being accumulated. - * - * @since 1.1 - */ -public interface DoubleStatisticAccumulator { - -/** - * Combines the state of the {@code other} statistic into this one. - * - * @param other Another statistic to be combined. - * @return {@code this} instance after combining {@code other}. - */ -T combine(T other); -} diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java index 7ae57c8..299f52a 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/DoubleStatistics.java @@ -681,7 +681,7 @@ public final class DoubleStatistics implements DoubleConsumer { * @param a LHS. * @param b RHS. */ -private static > void combine(T a, T b) { +private static > void combine(T a, T b) { if (a != null) { a.combine(b); } diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java index 18d4ed2..5fe08f5 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/FirstMoment.java +++
(commons-statistics) 04/06: Move default StatisticResult implementations to IntMath
This is an automated email from the ASF dual-hosted git repository. aherbert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-statistics.git commit 8e1ec4cfb3ce498bde9f0908054ce2c3f9b36e07 Author: Alex Herbert AuthorDate: Thu Dec 21 20:38:05 2023 + Move default StatisticResult implementations to IntMath --- .../statistics/descriptive/StatisticResult.java| 50 ++ .../commons/statistics/descriptive/Statistics.java | 29 - .../statistics/descriptive/IntMathTest.java| 3 +- src/conf/pmd/pmd-ruleset.xml | 2 +- 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java index 56108e7..79af4ca 100644 --- a/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java +++ b/commons-statistics-descriptive/src/main/java/org/apache/commons/statistics/descriptive/StatisticResult.java @@ -16,7 +16,6 @@ */ package org.apache.commons.statistics.descriptive; -import java.math.BigDecimal; import java.math.BigInteger; import java.util.function.DoubleSupplier; import java.util.function.IntSupplier; @@ -35,67 +34,46 @@ public interface StatisticResult extends DoubleSupplier, IntSupplier, LongSuppli * {@inheritDoc} * * The default implementation uses the closest representable {@code int} value of - * the {@link #getAsDouble()} result. In the event of ties the result is towards - * positive infinity. This will raise an {@link ArithmeticException} if the closest - * integer result is not within the range {@code [-2^31, 2^31)}. + * the {@link #getAsDouble()} {@code result}. In the event of ties the result is + * rounded towards positive infinity. This will raise an {@link ArithmeticException} + * if the closest integer result is not within the range {@code [-2^31, 2^31)}. * - * @throws ArithmeticException if the {@code result} overflows an int, or is not + * @throws ArithmeticException if the {@code result} overflows an {@code int} or is not * finite */ @Override default int getAsInt() { -// Note: Do not use (int) getAsLong() to avoid a narrowing primitive conversion. -final double x = getAsDouble(); -final double r = Statistics.roundToInteger(x); -if (r >= -0x1.0p31 && r < 0x1.0p31) { -return (int) r; -} -throw new ArithmeticException("integer overflow: " + x); +return IntMath.toIntExact(getAsDouble()); } /** * {@inheritDoc} * * The default implementation uses the closest representable {@code long} value of - * the {@link #getAsDouble()} result. In the event of ties the result is rounded - * positive infinity. This will raise an {@link ArithmeticException} if the closest - * long integer result is not within the range {@code [-2^63, 2^63)}. + * the {@link #getAsDouble()} {@code result}. In the event of ties the result is + * rounded towards positive infinity. This will raise an {@link ArithmeticException} + * if the closest integer result is not within the range {@code [-2^63, 2^63)}. * - * @throws ArithmeticException if the {@code result} overflows a long, or is not + * @throws ArithmeticException if the {@code result} overflows a {@code long} or is not * finite */ @Override default long getAsLong() { -final double x = getAsDouble(); -final double r = Statistics.roundToInteger(x); -if (r >= -0x1.0p63 && r < 0x1.0p63) { -return (long) r; -} -throw new ArithmeticException("long integer overflow: " + x); +return IntMath.toLongExact(getAsDouble()); } /** * Gets a result as a {@link BigInteger}. * * The default implementation uses the closest representable {@code BigInteger} - * value of the {@link #getAsDouble()} result. In the event of ties the result is - * rounded positive infinity. This will raise an {@link ArithmeticException} if the - * result is not finite. + * value of the {@link #getAsDouble()} {@code result}. In the event of ties the result + * is rounded towards positive infinity. This will raise an + * {@link ArithmeticException} if the {@code result} is not finite. * * @return a result * @throws ArithmeticException if the {@code result} is not finite */ default BigInteger getAsBigInteger() { -final double x = getAsDouble(); -if (!Double.isFinite(x)) { -throw new ArithmeticException("BigInteger overflow: " + x); -} -final double r = Statistics.roundToInteger(x); -if (r >=