mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-07 22:09:38 +07:00
WEB-41746 Sort properties alphabetically goes into an infinite loop on malformed JSON
GitOrigin-RevId: a81621b5f283bcd224cb26d413c9f0c2d4a3353e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8f3cc4607a
commit
f1f080a2ec
@@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class JsonSortPropertiesIntention implements IntentionAction, LowPriorityAction {
|
||||
@Nls(capitalization = Nls.Capitalization.Sentence)
|
||||
@@ -98,7 +99,7 @@ public class JsonSortPropertiesIntention implements IntentionAction, LowPriority
|
||||
if (properties.get(i).getName().compareTo(itemName) < 0) pos++;
|
||||
}
|
||||
if (pos == cycleStart) return -1;
|
||||
while (item == properties.get(pos)) pos++;
|
||||
while (Objects.equals(itemName, properties.get(pos).getName())) pos++;
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,4 +12,8 @@ public class JsonIntentionActionTest extends JsonTestCase {
|
||||
public void testSortProperties() {
|
||||
doTest("json.intention.sort.properties");
|
||||
}
|
||||
|
||||
public void testSortMalformedJson() {
|
||||
doTest("json.intention.sort.properties");
|
||||
}
|
||||
}
|
||||
|
||||
227
json/tests/testData/intention/SortMalformedJson.json
Normal file
227
json/tests/testData/intention/SortMalformedJson.json
Normal file
@@ -0,0 +1,227 @@
|
||||
{"properties": [
|
||||
{
|
||||
"defaultValue": true,
|
||||
"description": "Enable all endpoints.",
|
||||
"name": "endpoints.all.enabled",
|
||||
"type": "java.lang.Boolean"
|
||||
},
|
||||
{
|
||||
"name": "endpoints.all.jmx.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as JMX MBeans.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.all.web.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as Web endpoints.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.configprops.keys-to-sanitize",
|
||||
"type": "java.lang.String[]",
|
||||
"sourceType": "org.springframework.boot.actuate.endpoint.ConfigurationPropertiesReportEndpoint",
|
||||
"description": "Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions.",
|
||||
"defaultValue": [
|
||||
"password",
|
||||
"secret",
|
||||
"key",
|
||||
"token",
|
||||
".*credentials.*",
|
||||
"vcap_services"
|
||||
]
|
||||
},
|
||||
{
|
||||
"n<caret>ame": "endpoints.env.keys-to-sanitize",
|
||||
"type": "java.lang.String[]",
|
||||
"sourceType": "org.springframework.boot.actuate.endpoint.EnvironmentEndpoint",
|
||||
"description": ""<error descr="',' or '}' expected, got 'ption'">p</error>tion<error descr="':' expected, got '\": \"'">"</error>: "<error descr="':' expected, got 'Keys'">K</error>eys<error descr="':' expected, got 'that'"> </error>that<error descr="':' expected, got 'should'"> </error>should<error descr="':' expected, got 'be'"> </error>be<error descr="':' expected, got 'sanitized.'"> </error>sanitized.<error descr="':' expected, got 'Keys'"> </error>Keys<error descr="':' expected, got 'can'"> </error>can<error descr="':' expected, got 'be'"> </error>be<error descr="':' expected, got 'simple'"> </error>simple<error descr="':' expected, got 'strings'"> </error>strings<error descr="':' expected, got 'that'"> </error>that<error descr="':' expected, got 'the'"> </error>the<error descr="':' expected, got 'property'"> </error>property<error descr="':' expected, got 'ends'"> </error>ends<error descr="':' expected, got 'with'"> </error>with<error descr="':' expected, got 'or'"> </error>or<error descr="':' expected, got 'regex'"> </error>regex<error descr="':' expected, got 'expressions.'"> </error>expressions.<error descr="Missing closing quote"><error descr="':' expected, got '\",'">"</error>,</error><EOLError descr="':' expected, got '\"defaultValue\"'"></EOLError>
|
||||
"defaultValue": [
|
||||
<error descr="<value> expected, got ','">,</error>
|
||||
"secret"<error descr="':' expected, got ','">,</error>
|
||||
"key"<error descr="':' expected, got ','">,</error>
|
||||
"token"<error descr="':' expected, got ','">,</error>
|
||||
".*credentials.*"<error descr="':' expected, got ','">,</error>
|
||||
"vcap_services"<EOLError descr="':' expected, got ']'"></EOLError>
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "endpoints.metrics.filter.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable the metrics servlet filter.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.trace.filter.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable the trace servlet filter.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "info",
|
||||
"type": "java.util.Map<java.lang.String,java.lang.Object>",
|
||||
"description": "Arbitrary properties to add to the info endpoint."
|
||||
},
|
||||
{
|
||||
"name": "management.cloudfoundry.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable extended Cloud Foundry actuator endpoints.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.cloudfoundry.skip-ssl-validation",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Skip SSL verification for Cloud Foundry actuator endpoint security calls.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "management.health.cassandra.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable cassandra health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.couchbase.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
<error descr="':' unexpected">:</error> ,
|
||||
|
||||
},
|
||||
{
|
||||
"name": "management.health.db.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable database health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.defaults.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable default health indicators.",
|
||||
"defaultValue": true
|
||||
},
|
||||
<error descr="',' unexpected">,</error>
|
||||
{
|
||||
"name": "management.health.elasticsearch.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable elasticsearch health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.jms.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable JMS health check.",
|
||||
|
||||
},
|
||||
{
|
||||
"name": "management.health.ldap.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable LDAP health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
<error descr="',' unexpected">,</error>
|
||||
{
|
||||
"name": "management.health.rabbit.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable RabbitMQ health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name":<error descr="<value> expected, got ','"> </error>,
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable Redis health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.solr.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable Solr health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.mail.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable Mail health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
<error descr="',' unexpected">,</error>
|
||||
{
|
||||
"name": "management.info.build.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable build info.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.info.defaults.enabled",
|
||||
"type":<error descr="<value> expected, got ','"> </error>,
|
||||
"description": "Enable default info contributors.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.info.env.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable environment info.",
|
||||
"defaultValue": true
|
||||
},
|
||||
<error descr="',' unexpected">,</error>
|
||||
{
|
||||
"name": "management.info.git.mode",
|
||||
"defaultValue": "simple"
|
||||
},
|
||||
{
|
||||
"name": "management.security.sessions",
|
||||
"defaultValue": "stateless"
|
||||
},
|
||||
{
|
||||
"name": "spring.git.properties",
|
||||
"type": "java.lang.String",
|
||||
"description": "Resource reference to a generated git info properties file.",
|
||||
"deprecation": {
|
||||
"replacement"<error descr="':' expected, got '\"hints\"'">"</error>hints": [
|
||||
<error descr="<value> expected, got ','">,</error>
|
||||
{
|
||||
"name":<error descr="<value> expected, got ','"> </error>,
|
||||
"values": [false<EOLError descr="',' or ']' expected, got '{'"></EOLError>
|
||||
{
|
||||
"value": "*"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"name": "any"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "management.endpoints.cors.allowed-origins",
|
||||
"values": [
|
||||
{
|
||||
"value": "*"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"name": "any"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "management.health.status.order",
|
||||
"values": [
|
||||
{
|
||||
"value": "UNKNOWN"
|
||||
},
|
||||
{
|
||||
"value": "UP"
|
||||
},
|
||||
<error descr="',' unexpected">,</error>
|
||||
CE<error descr="',' or ']' expected, got '\"'"><error descr="Missing closing quote">"</error></error>
|
||||
<error descr="',' or ']' expected, got '}'">}</error>
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"name": "any"
|
||||
}
|
||||
]
|
||||
}
|
||||
]}
|
||||
|
||||
|
||||
248
json/tests/testData/intention/SortMalformedJson_after.json
Normal file
248
json/tests/testData/intention/SortMalformedJson_after.json
Normal file
@@ -0,0 +1,248 @@
|
||||
{"properties": [
|
||||
{
|
||||
"defaultValue": true,
|
||||
"description": "Enable all endpoints.",
|
||||
"name": "endpoints.all.enabled",
|
||||
"type": "java.lang.Boolean"
|
||||
},
|
||||
{
|
||||
"name": "endpoints.all.jmx.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as JMX MBeans.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.all.web.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable all endpoints as Web endpoints.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.configprops.keys-to-sanitize",
|
||||
"type": "java.lang.String[]",
|
||||
"sourceType": "org.springframework.boot.actuate.endpoint.ConfigurationPropertiesReportEndpoint",
|
||||
"description": "Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions.",
|
||||
"defaultValue": [
|
||||
"password",
|
||||
"secret",
|
||||
"key",
|
||||
"token",
|
||||
".*credentials.*",
|
||||
"vcap_services"
|
||||
]
|
||||
},
|
||||
{
|
||||
",<caret>,
|
||||
".*credentials.*",
|
||||
": ",
|
||||
Keys
|
||||
Keys
|
||||
be
|
||||
be
|
||||
can
|
||||
"defaultValue": [
|
||||
,
|
||||
"description": ""
|
||||
ends
|
||||
expressions.
|
||||
"key"
|
||||
"name": "endpoints.env.keys-to-sanitize"
|
||||
or
|
||||
property
|
||||
ption
|
||||
regex
|
||||
sanitized.
|
||||
"secret"
|
||||
should
|
||||
simple
|
||||
"sourceType": "org.springframework.boot.actuate.endpoint.EnvironmentEndpoint"
|
||||
strings
|
||||
that
|
||||
that
|
||||
the,
|
||||
"token",
|
||||
"type": "java.lang.String[]",
|
||||
"vcap_services",
|
||||
with
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "endpoints.metrics.filter.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable the metrics servlet filter.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "endpoints.trace.filter.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable the trace servlet filter.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "info",
|
||||
"type": "java.util.Map<java.lang.String,java.lang.Object>",
|
||||
"description": "Arbitrary properties to add to the info endpoint."
|
||||
},
|
||||
{
|
||||
"name": "management.cloudfoundry.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable extended Cloud Foundry actuator endpoints.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.cloudfoundry.skip-ssl-validation",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Skip SSL verification for Cloud Foundry actuator endpoint security calls.",
|
||||
"defaultValue": false
|
||||
},
|
||||
{
|
||||
"name": "management.health.cassandra.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable cassandra health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.couchbase.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
: ,
|
||||
|
||||
},
|
||||
{
|
||||
"name": "management.health.db.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable database health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.defaults.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable default health indicators.",
|
||||
"defaultValue": true
|
||||
},
|
||||
,
|
||||
{
|
||||
"name": "management.health.elasticsearch.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable elasticsearch health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.jms.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable JMS health check.",
|
||||
|
||||
},
|
||||
{
|
||||
"name": "management.health.ldap.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable LDAP health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
,
|
||||
{
|
||||
"name": "management.health.rabbit.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable RabbitMQ health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": ,
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable Redis health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.solr.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable Solr health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.health.mail.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable Mail health check.",
|
||||
"defaultValue": true
|
||||
},
|
||||
,
|
||||
{
|
||||
"name": "management.info.build.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable build info.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.info.defaults.enabled",
|
||||
"type": ,
|
||||
"description": "Enable default info contributors.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "management.info.env.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable environment info.",
|
||||
"defaultValue": true
|
||||
},
|
||||
,
|
||||
{
|
||||
"name": "management.info.git.mode",
|
||||
"defaultValue": "simple"
|
||||
},
|
||||
{
|
||||
"name": "management.security.sessions",
|
||||
"defaultValue": "stateless"
|
||||
},
|
||||
{
|
||||
"name": "spring.git.properties",
|
||||
"type": "java.lang.String",
|
||||
"description": "Resource reference to a generated git info properties file.",
|
||||
"deprecation": {
|
||||
"replacement""hints": [
|
||||
,
|
||||
{
|
||||
"name": ,
|
||||
"values": [false
|
||||
{
|
||||
"value": "*"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"name": "any"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "management.endpoints.cors.allowed-origins",
|
||||
"values": [
|
||||
{
|
||||
"value": "*"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"name": "any"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "management.health.status.order",
|
||||
"values": [
|
||||
{
|
||||
"value": "UNKNOWN"
|
||||
},
|
||||
{
|
||||
"value": "UP"
|
||||
},
|
||||
,
|
||||
CE"
|
||||
}
|
||||
],
|
||||
"providers": [
|
||||
{
|
||||
"name": "any"
|
||||
}
|
||||
]
|
||||
}
|
||||
]}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user