bundles = calculateBundleNames(fixedPath, Locale.getDefault());
for (String bundle : bundles) {
diff --git a/platform/util/src/com/intellij/AbstractBundle.java b/platform/util/src/com/intellij/AbstractBundle.java
index f5de0867c0dd..2dada7b90988 100644
--- a/platform/util/src/com/intellij/AbstractBundle.java
+++ b/platform/util/src/com/intellij/AbstractBundle.java
@@ -196,7 +196,7 @@ public class AbstractBundle {
}
if (loader instanceof UrlClassLoader) {
- byte[] data = ((UrlClassLoader)loader).getResourceAsBytes(resourceName);
+ byte[] data = ((UrlClassLoader)loader).getResourceAsBytes(resourceName, false);
if (data == null) {
return null;
}
diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java
index 46fb12a85ad3..5c18506e99cb 100644
--- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java
+++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.util;
import com.intellij.openapi.diagnostic.Logger;
@@ -247,7 +247,7 @@ public final class JDOMUtil {
/**
* @deprecated Use {@link #load(CharSequence)}
*
- * Direct usage of element allows to get rid of {@link Document#getRootElement()} because only Element is required in mostly all cases.
+ * Direct usage of element allows getting rid of {@link Document#getRootElement()} because only Element is required in mostly all cases.
*/
@Deprecated
public static @NotNull Document loadDocument(@NotNull Reader reader) throws IOException, JDOMException {
@@ -324,6 +324,21 @@ public final class JDOMUtil {
return stream == null ? null : loadUsingStaX(stream, null);
}
+ public static @NotNull Element load(byte @NotNull [] data) throws JDOMException, IOException {
+ try {
+ XMLStreamReader2 xmlStreamReader = StaxFactory.createXmlStreamReader(data);
+ try {
+ return SafeStAXStreamBuilder.build(xmlStreamReader, true, true, null == null ? SafeStAXStreamBuilder.FACTORY : null);
+ }
+ finally {
+ xmlStreamReader.close();
+ }
+ }
+ catch (XMLStreamException e) {
+ throw new JDOMException(e.getMessage(), e);
+ }
+ }
+
@ApiStatus.Internal
public static @NotNull Element load(@NotNull InputStream stream, @Nullable SafeJdomFactory factory) throws JDOMException, IOException {
return loadUsingStaX(stream, factory);
diff --git a/platform/util/ui/src/com/intellij/ui/svg/SvgDocumentFactory.kt b/platform/util/ui/src/com/intellij/ui/svg/SvgDocumentFactory.kt
index 13b91a7acc3f..5919cad50632 100644
--- a/platform/util/ui/src/com/intellij/ui/svg/SvgDocumentFactory.kt
+++ b/platform/util/ui/src/com/intellij/ui/svg/SvgDocumentFactory.kt
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ui.svg
import com.intellij.openapi.util.createXmlStreamReader
@@ -9,6 +9,7 @@ import org.apache.batik.dom.GenericCDATASection
import org.apache.batik.dom.GenericText
import org.apache.batik.transcoder.TranscoderException
import org.apache.batik.util.ParsedURL
+import org.codehaus.stax2.XMLStreamReader2
import org.jetbrains.annotations.ApiStatus
import org.w3c.dom.Document
import org.w3c.dom.Element
@@ -19,8 +20,12 @@ import javax.xml.stream.XMLStreamException
import javax.xml.stream.XMLStreamReader
@ApiStatus.Internal
-fun createSvgDocument(uri: String?, reader: InputStream): Document {
- val xmlStreamReader = createXmlStreamReader(reader)
+fun createSvgDocument(uri: String?, reader: InputStream) = createSvgDocument(uri, createXmlStreamReader(reader))
+
+@ApiStatus.Internal
+fun createSvgDocument(uri: String?, data: ByteArray) = createSvgDocument(uri, createXmlStreamReader(data))
+
+private fun createSvgDocument(uri: String?, xmlStreamReader: XMLStreamReader2): Document {
val result = try {
buildDocument(xmlStreamReader)
}
diff --git a/platform/util/ui/src/com/intellij/ui/svg/SvgTranscoder.kt b/platform/util/ui/src/com/intellij/ui/svg/SvgTranscoder.kt
index 6e6a664aef31..da7c7a57a427 100644
--- a/platform/util/ui/src/com/intellij/ui/svg/SvgTranscoder.kt
+++ b/platform/util/ui/src/com/intellij/ui/svg/SvgTranscoder.kt
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
@file:Suppress("UndesirableClassUsage")
package com.intellij.ui.svg
@@ -170,7 +170,7 @@ class SvgTranscoder private constructor(private var width: Float, private var he
" \n" +
" \n" +
"\n"
- return createSvgDocument(null, fallbackIcon.byteInputStream()) as SVGDocument
+ return createSvgDocument(null, fallbackIcon.toByteArray()) as SVGDocument
}
override fun getTransform() = currentTransform!!
diff --git a/platform/util/ui/src/com/intellij/util/ImageLoader.java b/platform/util/ui/src/com/intellij/util/ImageLoader.java
index 67945ed2a641..ad102140f65a 100644
--- a/platform/util/ui/src/com/intellij/util/ImageLoader.java
+++ b/platform/util/ui/src/com/intellij/util/ImageLoader.java
@@ -1,4 +1,4 @@
-// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.diagnostic.StartUpMeasurer;
@@ -31,12 +31,17 @@ import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.FilteredImageSource;
import java.awt.image.ImageFilter;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
-import java.nio.file.*;
+import java.nio.file.Files;
+import java.nio.file.NoSuchFileException;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -158,7 +163,7 @@ public final class ImageLoader {
if (start != -1) {
IconLoadMeasurer.addLoading(descriptor.isSvg, start);
}
- return convertImage(image, filters, flags, scaleContext, isUpScaleNeeded, isHiDpiNeeded, descriptor.scale, descriptor.isSvg, originalUserSize);
+ return convertImage(image, filters, flags, scaleContext, isUpScaleNeeded, isHiDpiNeeded, descriptor.scale, descriptor.isSvg);
}
catch (IOException e) {
ioExceptionThrown = true;
@@ -186,8 +191,8 @@ public final class ImageLoader {
if (image == null) {
continue;
}
- return convertImage(image, Collections.emptyList(), flags, scaleContext, isUpScaleNeeded, isHiDpiNeeded, descriptor.scale, descriptor.isSvg,
- originalUserSize);
+ return convertImage(image, Collections.emptyList(), flags, scaleContext, isUpScaleNeeded, isHiDpiNeeded, descriptor.scale, descriptor.isSvg
+ );
}
catch (IOException ignore) {
}
@@ -285,29 +290,34 @@ public final class ImageLoader {
return image;
}
- static @Nullable InputStream getResourceData(@NotNull String path, @Nullable Class> resourceClass, @Nullable ClassLoader classLoader) {
+ static byte @Nullable [] getResourceData(@NotNull String path, @Nullable Class> resourceClass, @Nullable ClassLoader classLoader)
+ throws IOException {
assert resourceClass != null || classLoader != null || path.startsWith("file://");
if (classLoader != null) {
- InputStream stream = classLoader.getResourceAsStream(path.startsWith("/") ? path.substring(1) : path);
- if (stream != null) {
- return stream;
+ boolean isAbsolute = path.startsWith("/");
+ byte[] data = ResourceUtil.getResourceAsBytes(isAbsolute ? path.substring(1) : path, classLoader);
+ if (data != null || isAbsolute) {
+ return data;
}
}
if (resourceClass != null) {
- return resourceClass.getResourceAsStream(path);
+ try (InputStream stream = resourceClass.getResourceAsStream(path)) {
+ return stream == null ? null : stream.readAllBytes();
+ }
}
if (path.startsWith("file:/")) {
- Path nioPath = Paths.get(URI.create(path));
- if (Files.exists(nioPath)) {
- try {
- return Files.newInputStream(nioPath);
- }
- catch (IOException e) {
- getLogger().warn(e);
- }
+ Path nioPath = Path.of(URI.create(path));
+ try {
+ return Files.readAllBytes(nioPath);
+ }
+ catch (NoSuchFileException e) {
+ return null;
+ }
+ catch (IOException e) {
+ getLogger().warn(e);
}
}
return null;
@@ -319,14 +329,11 @@ public final class ImageLoader {
@Nullable ClassLoader classLoader,
double scale,
@NotNull Dimension2DDouble originalUserSize) throws IOException {
- InputStream stream = getResourceData(path, resourceClass, classLoader);
- if (stream == null) {
+ byte[] data = getResourceData(path, resourceClass, classLoader);
+ if (data == null) {
return null;
}
-
- try (stream) {
- return loadPng(stream, scale, originalUserSize);
- }
+ return loadPng(new ByteArrayInputStream(data), scale, originalUserSize);
}
@ApiStatus.Internal
@@ -364,7 +371,7 @@ public final class ImageLoader {
}
// originalUserSize - The original user space size of the image. In case of SVG it's the size specified in the SVG doc.
- // Otherwise it's the size of the original image divided by the image's scale (defined by the extension @2x).
+ // Otherwise, it's the size of the original image divided by the image's scale (defined by the extension @2x).
public static @Nullable Image convertImage(@NotNull Image image,
@NotNull List extends ImageFilter> filters,
@MagicConstant(flagsFromClass = ImageLoader.class) int flags,
@@ -372,8 +379,7 @@ public final class ImageLoader {
boolean isUpScaleNeeded,
boolean isHiDpiNeeded,
double imageScale,
- boolean isSvg,
- @NotNull ImageLoader.Dimension2DDouble originalUserSize) {
+ boolean isSvg) {
if (isUpScaleNeeded && !isSvg) {
double scale = adjustScaleFactor((flags & ALLOW_FLOAT_SCALING) == ALLOW_FLOAT_SCALING, (float)scaleContext.getScale(DerivedScaleType.PIX_SCALE));
if (imageScale > 1) {
diff --git a/platform/util/ui/src/com/intellij/util/SVGLoader.java b/platform/util/ui/src/com/intellij/util/SVGLoader.java
index ac9eb23499e9..b452d7b0a004 100644
--- a/platform/util/ui/src/com/intellij/util/SVGLoader.java
+++ b/platform/util/ui/src/com/intellij/util/SVGLoader.java
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util;
import com.intellij.diagnostic.StartUpMeasurer;
@@ -16,6 +16,7 @@ import com.intellij.ui.svg.SvgCacheManager;
import com.intellij.ui.svg.SvgDocumentFactoryKt;
import com.intellij.ui.svg.SvgPrebuiltCacheManager;
import com.intellij.ui.svg.SvgTranscoder;
+import com.intellij.util.ui.EDT;
import com.intellij.util.ui.ImageUtil;
import org.apache.batik.transcoder.TranscoderException;
import org.jetbrains.annotations.ApiStatus;
@@ -43,10 +44,10 @@ public final class SVGLoader {
private static final boolean USE_CACHE = Boolean.parseBoolean(System.getProperty("idea.ui.icons.svg.disk.cache", "true"));
private static SvgElementColorPatcherProvider ourColorPatcher;
- private static SvgElementColorPatcherProvider ourSelectionColorPatcher;
- private static SvgElementColorPatcherProvider ourContextColorPatcher;
+ private static SvgElementColorPatcherProvider selectionColorPatcher;
+ private static SvgElementColorPatcherProvider contextColorPatcher;
- private static volatile boolean ourIsColorRedefinitionContext = false;
+ private static volatile boolean isColorRedefinitionContext;
private static final class SvgCache {
private static final SvgCacheManager persistentCache;
@@ -119,9 +120,8 @@ public final class SVGLoader {
float scale,
boolean isDark,
@NotNull ImageLoader.Dimension2DDouble docSize /*OUT*/) throws IOException {
- byte[] svgBytes = null;
- byte[] theme ;
- InputStream stream = null;
+ byte[] theme;
+ byte[] data = null;
if (USE_CACHE && !isColorRedefinitionContext()) {
@SuppressWarnings("DuplicatedCode")
@@ -149,23 +149,15 @@ public final class SVGLoader {
}
}
- stream = ImageLoader.getResourceData(path, resourceClass, classLoader);
- if (stream == null) {
+ data = ImageLoader.getResourceData(path, resourceClass, classLoader);
+ if (data == null) {
return null;
}
- try {
- svgBytes = stream.readAllBytes();
- }
- finally {
- stream.close();
- }
- image = SvgCache.persistentCache.loadFromCache(theme, svgBytes, scale, isDark, docSize);
+ image = SvgCache.persistentCache.loadFromCache(theme, data, scale, isDark, docSize);
if (image != null) {
return image;
}
-
- stream = new ByteArrayInputStream(svgBytes);
}
if (start != -1) {
@@ -176,13 +168,13 @@ public final class SVGLoader {
theme = null;
}
- if (stream == null) {
- stream = ImageLoader.getResourceData(path, resourceClass, classLoader);
- if (stream == null) {
+ if (data == null) {
+ data = ImageLoader.getResourceData(path, resourceClass, classLoader);
+ if (data == null) {
return null;
}
}
- return loadAndCache(path, stream, scale, docSize, theme, svgBytes);
+ return loadAndCache(path, data, scale, docSize, theme);
}
@ApiStatus.Internal
@@ -196,7 +188,7 @@ public final class SVGLoader {
}
byte[] theme = null;
- byte[] svgBytes = null;
+ byte[] data;
Image image;
if (USE_CACHE && !isColorRedefinitionContext()) {
@@ -210,32 +202,36 @@ public final class SVGLoader {
}
}
- if (theme != null) {
- svgBytes = stream.readAllBytes();
- image = SvgCache.persistentCache.loadFromCache(theme, svgBytes, scale, isDark, docSize);
+ if (theme == null) {
+ data = null;
+ }
+ else {
+ data = stream.readAllBytes();
+ image = SvgCache.persistentCache.loadFromCache(theme, data, scale, isDark, docSize);
if (image != null) {
return image;
}
- stream = new ByteArrayInputStream(svgBytes);
}
if (start != -1) {
IconLoadMeasurer.svgCacheRead.end(start);
}
}
- return loadAndCache(path, stream, scale, docSize, theme, svgBytes);
+ else {
+ data = stream.readAllBytes();
+ }
+ return loadAndCache(path, data, scale, docSize, theme);
}
private static @NotNull BufferedImage loadAndCache(@Nullable String path,
- @NotNull InputStream stream,
+ byte[] data,
float scale,
@NotNull ImageLoader.Dimension2DDouble docSize,
- byte[] theme,
- byte[] svgBytes) throws IOException {
+ byte[] theme) throws IOException {
long decodingStart = StartUpMeasurer.getCurrentTimeIfEnabled();
BufferedImage bufferedImage;
try {
- bufferedImage = SvgTranscoder.createImage(scale, createDocument(path, stream), docSize);
+ bufferedImage = SvgTranscoder.createImage(scale, createDocument(path, data), docSize);
}
catch (TranscoderException e) {
docSize.setSize(0, 0);
@@ -249,7 +245,7 @@ public final class SVGLoader {
if (theme != null) {
try {
long cacheWriteStart = StartUpMeasurer.getCurrentTimeIfEnabled();
- SvgCache.persistentCache.storeLoadedImage(theme, svgBytes, scale, bufferedImage, docSize);
+ SvgCache.persistentCache.storeLoadedImage(theme, data, scale, bufferedImage, docSize);
IconLoadMeasurer.svgCacheWrite.end(cacheWriteStart);
}
catch (Exception e) {
@@ -330,6 +326,12 @@ public final class SVGLoader {
return document;
}
+ private static @NotNull Document createDocument(@Nullable String url, byte[] data) {
+ Document document = SvgDocumentFactoryKt.createSvgDocument(url, data);
+ patchColors(url, document);
+ return document;
+ }
+
private static void patchColors(@Nullable String url, @NotNull Document document) {
SvgElementColorPatcherProvider colorPatcher = ourColorPatcher;
if (colorPatcher != null) {
@@ -350,11 +352,11 @@ public final class SVGLoader {
}
public static void setContextColorPatcher(@Nullable SvgElementColorPatcherProvider provider) {
- ourContextColorPatcher = provider;
+ contextColorPatcher = provider;
}
private static SvgElementColorPatcherProvider getColorPatcherProvider() {
- return ourContextColorPatcher;
+ return contextColorPatcher;
}
@Nullable
@@ -428,27 +430,28 @@ public final class SVGLoader {
}
public static void setSelectionColorPatcherProvider(@Nullable SvgElementColorPatcherProvider colorPatcher) {
- ourSelectionColorPatcher = colorPatcher;
+ selectionColorPatcher = colorPatcher;
IconLoader.clearCache();
}
public static void setColorRedefinitionContext(boolean isColorRedefinitionContext) {
- ourIsColorRedefinitionContext = isColorRedefinitionContext;
+ SVGLoader.isColorRedefinitionContext = isColorRedefinitionContext;
}
public static boolean isColorRedefinitionContext() {
- return ourContextColorPatcher != null
- && EventQueue.isDispatchThread()
- && ourIsColorRedefinitionContext
+ return contextColorPatcher != null
+ && isColorRedefinitionContext
+ && EDT.isCurrentThreadEdt()
&& Registry.is("ide.patch.icons.on.selection", false);
}
public static void paintIconWithSelection(Icon icon, Component c, Graphics g, int x, int y) {
- if (ourSelectionColorPatcher == null) {
+ if (selectionColorPatcher == null) {
icon.paintIcon(c, g, x, y);
- } else {
+ }
+ else {
try {
- setContextColorPatcher(ourSelectionColorPatcher);
+ setContextColorPatcher(selectionColorPatcher);
setColorRedefinitionContext(true);
icon.paintIcon(c, g, x, y);
}
diff --git a/plugins/completion-ml-ranking/src/com/intellij/completion/ml/experiment/ClientExperimentStatus.kt b/plugins/completion-ml-ranking/src/com/intellij/completion/ml/experiment/ClientExperimentStatus.kt
index 8b1de007ac95..5f3891b0e2bb 100644
--- a/plugins/completion-ml-ranking/src/com/intellij/completion/ml/experiment/ClientExperimentStatus.kt
+++ b/plugins/completion-ml-ranking/src/com/intellij/completion/ml/experiment/ClientExperimentStatus.kt
@@ -4,12 +4,12 @@
package com.intellij.completion.ml.experiment
import com.intellij.ide.util.PropertiesComponent
-import com.intellij.idea.StartupUtil
import com.intellij.internal.statistic.eventLog.EventLogConfiguration
import com.intellij.lang.Language
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.util.registry.Registry
+import com.intellij.util.ResourceUtil
import kotlinx.serialization.json.Json
import java.util.*
@@ -23,7 +23,7 @@ class ClientExperimentStatus : ExperimentStatus {
return ExperimentConfig.disabledExperiment()
}
- val data = StartupUtil.getResourceAsBytes("experiment.json", ClientExperimentStatus::class.java.classLoader)!!
+ val data = ResourceUtil.getResourceAsBytes("experiment.json", ClientExperimentStatus::class.java.classLoader)!!
val experimentInfo = Json.Default.decodeFromString(ExperimentConfig.serializer(), data.toString(Charsets.UTF_8))
checkExperimentGroups(experimentInfo)
return experimentInfo
diff --git a/plugins/devkit/devkit-core/src/actions/updateFromSources/UpdateIdeFromSourcesAction.kt b/plugins/devkit/devkit-core/src/actions/updateFromSources/UpdateIdeFromSourcesAction.kt
index bf6d0efe37fb..aa78b2d0d5e7 100644
--- a/plugins/devkit/devkit-core/src/actions/updateFromSources/UpdateIdeFromSourcesAction.kt
+++ b/plugins/devkit/devkit-core/src/actions/updateFromSources/UpdateIdeFromSourcesAction.kt
@@ -1,4 +1,4 @@
-// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.devkit.actions.updateFromSources
import com.intellij.CommonBundle
@@ -356,7 +356,7 @@ internal open class UpdateIdeFromSourcesAction
return
}
val plugins = try {
- pluginsXml.inputStream().reader().use {
+ pluginsXml.inputStream().use {
MarketplaceRequests.parsePluginList(it)
}
}
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileReader.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileReader.java
index dc1f3f3b5195..75ce9a4fb719 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileReader.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/EclipseXmlProfileReader.java
@@ -1,18 +1,4 @@
-/*
- * Copyright 2000-2013 JetBrains s.r.o.
- *
- * Licensed 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.
- */
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.eclipse.importer;
import com.intellij.openapi.options.SchemeImportException;
@@ -45,7 +31,7 @@ public class EclipseXmlProfileReader extends DefaultHandler implements EclipseXm
* @throws SchemeImportException
*/
protected void readSettings(InputStream input) throws SchemeImportException {
- SAXParserFactory spf = SAXParserFactory.newInstance();
+ SAXParserFactory spf = SAXParserFactory.newDefaultInstance();
spf.setValidating(false);
SAXParser parser;
try {
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseThemeReader.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseThemeReader.java
index 1e67d7ce515d..d5bf704ca331 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseThemeReader.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importer/colors/EclipseThemeReader.java
@@ -1,18 +1,4 @@
-/*
- * Copyright 2000-2016 JetBrains s.r.o.
- *
- * Licensed 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.
- */
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.idea.eclipse.importer.colors;
import com.intellij.openapi.editor.markup.EffectType;
@@ -48,7 +34,7 @@ public class EclipseThemeReader extends DefaultHandler implements EclipseColorTh
void readSettings(InputStream input) throws SchemeImportException {
- SAXParserFactory spf = SAXParserFactory.newInstance();
+ SAXParserFactory spf = SAXParserFactory.newDefaultInstance();
spf.setValidating(false);
try {
SAXParser parser = spf.newSAXParser();
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
index 5144ff17a188..1b87a2852c30 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/MavenUtil.java
@@ -1158,7 +1158,7 @@ public class MavenUtil {
try {
final CRC32 crc = new CRC32();
- SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
+ SAXParser parser = SAXParserFactory.newDefaultInstance().newSAXParser();
parser.getXMLReader().setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
parser.parse(in, new DefaultHandler() {
diff --git a/python/pydevSrc/com/jetbrains/python/debugger/PydevXmlUtils.java b/python/pydevSrc/com/jetbrains/python/debugger/PydevXmlUtils.java
index 9ebc4dcf989e..6648d3fc8395 100644
--- a/python/pydevSrc/com/jetbrains/python/debugger/PydevXmlUtils.java
+++ b/python/pydevSrc/com/jetbrains/python/debugger/PydevXmlUtils.java
@@ -1,4 +1,4 @@
-// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python.debugger;
import com.intellij.util.io.URLUtil;
@@ -23,7 +23,7 @@ import java.util.List;
*/
public final class PydevXmlUtils {
- private static final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ private static final SAXParserFactory parserFactory = SAXParserFactory.newDefaultInstance();
private PydevXmlUtils() {
}
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java b/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java
index a779ec4a0ca9..9eef0cedd7a6 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java
+++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HTMLControls.java
@@ -1,16 +1,13 @@
-// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
+// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.xml.util;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.JDOMUtil;
-import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.openapi.vfs.CharsetToolkit;
-import com.intellij.util.io.UnsyncByteArrayInputStream;
+import com.intellij.util.ResourceUtil;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
@@ -33,15 +30,9 @@ public final class HTMLControls {
private static Control[] loadControls() {
Element element;
try {
- // use temporary bytes stream because otherwise inputStreamSkippingBOM will fail
- // on ZipFileInputStream used in jar files
- final byte[] bytes;
- try (final InputStream stream = HTMLControls.class.getResourceAsStream("HtmlControls.xml")) {
- bytes = FileUtilRt.loadBytes(stream);
- }
- try (final UnsyncByteArrayInputStream bytesStream = new UnsyncByteArrayInputStream(bytes)) {
- element = JDOMUtil.load(CharsetToolkit.inputStreamSkippingBOM(bytesStream));
- }
+ byte[] bytes = ResourceUtil.getResourceAsBytes("com/intellij/xml/util/HtmlControls.xml", HTMLControls.class.getClassLoader());
+ assert bytes != null;
+ element = JDOMUtil.load(bytes);
}
catch (Exception e) {
LOG.error(e);
diff --git a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml
index 16d91a4db4e6..917f6d1e3514 100644
--- a/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml
+++ b/xml/xml-psi-impl/src/com/intellij/xml/util/HtmlControls.xml
@@ -1,5 +1,4 @@
-
-
+