Record Class ResourceInstaller.Limits

java.lang.Object
java.lang.Record
opennlp.tools.util.ResourceInstaller.Limits
Record Components:
connectTimeout - How long to wait for a connection to be established. Must be positive.
readTimeout - How long to wait for data on an established connection. Must be positive.
maxRedirects - How many http redirects to follow before failing. Must not be negative; zero rejects all redirects.
maxDownloadBytes - The largest download accepted, in bytes. Must be positive.
maxExpandedBytes - The largest expanded byte count accepted. For gzip content, this counts the entire decompressed stream; otherwise, it counts installed file content. Must be positive.
maxEntries - The largest number of archive entries accepted, counting every entry including directories, so an archive of many tiny files cannot exhaust directory entries while staying under the byte limits. Must be positive.
maxExpansionRatio - The largest expanded size accepted per compressed byte of a source, so a small archive cannot expand to the whole expansion limit. Applies to gzip and zip content; a source may always expand to 1048576L bytes regardless of it. Must be positive.
Enclosing class:
ResourceInstaller

public static record ResourceInstaller.Limits(Duration connectTimeout, Duration readTimeout, int maxRedirects, long maxDownloadBytes, long maxExpandedBytes, long maxEntries, long maxExpansionRatio) extends Record
Safety limits and network behavior for one installation.
Since:
3.0.0
  • Field Details

    • MAX_DOWNLOAD_BYTES_PROPERTY

      public static final String MAX_DOWNLOAD_BYTES_PROPERTY
      The system property overriding the default download limit in bytes.
      See Also:
    • MAX_EXPANDED_BYTES_PROPERTY

      public static final String MAX_EXPANDED_BYTES_PROPERTY
      The system property overriding the default expansion limit in bytes.
      See Also:
    • MAX_ENTRIES_PROPERTY

      public static final String MAX_ENTRIES_PROPERTY
      The system property overriding the default archive entry limit.
      See Also:
    • MAX_EXPANSION_RATIO_PROPERTY

      public static final String MAX_EXPANSION_RATIO_PROPERTY
      The system property overriding the default expansion ratio.
      See Also:
    • DEFAULT

      public static final ResourceInstaller.Limits DEFAULT
      The limits applied when none are given: 20 second connect timeout, 60 second read timeout, at most 5 redirects, a 1 GiB download limit, a 4 GiB expansion limit, 100000 archive entries, and an expansion ratio of 100. Each limit can be raised or lowered at startup through its system property (MAX_DOWNLOAD_BYTES_PROPERTY, MAX_EXPANDED_BYTES_PROPERTY, MAX_ENTRIES_PROPERTY, MAX_EXPANSION_RATIO_PROPERTY), read once at class load; a value that is absent, not a number, or not positive falls back to the built-in default.
  • Constructor Details

    • Limits

      public Limits(Duration connectTimeout, Duration readTimeout, int maxRedirects, long maxDownloadBytes, long maxExpandedBytes, long maxEntries, long maxExpansionRatio)
      Validates the limit values before constructing an instance.
      Parameters:
      connectTimeout - How long to wait for a connection to be established.
      readTimeout - How long to wait for data on an established connection.
      maxRedirects - How many http redirects to follow before failing.
      maxDownloadBytes - The largest download accepted, in bytes.
      maxExpandedBytes - The largest expanded byte count accepted.
      maxEntries - The largest number of archive entries accepted.
      maxExpansionRatio - The largest expanded size accepted per compressed byte.
      Throws:
      IllegalArgumentException - Thrown if either timeout is null, zero, or negative, a limit is not positive, or the redirect limit is negative.
  • Method Details

    • builder

      public static ResourceInstaller.Limits.Builder builder()
      Starts from DEFAULT so a caller can state only the limits that differ from it, instead of repeating all seven in the canonical constructor.
      Returns:
      A builder holding the default limits. Not null.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • connectTimeout

      public Duration connectTimeout()
      Returns the value of the connectTimeout record component.
      Returns:
      the value of the connectTimeout record component
    • readTimeout

      public Duration readTimeout()
      Returns the value of the readTimeout record component.
      Returns:
      the value of the readTimeout record component
    • maxRedirects

      public int maxRedirects()
      Returns the value of the maxRedirects record component.
      Returns:
      the value of the maxRedirects record component
    • maxDownloadBytes

      public long maxDownloadBytes()
      Returns the value of the maxDownloadBytes record component.
      Returns:
      the value of the maxDownloadBytes record component
    • maxExpandedBytes

      public long maxExpandedBytes()
      Returns the value of the maxExpandedBytes record component.
      Returns:
      the value of the maxExpandedBytes record component
    • maxEntries

      public long maxEntries()
      Returns the value of the maxEntries record component.
      Returns:
      the value of the maxEntries record component
    • maxExpansionRatio

      public long maxExpansionRatio()
      Returns the value of the maxExpansionRatio record component.
      Returns:
      the value of the maxExpansionRatio record component