-
Notifications
You must be signed in to change notification settings - Fork 1.9k
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Colle… #13262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
EgorBaranovEnjoysTyping
wants to merge
26
commits into
apache:master
Choose a base branch
from
EgorBaranovEnjoysTyping:IGNITE-28747
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
546cc8a
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Colle…
EgorBaranovEnjoysTyping e23ed1d
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Overr…
EgorBaranovEnjoysTyping a50ed4c
Merge branch 'master' of https://github.com/apache/ignite into IGNITE…
EgorBaranovEnjoysTyping ba5d657
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Clean…
EgorBaranovEnjoysTyping 4a3c5a2
Merge branch 'master' of https://github.com/apache/ignite into IGNITE…
EgorBaranovEnjoysTyping 60a6cb5
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Minor…
EgorBaranovEnjoysTyping 9d3109e
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Minor…
EgorBaranovEnjoysTyping c5c2be7
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Test …
EgorBaranovEnjoysTyping 54913ee
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Style
EgorBaranovEnjoysTyping c1ec624
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix i…
EgorBaranovEnjoysTyping a884ab9
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix A…
EgorBaranovEnjoysTyping 6eb91e5
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix A…
EgorBaranovEnjoysTyping 5cd4deb
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix A…
EgorBaranovEnjoysTyping 3c84478
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix A…
EgorBaranovEnjoysTyping 7c75b1a
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix A…
EgorBaranovEnjoysTyping 06d8db0
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE. Fix a…
EgorBaranovEnjoysTyping bd1b80e
Merge branch 'master' of https://github.com/apache/ignite into IGNITE…
EgorBaranovEnjoysTyping dce089d
IGNITE-28747 Simplify GridToStringNode tree: remove CACHED_NODES, fix…
EgorBaranovEnjoysTyping 1acc9e5
IGNITE-28747 GridToStringBuilder#handleRecursion may cause NPE.
EgorBaranovEnjoysTyping c6092d3
IGNITE-28747 Use LinkedHashMap in GridToStringMapNode to preserve ite…
EgorBaranovEnjoysTyping fb9a8ff
IGNITE-28747 Add JMH benchmark for GridToStringBuilder + assert tail …
EgorBaranovEnjoysTyping aae4ccc
Merge branch 'master' of https://github.com/apache/ignite into IGNITE…
EgorBaranovEnjoysTyping 822a9d9
IGNITE-28747 Optimize findRecursionMonitor to reduce allocation overhead
EgorBaranovEnjoysTyping 594fc51
IGNITE-28747 Fix GridToStringBuilderBenchmark: use Class.class litera…
EgorBaranovEnjoysTyping 08c11e7
IGNITE-28747 Remove GridToStringBuilderBenchmark but keep in history
EgorBaranovEnjoysTyping a9dbe55
IGNITE-28747 Fix style (indent)
EgorBaranovEnjoysTyping File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...commons/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringArrayNode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * 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.ignite.internal.util.tostring; | ||
|
|
||
| import org.apache.ignite.internal.util.GridStringBuilder; | ||
|
|
||
| import static org.apache.ignite.internal.util.tostring.GridToStringBuilder.COLLECTION_LIMIT; | ||
| import static org.apache.ignite.internal.util.tostring.GridToStringNodeFactory.getGridToStringNode; | ||
|
|
||
| /** | ||
| * A node that represents an array in the string representation. | ||
| * It creates nodes for each element of the array and formats the output with square brackets. | ||
| */ | ||
| class GridToStringArrayNode extends NodeRecursionMonitor { | ||
| /** An array of child nodes, each representing an element of the source array. */ | ||
| private final GridToStringNode[] nodes; | ||
|
|
||
| /** The rule for appending a hint about skipped elements if the array is too large. */ | ||
| private final LongSequenceSkipRule skipRule; | ||
|
|
||
| /** The class object representing the type of the array. */ | ||
| private final Class<?> arrType; | ||
|
|
||
| /** | ||
| * Constructs a new array node. | ||
| * Iterates over the input array, creates a node for each element, | ||
| * and populates the internal array up to the collection size limit. | ||
| * @param propName The property name. | ||
| * @param arr The source array. | ||
| * @param arrType The class object of the array's type. | ||
| */ | ||
| GridToStringArrayNode(String propName, Object[] arr, Class<?> arrType) { | ||
| super(propName, arr); | ||
| try { | ||
| aqcuireRecursionMonitor(this); | ||
| this.arrType = arrType; | ||
| skipRule = new LongSequenceSkipRule(() -> arr.length); | ||
| nodes = new GridToStringNode[Math.min(COLLECTION_LIMIT, arr.length)]; | ||
| for (int i = 0; i < nodes.length; i++) { | ||
| final int idx = i; | ||
| nodes[idx] = getGridToStringNode(null, () -> arr[idx], () -> arr[idx].getClass()); | ||
|
EgorBaranovEnjoysTyping marked this conversation as resolved.
Outdated
|
||
| } | ||
| } | ||
| finally { | ||
| releaseRecursionMonitor(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Appends the string representation of the array to the builder. | ||
| * The format is: ArrayType [element1, element2, ...]. | ||
| * Also appends a hint about skipped elements if necessary. | ||
| * @param sb The string builder to append to. | ||
| */ | ||
| @Override void appendNode(GridStringBuilder sb) { | ||
| super.appendNode(sb); | ||
| sb.a(arrType.getSimpleName()).a(" ["); | ||
| for (int i = 0; i < nodes.length - 1; i++) { | ||
| nodes[i].appendNode(sb); | ||
| sb.a(", "); | ||
| } | ||
| if (nodes.length > 0) | ||
| nodes[nodes.length - 1].appendNode(sb); | ||
| skipRule.appendSkippedCountHint(sb); | ||
| sb.a("]"); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.