Skip to content

Commit

Permalink
Merge branch '2.15'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Apr 5, 2023
2 parents 469374a + 931923f commit 821bb6c
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions src/main/java/tools/jackson/core/StreamReadConstraints.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public static final class Builder {
*
* @return this builder
* @throws IllegalArgumentException if the maxNestingDepth is set to a negative value
*
* @since 2.15
*/
public Builder maxNestingDepth(final int maxNestingDepth) {
if (maxNestingDepth < 0) {
Expand Down Expand Up @@ -104,8 +102,6 @@ public Builder maxNumberLength(final int maxNumLen) {
*
* @return this builder
* @throws IllegalArgumentException if the maxStringLen is set to a negative value
*
* @since 2.15
*/
public Builder maxStringLength(final int maxStringLen) {
if (maxStringLen < 0) {
Expand Down Expand Up @@ -142,7 +138,7 @@ public StreamReadConstraints build() {
/**********************************************************************
*/

StreamReadConstraints(final int maxNestingDepth, final int maxNumLen, final int maxStringLen) {
protected StreamReadConstraints(final int maxNestingDepth, final int maxNumLen, final int maxStringLen) {
_maxNestingDepth = maxNestingDepth;
_maxNumLen = maxNumLen;
_maxStringLen = maxStringLen;
Expand Down Expand Up @@ -202,7 +198,32 @@ public int getMaxStringLength() {

/*
/**********************************************************************
/* Convenience methods for validation
/* Convenience methods for validation, document limits
/**********************************************************************
*/

/**
* Convenience method that can be used to verify that the
* nesting depth does not exceed the maximum specified by this
* constraints object: if it does, a
* {@link StreamConstraintsException}
* is thrown.
*
* @param depth count of unclosed objects and arrays
*
* @throws StreamConstraintsException If depth exceeds maximum
*/
public void validateNestingDepth(int depth) throws StreamConstraintsException
{
if (depth > _maxNestingDepth) {
throw new StreamConstraintsException(String.format("Depth (%d) exceeds the maximum allowed nesting depth (%d)",
depth, _maxNestingDepth));
}
}

/*
/**********************************************************************
/* Convenience methods for validation, token lengths
/**********************************************************************
*/

Expand Down Expand Up @@ -262,23 +283,4 @@ public void validateStringLength(int length) throws StreamConstraintsException
length, _maxStringLen));
}
}

/**
* Convenience method that can be used to verify that the
* nesting depth does not exceed the maximum specified by this
* constraints object: if it does, a
* {@link StreamConstraintsException}
* is thrown.
*
* @param depth count of unclosed objects and arrays
*
* @throws StreamConstraintsException If depth exceeds maximum
*/
public void validateNestingDepth(int depth) throws StreamConstraintsException
{
if (depth > _maxNestingDepth) {
throw new StreamConstraintsException(String.format("Depth (%d) exceeds the maximum allowed nesting depth (%d)",
depth, _maxNestingDepth));
}
}
}

0 comments on commit 821bb6c

Please sign in to comment.