From 093087f0c8af6c9cfb11a79862c603f31fbaf15a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 12 Mar 2024 19:28:39 +0100 Subject: [PATCH] getResourceAsStream is efficient enough, - do not complicate GitOrigin-RevId: d73264f79aeda3cf29dda1bf79e4d2b04a6c00b1 --- .../util/src/com/intellij/AbstractBundle.java | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/platform/util/src/com/intellij/AbstractBundle.java b/platform/util/src/com/intellij/AbstractBundle.java index c438a3ed725d..952ab0f4a520 100644 --- a/platform/util/src/com/intellij/AbstractBundle.java +++ b/platform/util/src/com/intellij/AbstractBundle.java @@ -1,13 +1,11 @@ -// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij; import com.intellij.openapi.diagnostic.Logger; import com.intellij.util.ArrayUtilRt; import com.intellij.util.DefaultBundleService; -import com.intellij.util.lang.UrlClassLoader; import org.jetbrains.annotations.*; -import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; @@ -150,9 +148,11 @@ public class AbstractBundle { } @ApiStatus.Internal - protected static @NotNull ResourceBundle resolveResourceBundleWithFallback(@NotNull ClassLoader loader, - @NotNull String pathToBundle, - @NotNull Supplier firstTry) { + protected static @NotNull ResourceBundle resolveResourceBundleWithFallback( + @NotNull ClassLoader loader, + @NotNull String pathToBundle, + @NotNull Supplier firstTry + ) { try { return firstTry.get(); } @@ -212,28 +212,16 @@ public class AbstractBundle { return null; } - if (loader instanceof UrlClassLoader) { - // checkParents - https://youtrack.jetbrains.com/issue/IDEA-282831 - byte[] data = ((UrlClassLoader)loader).getResourceAsBytes(resourceName, true); - if (data == null) { - return null; - } - else { - return new PropertyResourceBundle(new InputStreamReader(new ByteArrayInputStream(data), StandardCharsets.UTF_8)); - } + InputStream stream = loader.getResourceAsStream(resourceName); + if (stream == null) { + return null; } - else { - InputStream stream = loader.getResourceAsStream(resourceName); - if (stream == null) { - return null; - } - try { - return new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8)); - } - finally { - stream.close(); - } + try { + return new PropertyResourceBundle(new InputStreamReader(stream, StandardCharsets.UTF_8)); + } + finally { + stream.close(); } } }