mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
save hash using a new property field to possibly avoid exceptions in older versions
GitOrigin-RevId: c405ae09124c49f4cb79103363b3f8d397dc41f3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a3dc6c22f0
commit
cb4fdfc2fc
@@ -4,7 +4,6 @@ package org.jetbrains.jps.incremental.storage;
|
||||
import com.dynatrace.hash4j.hashing.HashStream64;
|
||||
import com.dynatrace.hash4j.hashing.Hashing;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
@@ -347,7 +346,7 @@ public final class BuildTargetSourcesState implements BuildListener {
|
||||
|
||||
private @NotNull Map<String, Map<String, BuildTargetState>> loadCurrentTargetState() {
|
||||
try (BufferedReader reader = Files.newBufferedReader(targetStateStorage)) {
|
||||
return readJson(new JsonReader(reader), false);
|
||||
return readJson(new JsonReader(reader));
|
||||
}
|
||||
catch (NoSuchFileException ignore) {
|
||||
}
|
||||
@@ -379,50 +378,18 @@ public final class BuildTargetSourcesState implements BuildListener {
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static @NotNull Map<String, Map<String, BuildTargetState>> readJson(JsonReader reader, boolean stringHashAsHash) throws IOException {
|
||||
public static @NotNull Map<String, Map<String, BuildTargetState>> readJson(JsonReader reader) throws IOException {
|
||||
reader.beginObject();
|
||||
Map<String, Map<String, BuildTargetState>> result = new HashMap<>();
|
||||
while (reader.hasNext()) {
|
||||
String category = reader.nextName();
|
||||
|
||||
reader.beginObject();
|
||||
Map<String, BuildTargetState> map = new HashMap<>();
|
||||
Map<String, BuildTargetState> moduleNameToDescriptor = new HashMap<>();
|
||||
while (reader.hasNext()) {
|
||||
String moduleName = reader.nextName();
|
||||
reader.beginObject();
|
||||
long hash = -1;
|
||||
boolean hasHash = false;
|
||||
String relativePath = null;
|
||||
while (reader.hasNext()) {
|
||||
String name = reader.nextName();
|
||||
if (name.equals("hash")) {
|
||||
if (reader.peek() == JsonToken.NUMBER) {
|
||||
try {
|
||||
hash = reader.nextLong();
|
||||
hasHash = true;
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
reader.skipValue();
|
||||
}
|
||||
}
|
||||
else if (stringHashAsHash) {
|
||||
hash = Hashing.komihash5_0().hashCharsToLong(reader.nextString());
|
||||
hasHash = true;
|
||||
}
|
||||
else {
|
||||
reader.skipValue();
|
||||
}
|
||||
}
|
||||
else if (name.equals("relativePath")) {
|
||||
relativePath = reader.nextString();
|
||||
}
|
||||
}
|
||||
if (hasHash && relativePath != null) {
|
||||
map.put(moduleName, new BuildTargetState(hash, relativePath));
|
||||
}
|
||||
reader.endObject();
|
||||
|
||||
result.put(category, map);
|
||||
readModule(reader, moduleNameToDescriptor, moduleName);
|
||||
result.put(category, moduleNameToDescriptor);
|
||||
}
|
||||
reader.endObject();
|
||||
}
|
||||
@@ -430,6 +397,39 @@ public final class BuildTargetSourcesState implements BuildListener {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void readModule(JsonReader reader,
|
||||
Map<String, BuildTargetState> moduleNameToDescriptor,
|
||||
String moduleName) throws IOException {
|
||||
reader.beginObject();
|
||||
long hash = -1;
|
||||
boolean hasHash = false;
|
||||
String relativePath = null;
|
||||
while (reader.hasNext()) {
|
||||
String propertyName = reader.nextName();
|
||||
switch (propertyName) {
|
||||
case "relativePath":
|
||||
relativePath = reader.nextString();
|
||||
break;
|
||||
case "h":
|
||||
hash = reader.nextLong();
|
||||
hasHash = true;
|
||||
break;
|
||||
case "hash":
|
||||
reader.skipValue();
|
||||
break;
|
||||
default:
|
||||
LOG.warn("Unknown property: " + propertyName);
|
||||
reader.skipValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
reader.endObject();
|
||||
|
||||
if (hasHash && relativePath != null) {
|
||||
moduleNameToDescriptor.put(moduleName, new BuildTargetState(hash, relativePath));
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void writeJson(JsonWriter writer, Map<String, Map<String, BuildTargetState>> map) throws IOException {
|
||||
String[] keys = ArrayUtilRt.toStringArray(map.keySet());
|
||||
@@ -447,7 +447,7 @@ public final class BuildTargetSourcesState implements BuildListener {
|
||||
|
||||
BuildTargetState state = subMap.get(module);
|
||||
writer.beginObject();
|
||||
writer.name("hash").value(state.hash);
|
||||
writer.name("h").value(state.hash);
|
||||
writer.name("relativePath").value(state.relativePath);
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integrationTests": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b1670357c60b4f0520755597ae7",
|
||||
"h": 4514032945642354,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
},
|
||||
"intellij.sh": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.sh"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integrationTests": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b1670357c60b4f0520755597ae7",
|
||||
"h": 4514032945642354,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integrationTests": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.statsCollector": {
|
||||
"hash": "499dff8ad66e7a4604d4dde46bc79fc5",
|
||||
"h": 4562143,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.statsCollector"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b1670357c60b4f0520755597ae7",
|
||||
"h": 4514032945642354,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
},
|
||||
"intellij.sh": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.sh"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integrationTests": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.statsCollector": {
|
||||
"hash": "499dff8ad66e7a4344d4dde46bc79fc5",
|
||||
"h": 98765432342,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.statsCollector"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"artifacts": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integrationTests": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.statsCollector": {
|
||||
"hash": "499dff8ad66e7a4344d4dde46bc79fc5",
|
||||
"h": 98765432342,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.statsCollector"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integrationTests": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.statsCollector": {
|
||||
"hash": "499dff8ad66e7a4344d4dde46bc79fc5",
|
||||
"h": 98765432342,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.statsCollector"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"artifacts": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integration": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.statsCollector": {
|
||||
"hash": "499dff8ad66e7a4344d4dde46bc79fc5",
|
||||
"h": 98765432342,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.statsCollector"
|
||||
}
|
||||
},
|
||||
"artifacts": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"java-test": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "2278b175facf7afb99432408b82489c2",
|
||||
"h": 90345695402943,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"resources-test": {
|
||||
"intellij.platform.ssh.integration": {
|
||||
"hash": "71c661e849ef948135bdfa5b4d105a7c",
|
||||
"h": 23435674324354,
|
||||
"relativePath": "$BUILD_DIR$/test/intellij.platform.ssh.integrationTests"
|
||||
}
|
||||
},
|
||||
"java-production": {
|
||||
"intellij.statsCollector": {
|
||||
"hash": "499dff8ad66e7a4344d4dde46bc79fc5",
|
||||
"h": 98765432342,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.statsCollector"
|
||||
}
|
||||
},
|
||||
"resources-production": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
},
|
||||
"artifacts": {
|
||||
"intellij.cidr.externalSystem": {
|
||||
"hash": "9bd11b17f0357c60b4f0520755597ae7",
|
||||
"h": 8764333034314,
|
||||
"relativePath": "$BUILD_DIR$/production/intellij.cidr.externalSystem"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,11 +117,11 @@ class JpsCompilationOutputLoaderTest : BasePlatformTestCase() {
|
||||
|
||||
private fun loadModelFromFile(fileName: String): Map<String, Map<String, BuildTargetState>> {
|
||||
val inJson = Files.readString(getTestDataFile(fileName))
|
||||
val map = BuildTargetSourcesState.readJson(JsonReader(inJson.reader()), true)
|
||||
val map = BuildTargetSourcesState.readJson(JsonReader(inJson.reader()))
|
||||
|
||||
val stringWriter = StringWriter()
|
||||
JsonWriter(stringWriter).use { BuildTargetSourcesState.writeJson(it, map) }
|
||||
assertThat(BuildTargetSourcesState.readJson(JsonReader(stringWriter.toString().reader()), false))
|
||||
assertThat(BuildTargetSourcesState.readJson(JsonReader(stringWriter.toString().reader())))
|
||||
.isEqualTo(map)
|
||||
return map
|
||||
}
|
||||
Reference in New Issue
Block a user