diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java index 91b1459..ab83ee7 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/SchemaId.java @@ -14,6 +14,7 @@ import com.fasterxml.jackson.databind.exc.MismatchedInputException; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import it.unimi.dsi.fastutil.HashCommon; import it.unimi.dsi.fastutil.ints.Int2ReferenceMap; +import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps; import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; import javax.annotation.Nonnull; @@ -38,7 +39,7 @@ public final class SchemaId implements Comparable { private static final Int2ReferenceMap cache; static { - cache = new Int2ReferenceOpenHashMap<>(); + cache = Int2ReferenceMaps.synchronize(new Int2ReferenceOpenHashMap<>()); cache.put(0, INVALID = NONE = new SchemaId(0)); } diff --git a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java index 5cb455f..561dfaf 100644 --- a/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java +++ b/java/src/main/java/com/azure/data/cosmos/serialization/hybridrow/layouts/SystemSchema.java @@ -65,21 +65,12 @@ public final class SystemSchema { } private static InputStream getResourceAsStream(final String name) throws IOException { + InputStream inputStream = SystemSchema.class.getClassLoader().getResourceAsStream(name); - final CodeSource codeSource = SystemSchema.class.getProtectionDomain().getCodeSource(); - final ClassLoader classLoader = SystemSchema.class.getClassLoader(); - final String location = codeSource.getLocation().toString(); - final Enumeration urls; - - urls = classLoader.getResources(name); - - while (urls.hasMoreElements()) { - final URL url = urls.nextElement(); - if (url.getFile().endsWith(name)) { - return url.openStream(); - } + if (inputStream != null) { + return inputStream; } - throw new FileNotFoundException(lenientFormat("cannot find %s at %s", name, location)); + throw new FileNotFoundException(lenientFormat("cannot find %s", name)); } }