From 995b91a5ded47fe4377b8bb2c909ca30cf3d49f4 Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 24 Apr 2019 15:11:38 +0200 Subject: [PATCH] cleanup - specify UTF_8 charset explicitly GitOrigin-RevId: b6f12dabfc1a2d2bde4cdaa8f0455351c96e1556 --- .../render/ByteArrayAsStringRenderer.java | 4 ++- .../execution/jshell/JShellHandler.java | 7 ++-- .../jshell/protocol/MessageReader.java | 5 +-- .../jshell/protocol/MessageWriter.java | 5 +-- .../util/CommonSourceRootDetectionUtil.java | 19 ++--------- .../ArtifactoryRepositoryService.java | 25 ++++---------- .../services/bintray/BintrayEndpoint.java | 5 +-- .../compiler/JavaInMemoryCompiler.java | 3 +- .../jetbrains/jps/api/CmdlineProtoUtil.java | 19 ++--------- .../InspectionProfileEntry.java | 3 +- .../build/JUnitLiveTestProgressFormatter.java | 19 ++--------- .../RemoteExternalSystemFacadeImpl.java | 21 +++--------- .../externalSystem/util/OutputWrapper.java | 5 +-- .../options/CodeStyleAbstractPanel.java | 16 +++++---- .../ColorSchemePluginExporter.java | 19 ++--------- .../documentation/AbstractExternalFilter.java | 5 +-- ...cessBackedConsoleExecuteActionHandler.java | 19 ++--------- .../com/intellij/history/core/Content.java | 19 ++--------- .../openapi/diff/DocumentContent.java | 20 +++-------- .../intellij/openapi/diff/SimpleContent.java | 21 +++--------- .../schemes/SerializableSchemeExporter.java | 19 ++--------- .../process/impl/ProcessListUtil.java | 19 ++--------- .../src/com/intellij/idea/IdeaLogger.java | 7 ++-- .../src/com/intellij/idea/Launcher.java | 19 ++--------- .../cachedValueProfiler/CVPReader.java | 5 +-- .../eventLog/EventLogStatisticsService.java | 5 +-- .../diff/impl/mergeTool/MergeVersion.java | 3 +- .../history/core/LocalHistoryTestCase.java | 18 ++-------- .../history/core/LocalVcsLabelsTest.java | 33 ++++++------------- .../history/integration/BasicsTest.java | 29 ++++++++-------- .../integration/GettingContentAtDateTest.java | 20 +++-------- .../integration/IntegrationTestCase.java | 2 +- .../ui/SelectionHistoryDialogTest.java | 20 ++--------- .../ui/models/SelectionCalculatorTest.java | 19 ++--------- .../openapi/editor/richcopy/RichCopyTest.java | 19 ++--------- .../log/ConsoleTerminalHandlerImpl.java | 19 ++--------- .../core/src/com/intellij/TestCaseLoader.java | 5 +-- .../intellij/openapi/util/io/IoTestUtil.java | 2 +- .../testFramework/TestLoggerFactory.java | 19 ++--------- .../testFramework/TestClassesFilterTest.java | 2 +- .../execution/process/UnixProcessManager.java | 5 +-- .../com/intellij/openapi/util/JDOMUtil.java | 2 +- .../intellij/openapi/util/io/FileUtil.java | 2 +- .../intellij/openapi/util/io/StreamUtil.java | 19 ++--------- .../openapi/util/io/WindowsRegistryUtil.java | 21 +++--------- .../com/intellij/util/Base64Converter.java | 22 +++---------- .../util/io/SourceCodeCompressor.java | 19 ++--------- .../util/io/UnsyncByteArrayOutputStream.java | 19 ++--------- .../util/io/zip/JBZipOutputStream.java | 19 ++--------- .../util/containers/PathInternerTest.java | 19 ++--------- .../util/io/zip/UpdateableZipTest.java | 6 ++-- .../com/intellij/openapi/vcs/VcsTestUtil.java | 21 +++--------- .../testFramework/vcs/TestClientRunner.java | 19 ++--------- .../osHandlers/UnixAttachOSHandler.java | 5 +-- .../connections/ssh/SshConnectionUtils.java | 19 ++--------- .../actions/merge/CvsConflictsParser.java | 24 ++++---------- .../actions/merge/CvsMergeProvider.java | 23 +++---------- .../CvsApplicationLevelConfiguration.java | 5 +-- .../cvsIgnore/IgnoredFilesInfoImpl.java | 19 ++--------- .../lib/cvsclient/ConnectionStreams.java | 3 +- .../command/reservedcheckout/EditCommand.java | 3 +- .../connection/PServerConnection.java | 3 +- .../lib/cvsclient/io/StreamUtilities.java | 3 +- .../appengine/sdk/impl/AppEngineSdkImpl.java | 19 ++--------- .../compiler/GradleResourceFileProcessor.java | 19 ++--------- .../groovy/GroovycOutputParser.java | 19 ++--------- .../plugins/groovy/mvc/MvcConsole.java | 5 +-- .../execution/HgPromptCommandExecutor.java | 7 ++-- .../execution/HgRemoteCommandExecutor.java | 13 ++++---- .../testSrc/hg4idea/test/HgEncodingTest.java | 19 ++--------- ...FxGenerateDefaultPropertyValuesScript.java | 4 ++- .../JUnitTreeByDescriptionHierarchyTest.java | 33 ++++++------------- .../compiler/MavenResourceFileProcessor.java | 19 ++--------- .../execution/MavenExternalParameters.java | 3 +- .../maven/vfs/MavenPropertiesVirtualFile.java | 19 ++--------- .../maven/project/MavenProjectReaderTest.java | 19 ++--------- .../idea/svn/commandLine/CommandExecutor.java | 5 +-- .../configuration/SearchingForTestsTask.java | 6 ++-- .../TestNGTreeHierarchyTest.java | 25 ++++---------- .../python/debugger/PydevXmlUtils.java | 5 +-- .../codeInsight/stdlib/PyStdlibUtil.java | 19 ++--------- .../debugger/PySignatureCacheManagerImpl.java | 7 ++-- .../validation/Pep8ExternalAnnotator.java | 27 ++++----------- .../src/com/intellij/updater/Bootstrap.java | 5 +-- .../actions/xmlbeans/Xsd2InstanceUtils.java | 23 +++---------- .../xml/index/XmlSchemaIndexTest.java | 8 +++-- .../xml/index/XsdComplexTypeInfoBuilder.java | 3 +- .../xml/index/XsdNamespaceBuilder.java | 3 +- .../intellij/xml/index/XsdTagNameBuilder.java | 3 +- 89 files changed, 316 insertions(+), 864 deletions(-) diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ByteArrayAsStringRenderer.java b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ByteArrayAsStringRenderer.java index 38f8b8068cac..6e83dd8bddf7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ByteArrayAsStringRenderer.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/tree/render/ByteArrayAsStringRenderer.java @@ -7,6 +7,8 @@ import com.intellij.debugger.ui.tree.ValueDescriptor; import com.sun.jdi.ArrayReference; import com.sun.jdi.Value; +import java.nio.charset.StandardCharsets; + /** * @author egor */ @@ -24,7 +26,7 @@ final class ByteArrayAsStringRenderer extends CompoundReferenceRenderer { // TODO: read charset from the target vm byte[] bytes = DebuggerUtilsImpl.readBytesArray(value); if (bytes != null) { - return new String(bytes); + return new String(bytes, StandardCharsets.UTF_8); } } } diff --git a/java/execution/impl/src/com/intellij/execution/jshell/JShellHandler.java b/java/execution/impl/src/com/intellij/execution/jshell/JShellHandler.java index 20702dc94d6d..11ffdc2095bb 100644 --- a/java/execution/impl/src/com/intellij/execution/jshell/JShellHandler.java +++ b/java/execution/impl/src/com/intellij/execution/jshell/JShellHandler.java @@ -14,7 +14,10 @@ import com.intellij.execution.process.*; import com.intellij.execution.ui.ConsoleViewContentType; import com.intellij.execution.ui.RunContentDescriptor; import com.intellij.execution.ui.actions.CloseAction; -import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.ActionManager; +import com.intellij.openapi.actionSystem.ActionToolbar; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.diagnostic.Logger; @@ -81,7 +84,7 @@ public class JShellHandler { myProcess = handler; final PipedInputStream is = new PipedInputStream(); - final OutputStreamWriter readerSink = new OutputStreamWriter(new PipedOutputStream(is)); + final OutputStreamWriter readerSink = new OutputStreamWriter(new PipedOutputStream(is), StandardCharsets.UTF_8); myMessageReader = new MessageReader<>(is, Response.class); myMessageWriter = new MessageWriter<>(handler.getProcessInput()); diff --git a/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageReader.java b/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageReader.java index 470a1ec3b9b2..fc0bea89d859 100644 --- a/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageReader.java +++ b/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageReader.java @@ -1,7 +1,8 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.execution.jshell.protocol; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.function.Consumer; @@ -13,7 +14,7 @@ public class MessageReader extends Endpoint { private final Class myMsgType; public MessageReader(InputStream input, Class msgType) { - myIn = new BufferedReader(new InputStreamReader(input)); + myIn = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8)); myMsgType = msgType; } diff --git a/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageWriter.java b/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageWriter.java index f039009a9519..3544821c4113 100644 --- a/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageWriter.java +++ b/java/execution/jshell-protocol/src/com/intellij/execution/jshell/protocol/MessageWriter.java @@ -1,7 +1,8 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.execution.jshell.protocol; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.Base64; /** @@ -11,7 +12,7 @@ public class MessageWriter extends Endpoint { private final BufferedWriter myOut; public MessageWriter(OutputStream output) { - myOut = new BufferedWriter(new OutputStreamWriter(output)); + myOut = new BufferedWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8)); } public void send(T message) throws IOException { diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/util/CommonSourceRootDetectionUtil.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/util/CommonSourceRootDetectionUtil.java index 84f99abd9376..b07120dc80b5 100644 --- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/util/CommonSourceRootDetectionUtil.java +++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/importSources/util/CommonSourceRootDetectionUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2011 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-2019 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. package com.intellij.ide.util.projectWizard.importSources.util; import com.intellij.openapi.util.Pair; @@ -26,6 +12,7 @@ import com.intellij.util.text.StringFactory; import org.jetbrains.annotations.Nullable; import java.io.*; +import java.nio.charset.StandardCharsets; public abstract class CommonSourceRootDetectionUtil { @@ -109,7 +96,7 @@ public abstract class CommonSourceRootDetectionUtil { private static char[] loadFileTextSkippingBom(File file) throws IOException { try (InputStream stream = CharsetToolkit.inputStreamSkippingBOM(new BufferedInputStream(new FileInputStream(file))); - Reader reader = new InputStreamReader(stream)) { + Reader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { return FileUtilRt.loadText(reader, (int)file.length()); } } diff --git a/java/java-impl/src/com/intellij/jarRepository/services/artifactory/ArtifactoryRepositoryService.java b/java/java-impl/src/com/intellij/jarRepository/services/artifactory/ArtifactoryRepositoryService.java index 04868d997688..e13ad883e8ad 100644 --- a/java/java-impl/src/com/intellij/jarRepository/services/artifactory/ArtifactoryRepositoryService.java +++ b/java/java-impl/src/com/intellij/jarRepository/services/artifactory/ArtifactoryRepositoryService.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2010 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-2019 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. package com.intellij.jarRepository.services.artifactory; import com.google.gson.Gson; @@ -27,6 +13,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -48,7 +35,7 @@ public class ArtifactoryRepositoryService extends MavenRepositoryService { try { final Gson gson = new Gson(); final InputStreamReader stream = - new InputStreamReader(new Endpoint.Repositories(url).getRepositoryDetailsListJson(null).getInputStream()); + new InputStreamReader(new Endpoint.Repositories(url).getRepositoryDetailsListJson(null).getInputStream(), StandardCharsets.UTF_8); final ArtifactoryModel.RepositoryType[] repos = gson.fromJson(stream, ArtifactoryModel.RepositoryType[].class); final List result = new ArrayList<>(repos.length); for (ArtifactoryModel.RepositoryType repo : repos) { @@ -80,7 +67,8 @@ public class ArtifactoryRepositoryService extends MavenRepositoryService { final String name = StringUtil.join(Arrays.asList(template.getGroupId(), template.getArtifactId(), template.getVersion()), ":"); final InputStream stream = new Endpoint.Search.Artifact(url).getArtifactSearchResultJson(name, null).getInputStream(); - final ArtifactoryModel.GavcResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream), ArtifactoryModel.GavcResults.class); + final ArtifactoryModel.GavcResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream, + StandardCharsets.UTF_8), ArtifactoryModel.GavcResults.class); if (results != null && results.results != null) { for (ArtifactoryModel.GavcResult result : results.results) { if (!result.uri.endsWith(packaging)) continue; @@ -93,7 +81,8 @@ public class ArtifactoryRepositoryService extends MavenRepositoryService { final String searchString = className.endsWith("*") || className.endsWith("?") ? className : className + ".class"; final InputStream stream = new Endpoint.Search.Archive(url).getArchiveSearchResultJson(searchString, null).getInputStream(); - final ArtifactoryModel.ArchiveResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream), ArtifactoryModel.ArchiveResults.class); + final ArtifactoryModel.ArchiveResults results = stream == null? null : gson.fromJson(new InputStreamReader(stream, + StandardCharsets.UTF_8), ArtifactoryModel.ArchiveResults.class); if (results != null && results.results != null) { for (ArtifactoryModel.ArchiveResult result : results.results) { for (String uri : result.archiveUris) { diff --git a/java/java-impl/src/com/intellij/jarRepository/services/bintray/BintrayEndpoint.java b/java/java-impl/src/com/intellij/jarRepository/services/bintray/BintrayEndpoint.java index 6a8e06f9d942..c9d4eb47ab58 100644 --- a/java/java-impl/src/com/intellij/jarRepository/services/bintray/BintrayEndpoint.java +++ b/java/java-impl/src/com/intellij/jarRepository/services/bintray/BintrayEndpoint.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.jarRepository.services.bintray; import com.google.gson.Gson; @@ -16,6 +16,7 @@ import java.io.InputStreamReader; import java.io.Reader; import java.net.HttpURLConnection; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -225,7 +226,7 @@ public class BintrayEndpoint { private void handleRequest(HttpRequests.Request request, Class responseDataClass, ThrowableConsumer responseHandler) throws IOException { try (InputStream in = request.getInputStream(); - Reader reader = new InputStreamReader(in)) { + Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8)) { Data data = gson.fromJson(reader, responseDataClass); responseHandler.consume(data); } diff --git a/java/testFramework/src/com/intellij/compiler/JavaInMemoryCompiler.java b/java/testFramework/src/com/intellij/compiler/JavaInMemoryCompiler.java index bf98dc77767b..edd82342f28f 100644 --- a/java/testFramework/src/com/intellij/compiler/JavaInMemoryCompiler.java +++ b/java/testFramework/src/com/intellij/compiler/JavaInMemoryCompiler.java @@ -6,6 +6,7 @@ import org.intellij.lang.annotations.Language; import javax.tools.*; import java.io.*; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.*; /** @@ -31,7 +32,7 @@ public class JavaInMemoryCompiler { final Iterable compilationUnits = Collections.singletonList(new JavaSourceFromString(className, code)); final Iterable options = Arrays.asList("-g"); // generate debugging info. @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") - final OutputStreamWriter out = new OutputStreamWriter(System.err); + final OutputStreamWriter out = new OutputStreamWriter(System.err, StandardCharsets.UTF_8); final Boolean success = myCompiler.getTask(out, myFileManager, diagnostics, options, null, compilationUnits).call(); if (!success.booleanValue()) { diff --git a/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java b/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java index faa7bbd8ec27..54063b26fadb 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java +++ b/jps/jps-builders/src/org/jetbrains/jps/api/CmdlineProtoUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2012 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-2019 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. package org.jetbrains.jps.api; import com.intellij.openapi.util.Pair; @@ -23,6 +9,7 @@ import org.jetbrains.jps.incremental.messages.BuildMessage; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.nio.charset.StandardCharsets; import java.util.*; import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.BuilderMessage; @@ -120,7 +107,7 @@ public class CmdlineProtoUtil { try (PrintStream stream = new PrintStream(baos)) { cause.printStackTrace(stream); } - final String stacktrace = new String(baos.toByteArray()); + final String stacktrace = new String(baos.toByteArray(), StandardCharsets.UTF_8); builder.setStacktrace(stacktrace); if (description == null) { builder.setDescription(stacktrace); diff --git a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java index a064f8a371f1..6f82beff3404 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/InspectionProfileEntry.java @@ -34,6 +34,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.*; @Property(assertIfNoBindings = false) @@ -348,7 +349,7 @@ public abstract class InspectionProfileEntry implements BatchSuppressableTool { return; } - try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()))) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { String line; while ((line = reader.readLine()) != null) { line = line.trim(); diff --git a/platform/build-scripts/testSrc/org/jetbrains/intellij/build/JUnitLiveTestProgressFormatter.java b/platform/build-scripts/testSrc/org/jetbrains/intellij/build/JUnitLiveTestProgressFormatter.java index f42bac0de4c0..e9933ee0a51a 100644 --- a/platform/build-scripts/testSrc/org/jetbrains/intellij/build/JUnitLiveTestProgressFormatter.java +++ b/platform/build-scripts/testSrc/org/jetbrains/intellij/build/JUnitLiveTestProgressFormatter.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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-2019 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. package org.jetbrains.intellij.build; import junit.framework.AssertionFailedError; @@ -26,6 +12,7 @@ import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; /** * @author nik @@ -36,7 +23,7 @@ public class JUnitLiveTestProgressFormatter implements JUnitResultFormatter, Ign @Override public void setOutput(OutputStream out) { - myOut = new PrintWriter(new OutputStreamWriter(out)); + myOut = new PrintWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)); } @Override diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacadeImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacadeImpl.java index e40fd5683323..fd500bcde051 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacadeImpl.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/RemoteExternalSystemFacadeImpl.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-2019 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. package com.intellij.openapi.externalSystem.service; import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings; @@ -29,6 +15,7 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; +import java.nio.charset.StandardCharsets; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.util.concurrent.CompletableFuture; @@ -172,14 +159,14 @@ public class RemoteExternalSystemFacadeImpl processListOptions() { return Collections.emptySet(); } - + public final void applyPredefinedSettings(@NotNull PredefinedCodeStyle codeStyle) { codeStyle.apply(mySettings); ((CodeStyleSchemesModel.ModelSettings) mySettings).doWithLockedSettings(()->resetImpl(mySettings)); @@ -578,7 +580,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable, ComponentHig } /** - * Override this method if the panel is linked to a specific language. + * Override this method if the panel is linked to a specific language. * @return The language this panel is associated with. */ @Nullable @@ -589,11 +591,11 @@ public abstract class CodeStyleAbstractPanel implements Disposable, ComponentHig protected String getTabTitle() { return "Other"; } - + protected CodeStyleSettings getCurrentSettings() { return myCurrentSettings; } - + public void setupCopyFromMenu(JPopupMenu copyMenu) { copyMenu.removeAll(); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/ColorSchemePluginExporter.java b/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/ColorSchemePluginExporter.java index b798d3c48222..76af17dc7edb 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/ColorSchemePluginExporter.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/pluginExport/ColorSchemePluginExporter.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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-2019 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. package com.intellij.application.options.colors.pluginExport; import com.intellij.application.options.schemes.SerializableSchemeExporter; @@ -28,6 +14,7 @@ import java.awt.*; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -73,7 +60,7 @@ public class ColorSchemePluginExporter extends ConfigurableSchemeExporter { } private static void writeToStream(@NotNull OutputStream outputStream, @NotNull Element element) throws IOException { - OutputStreamWriter writer = new OutputStreamWriter(outputStream); + OutputStreamWriter writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8); Format format = Format.getPrettyFormat(); format.setLineSeparator("\n"); new XMLOutputter(format).output(element, writer); diff --git a/platform/platform-impl/src/com/intellij/execution/process/impl/ProcessListUtil.java b/platform/platform-impl/src/com/intellij/execution/process/impl/ProcessListUtil.java index f36e677976f0..b6098acd71dd 100644 --- a/platform/platform-impl/src/com/intellij/execution/process/impl/ProcessListUtil.java +++ b/platform/platform-impl/src/com/intellij/execution/process/impl/ProcessListUtil.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-2019 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. package com.intellij.execution.process.impl; @@ -34,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -125,7 +112,7 @@ public class ProcessListUtil { List cmdline; try (FileInputStream stream = new FileInputStream(new File(each, "cmdline"))) { //noinspection SSBasedInspection - no better candidate for system encoding anyways - String cmdlineString = new String(FileUtil.loadBytes(stream)); + String cmdlineString = new String(FileUtil.loadBytes(stream), StandardCharsets.UTF_8); cmdline = StringUtil.split(cmdlineString, "\0"); } catch (IOException e) { diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java b/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java index e30210d248a8..22c4772393e2 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaLogger.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.idea; import com.intellij.diagnostic.LogMessage; @@ -23,6 +23,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; +import java.nio.charset.StandardCharsets; /** * @author Mike @@ -44,7 +45,7 @@ public class IdeaLogger extends Log4jBasedLogger { String stamp = null; URL resource = Logger.class.getResource("/.compilation-timestamp"); if (resource != null) { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream()))) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(resource.openStream(), StandardCharsets.UTF_8))) { String s = reader.readLine(); if (s != null) { stamp = s.trim(); @@ -141,7 +142,7 @@ public class IdeaLogger extends Log4jBasedLogger { "; VM: " + System.getProperties().getProperty("java.vm.name", "unknown") + "; Vendor: " + System.getProperties().getProperty("java.vendor", "unknown")); myLogger.error("OS: " + System.getProperties().getProperty("os.name", "unknown")); - + IdeaPluginDescriptor plugin = t == null ? null : PluginManager.findPluginIfInitialized(t); if (plugin != null && (!plugin.isBundled() || plugin.allowBundledUpdate())) { myLogger.error("Plugin to blame: " + plugin.getName() + " version: " + plugin.getVersion()); diff --git a/platform/platform-impl/src/com/intellij/idea/Launcher.java b/platform/platform-impl/src/com/intellij/idea/Launcher.java index 2b21a54a80a0..a2d4199565a3 100644 --- a/platform/platform-impl/src/com/intellij/idea/Launcher.java +++ b/platform/platform-impl/src/com/intellij/idea/Launcher.java @@ -1,21 +1,8 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.idea; import java.io.*; +import java.nio.charset.StandardCharsets; /** * @author max @@ -51,7 +38,7 @@ public class Launcher { @Override public void run() { - Reader reader = new InputStreamReader(myInput); + Reader reader = new InputStreamReader(myInput, StandardCharsets.UTF_8); do { int ch = 0; try { diff --git a/platform/platform-impl/src/com/intellij/internal/cachedValueProfiler/CVPReader.java b/platform/platform-impl/src/com/intellij/internal/cachedValueProfiler/CVPReader.java index debc08aa68b5..76eec7b1abd9 100644 --- a/platform/platform-impl/src/com/intellij/internal/cachedValueProfiler/CVPReader.java +++ b/platform/platform-impl/src/com/intellij/internal/cachedValueProfiler/CVPReader.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.internal.cachedValueProfiler; import com.google.gson.stream.JsonReader; @@ -8,6 +8,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -20,7 +21,7 @@ public class CVPReader { @NotNull public static List deserialize(@NotNull InputStream stream) throws IOException { - try (JsonReader reader = new JsonReader(new InputStreamReader(stream))) { + try (JsonReader reader = new JsonReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) { return new CVPReader(reader).read(); } } diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java index c4213322aa4e..bcc52677e6e1 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java +++ b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/EventLogStatisticsService.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.internal.statistic.eventLog; import com.intellij.internal.statistic.connect.StatServiceException; @@ -17,6 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -86,7 +87,7 @@ public class EventLogStatisticsService implements StatisticsService { .tuner(connection -> connection.setRequestProperty("Content-Encoding", "gzip")) .connect(request -> { final BufferExposingByteArrayOutputStream out = new BufferExposingByteArrayOutputStream(); - try (OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(out))) { + try (OutputStreamWriter writer = new OutputStreamWriter(new GZIPOutputStream(out), StandardCharsets.UTF_8)) { LogEventSerializer.INSTANCE.toString(recordRequest, writer); } request.write(out.toByteArray()); diff --git a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java index fdaed9107432..89c0447b8e3d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java +++ b/platform/platform-impl/src/com/intellij/openapi/diff/impl/mergeTool/MergeVersion.java @@ -19,6 +19,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.nio.charset.StandardCharsets; @Deprecated public interface MergeVersion { @@ -102,7 +103,7 @@ public interface MergeVersion { @Override public byte[] getBytes() throws IOException { VirtualFile file = getFile(); - return file != null ? file.contentsToByteArray() : myDocument.getText().getBytes(); + return file != null ? file.contentsToByteArray() : myDocument.getText().getBytes(StandardCharsets.UTF_8); } @Override diff --git a/platform/platform-tests/testSrc/com/intellij/history/core/LocalHistoryTestCase.java b/platform/platform-tests/testSrc/com/intellij/history/core/LocalHistoryTestCase.java index 49ba64cda8b9..48dbaa993949 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/core/LocalHistoryTestCase.java +++ b/platform/platform-tests/testSrc/com/intellij/history/core/LocalHistoryTestCase.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package com.intellij.history.core; @@ -213,7 +199,7 @@ public abstract class LocalHistoryTestCase extends Assert { } protected static void assertContent(String expected, Content c) { - assertEquals(expected, new String(c.getBytes())); + assertEquals(expected, new String(c.getBytes(), StandardCharsets.UTF_8)); } protected static void assertEquals(Object[] expected, Collection actual) { diff --git a/platform/platform-tests/testSrc/com/intellij/history/core/LocalVcsLabelsTest.java b/platform/platform-tests/testSrc/com/intellij/history/core/LocalVcsLabelsTest.java index 0aa835ceedcc..2fb3eb926ace 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/core/LocalVcsLabelsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/core/LocalVcsLabelsTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2019 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. package com.intellij.history.core; @@ -20,6 +6,7 @@ import com.intellij.history.core.revisions.Revision; import com.intellij.history.core.tree.RootEntry; import org.junit.Test; +import java.nio.charset.StandardCharsets; import java.util.List; public class LocalVcsLabelsTest extends LocalHistoryTestCase { @@ -147,8 +134,8 @@ public class LocalVcsLabelsTest extends LocalHistoryTestCase { LabelImpl l3 = myVcs.putSystemLabel("label", "project", -1); assertNull(l1.getByteContent(myRoot, "f").getBytes()); - assertEquals("one", new String(l2.getByteContent(myRoot, "f").getBytes())); - assertEquals("two", new String(l3.getByteContent(myRoot, "f").getBytes())); + assertEquals("one", new String(l2.getByteContent(myRoot, "f").getBytes(), StandardCharsets.UTF_8)); + assertEquals("two", new String(l3.getByteContent(myRoot, "f").getBytes(), StandardCharsets.UTF_8)); add(myVcs, createDirectory(myRoot, "dir")); LabelImpl l4 = myVcs.putSystemLabel("label", "project", -1); @@ -156,7 +143,7 @@ public class LocalVcsLabelsTest extends LocalHistoryTestCase { assertTrue(l4.getByteContent(myRoot, "dir").isDirectory()); assertNull(l4.getByteContent(myRoot, "dir").getBytes()); } - + @Test public void testGettingByteContentInsideChangeSet() { myVcs.beginChangeSet(); @@ -166,8 +153,8 @@ public class LocalVcsLabelsTest extends LocalHistoryTestCase { LabelImpl l2 = myVcs.putSystemLabel("label", "project", -1); myVcs.endChangeSet(null); - assertEquals("one", new String(l1.getByteContent(myRoot, "f").getBytes())); - assertEquals("two", new String(l2.getByteContent(myRoot, "f").getBytes())); + assertEquals("one", new String(l1.getByteContent(myRoot, "f").getBytes(), StandardCharsets.UTF_8)); + assertEquals("two", new String(l2.getByteContent(myRoot, "f").getBytes(), StandardCharsets.UTF_8)); } @Test @@ -181,8 +168,8 @@ public class LocalVcsLabelsTest extends LocalHistoryTestCase { LabelImpl l3 = myVcs.putSystemLabel("label", "project", -1); - assertEquals("one", new String(l1.getByteContent(myRoot, "f_r").getBytes())); - assertEquals("two", new String(l2.getByteContent(myRoot, "f_r").getBytes())); - assertEquals("two", new String(l3.getByteContent(myRoot, "f_r").getBytes())); + assertEquals("one", new String(l1.getByteContent(myRoot, "f_r").getBytes(), StandardCharsets.UTF_8)); + assertEquals("two", new String(l2.getByteContent(myRoot, "f_r").getBytes(), StandardCharsets.UTF_8)); + assertEquals("two", new String(l3.getByteContent(myRoot, "f_r").getBytes(), StandardCharsets.UTF_8)); } } \ No newline at end of file diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/BasicsTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/BasicsTest.java index 37abe53852c1..7880e3629667 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/BasicsTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/BasicsTest.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.history.integration; import com.intellij.history.LocalHistory; @@ -14,6 +14,7 @@ import com.intellij.openapi.vfs.VirtualFile; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; @@ -85,14 +86,14 @@ public class BasicsTest extends IntegrationTestCase { List rr = getRevisionsFor(f); assertEquals(9, rr.size()); // 5 changes + 3 labels - assertEquals("4", new String(rr.get(0).findEntry().getContent().getBytes())); - assertEquals("4", new String(rr.get(1).findEntry().getContent().getBytes())); - assertEquals("3", new String(rr.get(2).findEntry().getContent().getBytes())); - assertEquals("3", new String(rr.get(3).findEntry().getContent().getBytes())); - assertEquals("2", new String(rr.get(4).findEntry().getContent().getBytes())); - assertEquals("2", new String(rr.get(5).findEntry().getContent().getBytes())); - assertEquals("1", new String(rr.get(6).findEntry().getContent().getBytes())); - assertEquals("", new String(rr.get(7).findEntry().getContent().getBytes())); + assertEquals("4", new String(rr.get(0).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("4", new String(rr.get(1).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("3", new String(rr.get(2).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("3", new String(rr.get(3).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("2", new String(rr.get(4).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("2", new String(rr.get(5).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("1", new String(rr.get(6).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("", new String(rr.get(7).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); } public void testDoNotRegisterSameUnsavedDocumentContentTwice() { @@ -105,11 +106,11 @@ public class BasicsTest extends IntegrationTestCase { List rr = getRevisionsFor(f); assertEquals(6, rr.size()); // 3 changes + 2 labels - assertEquals("2", new String(rr.get(0).findEntry().getContent().getBytes())); - assertEquals("2", new String(rr.get(1).findEntry().getContent().getBytes())); - assertEquals("2", new String(rr.get(2).findEntry().getContent().getBytes())); - assertEquals("1", new String(rr.get(3).findEntry().getContent().getBytes())); - assertEquals("", new String(rr.get(4).findEntry().getContent().getBytes())); + assertEquals("2", new String(rr.get(0).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("2", new String(rr.get(1).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("2", new String(rr.get(2).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("1", new String(rr.get(3).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); + assertEquals("", new String(rr.get(4).findEntry().getContent().getBytes(), StandardCharsets.UTF_8)); } public void testIsUnderControl() { diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/GettingContentAtDateTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/GettingContentAtDateTest.java index 8c4dab3ffbf6..74ad0a193083 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/GettingContentAtDateTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/GettingContentAtDateTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.history.integration; @@ -23,6 +9,8 @@ import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.util.Clock; import com.intellij.openapi.vfs.VirtualFile; +import java.nio.charset.StandardCharsets; + public class GettingContentAtDateTest extends IntegrationTestCase { private VirtualFile f; @@ -129,7 +117,7 @@ public class GettingContentAtDateTest extends IntegrationTestCase { private void assertContentAt(FileRevisionTimestampComparator c, String expected) { byte[] actual = LocalHistory.getInstance().getByteContent(f, c); - assertEquals(expected, actual == null ? null : new String(actual)); + assertEquals(expected, actual == null ? null : new String(actual, StandardCharsets.UTF_8)); } private FileRevisionTimestampComparator comparator(final long timestamp) { diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java b/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java index 01a797b97821..9e9406b8f057 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/IntegrationTestCase.java @@ -199,6 +199,6 @@ public abstract class IntegrationTestCase extends PlatformTestCase { } protected static void assertContent(String expected, Entry e) { - assertEquals(expected, new String(e.getContent().getBytes())); + assertEquals(expected, new String(e.getContent().getBytes(), StandardCharsets.UTF_8)); } } diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/SelectionHistoryDialogTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/SelectionHistoryDialogTest.java index 1d63468fbed0..f7b99b9c7a04 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/SelectionHistoryDialogTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/SelectionHistoryDialogTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.history.integration.ui; @@ -109,7 +95,7 @@ public class SelectionHistoryDialogTest extends LocalHistoryUITestCase { byte[] bytes = f.contentsToByteArray(); delete(f); - f = createFile(f.getName(), new String(bytes)); + f = createFile(f.getName(), new String(bytes, StandardCharsets.UTF_8)); loadContent(f); initModelOnSecondLineAndSelectRevisions(3, 3); @@ -123,7 +109,7 @@ public class SelectionHistoryDialogTest extends LocalHistoryUITestCase { Reverter r = m.createReverter(); r.revert(); - assertEquals("a\nbc\nc\ne\n", new String(f.contentsToByteArray())); + assertEquals("a\nbc\nc\ne\n", new String(f.contentsToByteArray(), StandardCharsets.UTF_8)); } private void initModelOnSecondLineAndSelectRevisions(int first, int second) { diff --git a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/models/SelectionCalculatorTest.java b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/models/SelectionCalculatorTest.java index 7aa4140ea049..90fd874bbb4a 100644 --- a/platform/platform-tests/testSrc/com/intellij/history/integration/ui/models/SelectionCalculatorTest.java +++ b/platform/platform-tests/testSrc/com/intellij/history/integration/ui/models/SelectionCalculatorTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2019 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. package com.intellij.history.integration.ui.models; @@ -26,6 +12,7 @@ import com.intellij.history.integration.IdeaGateway; import org.jetbrains.annotations.NotNull; import org.junit.Test; +import java.nio.charset.StandardCharsets; import java.util.List; import static org.easymock.EasyMock.*; @@ -134,7 +121,7 @@ public class SelectionCalculatorTest extends LocalHistoryTestCase { private static class MyIdeaGateway extends IdeaGateway { @Override public String stringFromBytes(@NotNull byte[] bytes, @NotNull String path) { - return new String(bytes); + return new String(bytes, StandardCharsets.UTF_8); } } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/richcopy/RichCopyTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/richcopy/RichCopyTest.java index 300c0fbe9040..7f4b3c853d97 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/richcopy/RichCopyTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/richcopy/RichCopyTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package com.intellij.openapi.editor.richcopy; import com.intellij.openapi.editor.richcopy.view.HtmlTransferableData; @@ -30,6 +16,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.Reader; +import java.nio.charset.StandardCharsets; public class RichCopyTest extends LightPlatformCodeInsightFixtureTestCase { private static final String PLATFORM_SPECIFIC_PLACEHOLDER = "___PLATFORM_SPECIFIC___"; @@ -87,7 +74,7 @@ public class RichCopyTest extends LightPlatformCodeInsightFixtureTestCase { } private static String readFully(InputStream inputStream) throws IOException { - return new String(FileUtilRt.loadBytes(inputStream)); + return new String(FileUtilRt.loadBytes(inputStream), StandardCharsets.UTF_8); } private static String readFully(Reader reader) throws IOException { diff --git a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java index 207f36e469c2..cbc435b600a7 100644 --- a/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java +++ b/platform/remote-servers/impl/src/com/intellij/remoteServer/impl/runtime/log/ConsoleTerminalHandlerImpl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.remoteServer.impl.runtime.log; import com.intellij.execution.process.ProcessHandler; @@ -24,6 +10,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.io.*; +import java.nio.charset.StandardCharsets; public class ConsoleTerminalHandlerImpl extends TerminalHandlerBase { @@ -64,7 +51,7 @@ public class ConsoleTerminalHandlerImpl extends TerminalHandlerBase { Disposer.register(this, myLoggingHandler); ApplicationManager.getApplication().executeOnPooledThread(() -> { - try (BufferedReader outputReader = new BufferedReader(new InputStreamReader(terminalOutput))) { + try (BufferedReader outputReader = new BufferedReader(new InputStreamReader(terminalOutput, StandardCharsets.UTF_8))) { while (!isClosed()) { String line = outputReader.readLine(); if (line == null) { diff --git a/platform/testFramework/core/src/com/intellij/TestCaseLoader.java b/platform/testFramework/core/src/com/intellij/TestCaseLoader.java index 6814b8a6f9c2..3d46b130ec38 100644 --- a/platform/testFramework/core/src/com/intellij/TestCaseLoader.java +++ b/platform/testFramework/core/src/com/intellij/TestCaseLoader.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij; import com.intellij.idea.Bombed; @@ -26,6 +26,7 @@ import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.function.ToIntFunction; @@ -95,7 +96,7 @@ public class TestCaseLoader { MultiMap groups = MultiMap.createLinked(); for (URL fileUrl : groupingFileUrls) { - try (InputStreamReader reader = new InputStreamReader(fileUrl.openStream())) { + try (InputStreamReader reader = new InputStreamReader(fileUrl.openStream(), StandardCharsets.UTF_8)) { groups.putAllValues(GroupBasedTestClassFilter.readGroups(reader)); } catch (IOException e) { diff --git a/platform/testFramework/src/com/intellij/openapi/util/io/IoTestUtil.java b/platform/testFramework/src/com/intellij/openapi/util/io/IoTestUtil.java index b1aea9fc5ed4..56c9fb26e159 100644 --- a/platform/testFramework/src/com/intellij/openapi/util/io/IoTestUtil.java +++ b/platform/testFramework/src/com/intellij/openapi/util/io/IoTestUtil.java @@ -151,7 +151,7 @@ public class IoTestUtil { Process process = builder.start(); StringBuilder output = new StringBuilder(); Thread thread = new Thread(() -> { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) { String line; while ((line = reader.readLine()) != null) { output.append(line).append('\n'); diff --git a/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java b/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java index abc28ea40736..885efec2b685 100644 --- a/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java +++ b/platform/testFramework/src/com/intellij/testFramework/TestLoggerFactory.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.testFramework; import com.intellij.openapi.Disposable; @@ -33,6 +19,7 @@ import org.junit.rules.TestWatcher; import org.junit.runner.Description; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -129,7 +116,7 @@ public class TestLoggerFactory implements Logger.Factory { file.seek(length - LOG_SEEK_WINDOW); byte[] bytes = new byte[(int)LOG_SEEK_WINDOW]; int read = file.read(bytes); - logText = new String(bytes, 0, read); + logText = new String(bytes, 0, read, StandardCharsets.UTF_8); } } else { diff --git a/platform/testFramework/testSrc/com/intellij/testFramework/TestClassesFilterTest.java b/platform/testFramework/testSrc/com/intellij/testFramework/TestClassesFilterTest.java index e965f1d6f9f1..d32f5c9070fd 100644 --- a/platform/testFramework/testSrc/com/intellij/testFramework/TestClassesFilterTest.java +++ b/platform/testFramework/testSrc/com/intellij/testFramework/TestClassesFilterTest.java @@ -137,7 +137,7 @@ public class TestClassesFilterTest { } private static InputStreamReader getReader(String filterText) { - return new InputStreamReader(new ByteArrayInputStream(filterText.getBytes(StandardCharsets.UTF_8))); + return new InputStreamReader(new ByteArrayInputStream(filterText.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); } private static void checkForAllExcludedDefinedGroup(TestClassesFilter classesFilter) { diff --git a/platform/util/src/com/intellij/execution/process/UnixProcessManager.java b/platform/util/src/com/intellij/execution/process/UnixProcessManager.java index 025a87ba7838..4394ec586d41 100644 --- a/platform/util/src/com/intellij/execution/process/UnixProcessManager.java +++ b/platform/util/src/com/intellij/execution/process/UnixProcessManager.java @@ -16,6 +16,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.*; import static com.intellij.util.ObjectUtils.assertNotNull; @@ -209,8 +210,8 @@ public class UnixProcessManager { } private static void processCommandOutput(Process process, Processor processor, boolean skipFirstLine, boolean throwOnError) throws IOException { - try (BufferedReader stdOutput = new BufferedReader(new InputStreamReader(process.getInputStream()))) { - try (BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream()))) { + try (BufferedReader stdOutput = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8))) { + try (BufferedReader stdError = new BufferedReader(new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8))) { if (skipFirstLine) { stdOutput.readLine(); //ps output header } diff --git a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java index 3ffa39c72a84..a4fddd00c081 100644 --- a/platform/util/src/com/intellij/openapi/util/JDOMUtil.java +++ b/platform/util/src/com/intellij/openapi/util/JDOMUtil.java @@ -263,7 +263,7 @@ public class JDOMUtil { @NotNull public static Document loadDocument(@NotNull File file) throws JDOMException, IOException { - return loadDocumentUsingStaX(new BufferedReader(new InputStreamReader(new FileInputStream(file)))); + return loadDocumentUsingStaX(new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))); } @NotNull diff --git a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java index bce77710fa01..b12cc227fef4 100644 --- a/platform/util/src/com/intellij/openapi/util/io/FileUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java @@ -220,7 +220,7 @@ public class FileUtil extends FileUtilRt { @NotNull public static String loadTextAndClose(@NotNull InputStream stream) throws IOException { - return loadTextAndClose(new InputStreamReader(stream)); + return loadTextAndClose(new InputStreamReader(stream, StandardCharsets.UTF_8)); } @NotNull diff --git a/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java b/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java index bc1921d35916..728768e7afee 100644 --- a/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/StreamUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package com.intellij.openapi.util.io; import com.intellij.openapi.diagnostic.Logger; @@ -23,6 +9,7 @@ import org.jetbrains.annotations.Nullable; import java.io.*; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; public class StreamUtil { private static final Logger LOG = Logger.getInstance(StreamUtil.class); @@ -67,7 +54,7 @@ public class StreamUtil { @NotNull public static String readText(@NotNull InputStream inputStream) throws IOException { final byte[] data = loadFromStream(inputStream); - return new String(data); + return new String(data, StandardCharsets.UTF_8); } @NotNull diff --git a/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java b/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java index dd6f3b23ec63..4a6de7549173 100644 --- a/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java +++ b/platform/util/src/com/intellij/openapi/util/io/WindowsRegistryUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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-2019 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. package com.intellij.openapi.util.io; import org.jetbrains.annotations.NotNull; @@ -21,6 +7,7 @@ import org.jetbrains.annotations.Nullable; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -86,7 +73,7 @@ public class WindowsRegistryUtil { } return result; } - + @NotNull public static List readRegistryBranchValues(@NotNull String location) { List result = new ArrayList<>(); @@ -131,7 +118,7 @@ public class WindowsRegistryUtil { for (int length = is.read(buffer); length > 0; length = is.read(buffer)) { os.write(buffer, 0, length); } - output = new StringBuilder(new String(os.toByteArray())); + output = new StringBuilder(new String(os.toByteArray(), StandardCharsets.UTF_8)); } catch (IOException ignored) { diff --git a/platform/util/src/com/intellij/util/Base64Converter.java b/platform/util/src/com/intellij/util/Base64Converter.java index 04171dbc36f4..cd9506fe07a0 100644 --- a/platform/util/src/com/intellij/util/Base64Converter.java +++ b/platform/util/src/com/intellij/util/Base64Converter.java @@ -1,23 +1,11 @@ -/* - * 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-2019 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. package com.intellij.util; import com.intellij.util.text.StringFactory; import org.jetbrains.annotations.NotNull; +import java.nio.charset.StandardCharsets; + /** * @deprecated Please use {@link java.util.Base64} instead */ @@ -52,7 +40,7 @@ public class Base64Converter { }; public static String encode(@NotNull String s) { - return encode(s.getBytes()); + return encode(s.getBytes(StandardCharsets.UTF_8)); } public static String encode(@NotNull byte[] octetString) { @@ -114,7 +102,7 @@ public class Base64Converter { } public static String decode(@NotNull String s) { - return new String(decode(s.getBytes())); + return new String(decode(s.getBytes(StandardCharsets.UTF_8)), StandardCharsets.UTF_8); } public static byte[] decode(@NotNull byte[] bytes) { diff --git a/platform/util/src/com/intellij/util/io/SourceCodeCompressor.java b/platform/util/src/com/intellij/util/io/SourceCodeCompressor.java index 1041c4e0e149..6ca337c3242a 100644 --- a/platform/util/src/com/intellij/util/io/SourceCodeCompressor.java +++ b/platform/util/src/com/intellij/util/io/SourceCodeCompressor.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-2019 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. /* * @author max @@ -24,6 +10,7 @@ import org.jetbrains.annotations.NonNls; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import java.util.zip.Inflater; @@ -53,7 +40,7 @@ public class SourceCodeCompressor { "/>\r\ntable

{ try { final long newTs = Math.max(System.currentTimeMillis(), file.getTimeStamp() + 1100); - file.setBinaryContent(newContent.getBytes(), -1, newTs); + file.setBinaryContent(newContent.getBytes(StandardCharsets.UTF_8), -1, newTs); final File file1 = new File(file.getPath()); - FileUtil.writeToFile(file1, newContent.getBytes()); + FileUtil.writeToFile(file1, newContent.getBytes(StandardCharsets.UTF_8)); file.refresh(false, false); assertTrue(file1 + " / " + newTs, file1.setLastModified(newTs)); } diff --git a/platform/vcs-tests/src/com/intellij/testFramework/vcs/TestClientRunner.java b/platform/vcs-tests/src/com/intellij/testFramework/vcs/TestClientRunner.java index 50b8bd186ef6..39a9bb248d41 100644 --- a/platform/vcs-tests/src/com/intellij/testFramework/vcs/TestClientRunner.java +++ b/platform/vcs-tests/src/com/intellij/testFramework/vcs/TestClientRunner.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.testFramework.vcs; import com.intellij.execution.process.CapturingProcessHandler; @@ -28,6 +14,7 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -82,7 +69,7 @@ public class TestClientRunner { if (stdin != null) { try (OutputStream outputStream = clientProcess.getOutputStream()) { - final byte[] bytes = stdin.getBytes(); + final byte[] bytes = stdin.getBytes(StandardCharsets.UTF_8); outputStream.write(bytes); } } diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/osHandlers/UnixAttachOSHandler.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/osHandlers/UnixAttachOSHandler.java index 524bfc9a77d1..1eb00acea7e6 100644 --- a/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/osHandlers/UnixAttachOSHandler.java +++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/attach/osHandlers/UnixAttachOSHandler.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.xdebugger.attach.osHandlers; import com.intellij.execution.ExecutionException; @@ -11,6 +11,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -59,7 +60,7 @@ public abstract class UnixAttachOSHandler extends AttachOSHandler { LOGGER.warn(PTRACE_SCOPE_PATH + " file exists but you don't have permissions to read it."); return 3; // The strongest possible level } - final BufferedReader buf = new BufferedReader(new InputStreamReader(fileStream)); + final BufferedReader buf = new BufferedReader(new InputStreamReader(fileStream, StandardCharsets.UTF_8)); final String fileContent = buf.readLine(); try (Scanner scanner = new Scanner(fileContent)) { diff --git a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshConnectionUtils.java b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshConnectionUtils.java index 4e966b289382..111a9610246a 100644 --- a/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshConnectionUtils.java +++ b/plugins/cvs/cvs-core/src/com/intellij/cvsSupport2/connections/ssh/SshConnectionUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2019 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. package com.intellij.cvsSupport2.connections.ssh; import com.trilead.ssh2.Connection; @@ -22,6 +8,7 @@ import org.netbeans.lib.cvsclient.connection.AuthenticationException; import org.netbeans.lib.cvsclient.connection.ConnectionSettings; import java.io.IOException; +import java.nio.charset.StandardCharsets; public class SshConnectionUtils { private static final int SSH_DEFAULT_PORT = 22; @@ -47,6 +34,6 @@ public class SshConnectionUtils { public static boolean connectionSupportsPing(final Connection connection) { final ClientServerHello csh = connection.getClientServerHello(); - return (csh != null) && (csh.getServerString() != null) && (new String(csh.getServerString()).contains("OpenSSH")); + return (csh != null) && (csh.getServerString() != null) && (new String(csh.getServerString(), StandardCharsets.UTF_8).contains("OpenSSH")); } } diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java index 6e9f92fefc74..b87620f056e1 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsConflictsParser.java @@ -1,23 +1,13 @@ -/* - * Copyright 2000-2012 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-2019 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. package com.intellij.cvsSupport2.actions.merge; import com.intellij.util.containers.Stack; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; /** * @author lesya @@ -59,7 +49,7 @@ public class CvsConflictsParser { } private void parseFile(final InputStream merged) throws IOException { - final BufferedReader br = new BufferedReader(new InputStreamReader(merged)); + final BufferedReader br = new BufferedReader(new InputStreamReader(merged, StandardCharsets.UTF_8)); try { for (String line; (line = br.readLine()) != null; ) { if (!processLeftMarker(line) && !processRightMarker(line) && !processEndMarker(line)) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsMergeProvider.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsMergeProvider.java index 86f90cffc9ae..c2605e7abcfc 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsMergeProvider.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/actions/merge/CvsMergeProvider.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2019 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. package com.intellij.cvsSupport2.actions.merge; import com.intellij.cvsSupport2.CvsUtil; @@ -30,6 +16,7 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; /** * @author lesya @@ -53,9 +40,9 @@ public class CvsMergeProvider implements MergeProvider { try { final CvsConflictsParser parser = CvsConflictsParser.createOn(input); final MergeData mergeData = new MergeData(); - mergeData.ORIGINAL = parser.getCenterVersion().getBytes(); - mergeData.CURRENT = parser.getLeftVersion().getBytes(); - mergeData.LAST = parser.getRightVersion().getBytes(); + mergeData.ORIGINAL = parser.getCenterVersion().getBytes(StandardCharsets.UTF_8); + mergeData.CURRENT = parser.getLeftVersion().getBytes(StandardCharsets.UTF_8); + mergeData.LAST = parser.getRightVersion().getBytes(StandardCharsets.UTF_8); return mergeData; } finally { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/CvsApplicationLevelConfiguration.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/CvsApplicationLevelConfiguration.java index 7b6674e2258d..00bc34d9f10a 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/CvsApplicationLevelConfiguration.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/CvsApplicationLevelConfiguration.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.intellij.cvsSupport2.config; import com.intellij.openapi.components.*; @@ -16,6 +16,7 @@ import org.jetbrains.annotations.Nullable; import java.io.*; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; @@ -165,7 +166,7 @@ public class CvsApplicationLevelConfiguration implements PersistentStateComponen return; } try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(passFile))); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(passFile), StandardCharsets.UTF_8)); try { String line; while ((line = reader.readLine()) != null) { diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java index e739aa270277..44aeee197b6c 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/cvsIgnore/IgnoredFilesInfoImpl.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package com.intellij.cvsSupport2.cvsIgnore; import com.intellij.cvsSupport2.application.CvsEntriesManager; @@ -21,6 +7,7 @@ import com.intellij.openapi.vfs.VirtualFile; import org.netbeans.lib.cvsclient.util.SimpleStringPattern; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; @@ -99,7 +86,7 @@ public class IgnoredFilesInfoImpl implements IgnoredFilesInfo { if (!cvsIgnoreFile.exists()) return result; try { - BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(cvsIgnoreFile))); + BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(cvsIgnoreFile), StandardCharsets.UTF_8)); try{ String line; while((line = reader.readLine()) != null){ diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java index 691dc30b79a8..3d9fbbc30b12 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/ConnectionStreams.java @@ -19,6 +19,7 @@ import org.netbeans.lib.cvsclient.io.IStreamLogger; import org.netbeans.lib.cvsclient.util.BugLog; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.zip.Deflater; import java.util.zip.DeflaterOutputStream; import java.util.zip.InflaterInputStream; @@ -59,7 +60,7 @@ public final class ConnectionStreams @Override public Reader createReader(InputStream inputStream) { - return new InputStreamReader(inputStream); + return new InputStreamReader(inputStream, StandardCharsets.UTF_8); } @Override diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/reservedcheckout/EditCommand.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/reservedcheckout/EditCommand.java index cec4479bb932..ff8a6fa7a2f9 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/reservedcheckout/EditCommand.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/command/reservedcheckout/EditCommand.java @@ -29,6 +29,7 @@ import org.netbeans.lib.cvsclient.request.CommandRequest; import org.netbeans.lib.cvsclient.request.Requests; import java.io.IOException; +import java.nio.charset.StandardCharsets; /** * @author Thomas Singer @@ -80,7 +81,7 @@ public final class EditCommand extends AbstractCommand { if (parser.isFilesEdited()) { final String message = JavaCvsSrcBundle.message("cannot.edit.files.they.are.edited.error.message"); - eventSender.notifyMessageListeners(message.getBytes(),true, false); + eventSender.notifyMessageListeners(message.getBytes(StandardCharsets.UTF_8), true, false); return false; } diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/connection/PServerConnection.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/connection/PServerConnection.java index ea83b26f5b6f..8e2c00e4a5fa 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/connection/PServerConnection.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/connection/PServerConnection.java @@ -22,6 +22,7 @@ import org.netbeans.lib.cvsclient.util.BugLog; import java.io.*; import java.net.*; +import java.nio.charset.StandardCharsets; /** * Implements a connection to a pserver. See the cvs documents for more @@ -220,7 +221,7 @@ public final class PServerConnection private static void writeLn(final OutputStream outputStream, final String line) throws IOException { final String line1 = line + "\n"; - outputStream.write(line1.getBytes()); + outputStream.write(line1.getBytes(StandardCharsets.UTF_8)); } private void createSocket() throws IOException { diff --git a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/io/StreamUtilities.java b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/io/StreamUtilities.java index a14e170c6651..af166acc7d34 100644 --- a/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/io/StreamUtilities.java +++ b/plugins/cvs/javacvs-src/org/netbeans/lib/cvsclient/io/StreamUtilities.java @@ -15,6 +15,7 @@ package org.netbeans.lib.cvsclient.io; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; /** * @author Thomas Singer @@ -31,7 +32,7 @@ public final class StreamUtilities { if (myCharset != null) { return new String(readLineBytes(reader), myCharset); } else { - return new String(readLineBytes(reader)); + return new String(readLineBytes(reader), StandardCharsets.UTF_8); } } diff --git a/plugins/google-app-engine/source/com/intellij/appengine/sdk/impl/AppEngineSdkImpl.java b/plugins/google-app-engine/source/com/intellij/appengine/sdk/impl/AppEngineSdkImpl.java index 0589adba888e..a736773de52c 100644 --- a/plugins/google-app-engine/source/com/intellij/appengine/sdk/impl/AppEngineSdkImpl.java +++ b/plugins/google-app-engine/source/com/intellij/appengine/sdk/impl/AppEngineSdkImpl.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-2019 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. package com.intellij.appengine.sdk.impl; import com.intellij.appengine.sdk.AppEngineSdk; @@ -35,6 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jps.appengine.model.impl.JpsAppEngineModuleExtensionImpl; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.jar.Attributes; @@ -243,7 +230,7 @@ public class AppEngineSdkImpl implements AppEngineSdk { final InputStream stream = getClass().getResourceAsStream("/data/methodsBlacklist.txt"); LOG.assertTrue(stream != null, "/data/methodsBlacklist.txt not found"); final THashMap> map = new THashMap<>(); - BufferedReader reader = new BufferedReader(new InputStreamReader(stream)); + BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)); try { String line; while ((line = reader.readLine()) != null) { diff --git a/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/compiler/GradleResourceFileProcessor.java b/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/compiler/GradleResourceFileProcessor.java index 817fb590ec57..240e125d1e24 100644 --- a/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/compiler/GradleResourceFileProcessor.java +++ b/plugins/gradle/jps-plugin/src/org/jetbrains/jps/gradle/compiler/GradleResourceFileProcessor.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package org.jetbrains.jps.gradle.compiler; import com.intellij.openapi.util.Ref; @@ -32,6 +18,7 @@ import org.jetbrains.jps.model.JpsEncodingProjectConfiguration; import org.jetbrains.jps.model.JpsProject; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.List; /** @@ -94,7 +81,7 @@ public class GradleResourceFileProcessor { } private static InputStream transform(List filters, FileInputStream original, Ref outputFileRef, CompileContext context) { - final InputStreamReader streamReader = new InputStreamReader(original); + final InputStreamReader streamReader = new InputStreamReader(original, StandardCharsets.UTF_8); final Reader newReader = new ChainingFilterTransformer(context, filters, outputFileRef).transform(streamReader); return streamReader == newReader ? original : new ReaderInputStream(newReader); } diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java index 06532c69b2bf..e6a8772c400a 100644 --- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java +++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOutputParser.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2009 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-2019 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. package org.jetbrains.jps.incremental.groovy; @@ -37,6 +23,7 @@ import org.jetbrains.jps.model.library.sdk.JpsSdk; import org.jetbrains.jps.model.module.JpsModule; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -265,7 +252,7 @@ public class GroovycOutputParser { String classpath) throws IOException { File tempFile = FileUtil.createTempFile("ideaGroovyToCompile", ".txt", true); - final Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile))); + final Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempFile), StandardCharsets.UTF_8)); try { writer.write(classpath); writer.write("\n"); diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcConsole.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcConsole.java index 637276b00566..691d1cb87afb 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcConsole.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/mvc/MvcConsole.java @@ -44,6 +44,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.LinkedList; import java.util.List; import java.util.Queue; @@ -198,7 +199,7 @@ public class MvcConsole implements Disposable { final String... input) { ApplicationManager.getApplication().assertIsDispatchThread(); assert module.getProject() == myProject; - + final MyProcessInConsole process = new MyProcessInConsole(module, commandLine, onDone, showConsole, closeOnDone, input); if (isExecuting()) { myProcessQueue.add(process); @@ -241,7 +242,7 @@ public class MvcConsole implements Disposable { handler = new OSProcessHandler(commandLine); @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") - OutputStreamWriter writer = new OutputStreamWriter(handler.getProcess().getOutputStream()); + OutputStreamWriter writer = new OutputStreamWriter(handler.getProcess().getOutputStream(), StandardCharsets.UTF_8); for (String s : input) { writer.write(s); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptCommandExecutor.java index d981e3716ffb..baea4357c3fc 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptCommandExecutor.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgPromptCommandExecutor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package org.zmlx.hg4idea.execution; import com.intellij.openapi.project.Project; @@ -14,6 +14,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.net.Socket; +import java.nio.charset.StandardCharsets; import java.util.List; public class HgPromptCommandExecutor extends HgCommandExecutor { @@ -67,11 +68,11 @@ public class HgPromptCommandExecutor extends HgCommandExecutor { //noinspection IOResourceOpenedButNotSafelyClosed DataInputStream dataInput = new DataInputStream(socket.getInputStream()); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); - final String message = new String(readDataBlock(dataInput)); + final String message = new String(readDataBlock(dataInput), StandardCharsets.UTF_8); int numOfChoices = dataInput.readInt(); final HgPromptChoice[] choices = new HgPromptChoice[numOfChoices]; for (int i = 0; i < numOfChoices; i++) { - String choice = new String(readDataBlock(dataInput)); + String choice = new String(readDataBlock(dataInput), StandardCharsets.UTF_8); choices[i] = new HgPromptChoice(i, choice); } int defaultChoiceInt = dataInput.readInt(); diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgRemoteCommandExecutor.java b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgRemoteCommandExecutor.java index 7e133e22bbc5..62fb4464b9c1 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgRemoteCommandExecutor.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/execution/HgRemoteCommandExecutor.java @@ -25,6 +25,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.Socket; +import java.nio.charset.StandardCharsets; import java.util.List; public class HgRemoteCommandExecutor extends HgCommandExecutor { @@ -128,18 +129,18 @@ public class HgRemoteCommandExecutor extends HgCommandExecutor { DataInputStream dataInputStream = new DataInputStream(socket.getInputStream()); DataOutputStream out = new DataOutputStream(socket.getOutputStream()); - String command = new String(readDataBlock(dataInputStream)); + String command = new String(readDataBlock(dataInputStream), StandardCharsets.UTF_8); assert "getpass".equals(command) : "Invalid command: " + command; - String uri = new String(readDataBlock(dataInputStream)); - String path = new String(readDataBlock(dataInputStream)); - String proposedLogin = new String(readDataBlock(dataInputStream)); + String uri = new String(readDataBlock(dataInputStream), StandardCharsets.UTF_8); + String path = new String(readDataBlock(dataInputStream), StandardCharsets.UTF_8); + String proposedLogin = new String(readDataBlock(dataInputStream), StandardCharsets.UTF_8); HgCommandAuthenticator authenticator = new HgCommandAuthenticator(myForceAuthorization, mySilentMode); boolean ok = authenticator.promptForAuthentication(myProject, proposedLogin, uri, path, myState); if (ok) { myAuthenticator = authenticator; - sendDataBlock(out, authenticator.getUserName().getBytes()); - sendDataBlock(out, authenticator.getPassword().getBytes()); + sendDataBlock(out, authenticator.getUserName().getBytes(StandardCharsets.UTF_8)); + sendDataBlock(out, authenticator.getPassword().getBytes(StandardCharsets.UTF_8)); } return true; } diff --git a/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java b/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java index c6116e134011..e0ae0c8caab3 100644 --- a/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.java +++ b/plugins/hg4idea/testSrc/hg4idea/test/HgEncodingTest.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-2019 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. package hg4idea.test; import com.intellij.openapi.vcs.VcsException; @@ -27,6 +13,7 @@ import org.zmlx.hg4idea.repo.HgRepositoryImpl; import org.zmlx.hg4idea.util.HgEncodingUtil; import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.List; import static com.intellij.openapi.vcs.Executor.cd; @@ -62,6 +49,6 @@ public class HgEncodingTest extends HgPlatformTest { assert file != null; List revisions = logCommand.execute(new HgFile(myProject, file), 1, false); HgFileRevision rev = revisions.get(0); - assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage()); + assertEquals(new String(comment.getBytes(charset), StandardCharsets.UTF_8), rev.getCommitMessage()); } } diff --git a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxGenerateDefaultPropertyValuesScript.java b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxGenerateDefaultPropertyValuesScript.java index 4ff95624ef9c..b95817f7d165 100644 --- a/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxGenerateDefaultPropertyValuesScript.java +++ b/plugins/javaFX/javaFX-CE/testSrc/org/jetbrains/plugins/javaFX/fxml/JavaFxGenerateDefaultPropertyValuesScript.java @@ -1,3 +1,4 @@ +// Copyright 2000-2019 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. package org.jetbrains.plugins.javaFX.fxml; import javafx.application.Application; @@ -21,6 +22,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.*; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -496,7 +498,7 @@ public class JavaFxGenerateDefaultPropertyValuesScript extends Application { StringBuilder text = new StringBuilder(); int len; while ((len = zip.read(buffer)) > 0) { - String str = new String(buffer, 0, len); + String str = new String(buffer, 0, len, StandardCharsets.UTF_8); text.append(str); } String[] lines = text.toString().split("\n"); diff --git a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java index 2b3cec1bfe31..50b5931cdaf3 100644 --- a/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java +++ b/plugins/junit/test/com/intellij/execution/junit/JUnitTreeByDescriptionHierarchyTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.intellij.execution.junit; import com.intellij.junit4.JUnit4TestListener; @@ -27,6 +13,7 @@ import org.junit.runner.notification.Failure; import java.io.OutputStream; import java.io.PrintStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -128,7 +115,7 @@ public class JUnitTreeByDescriptionHierarchyTest { final StringBuffer buf = new StringBuffer(); JUnit4TestListener sender = createListener(buf); - + sender.testRunStarted(root); for (Description test : tests) { sender.testStarted(test); @@ -223,7 +210,7 @@ public class JUnitTreeByDescriptionHierarchyTest { "\n" + "##teamcity[testSuiteFinished name='|[1|]']\n"); } - + @Test public void testParameterizedClassWithSameParameters() throws Exception { final String className = "a.TestA"; @@ -393,7 +380,7 @@ public class JUnitTreeByDescriptionHierarchyTest { root.addChild(testA); final Description testName = Description.createTestDescription("TestA", "testName"); testA.addChild(testName); - + final Description testB = Description.createSuiteDescription("TestB"); root.addChild(testB); final Description testNameB = Description.createTestDescription("TestB", "testNameB"); @@ -604,7 +591,7 @@ public class JUnitTreeByDescriptionHierarchyTest { "\n" + "##teamcity[testSuiteFinished name='TestA']\n", StringUtil.convertLineSeparators(buf.toString())); } - + @Test public void testTearDownClassFailureSingleClass() throws Exception { final Description testA = Description.createSuiteDescription("TestA"); @@ -697,7 +684,7 @@ public class JUnitTreeByDescriptionHierarchyTest { Assert.assertEquals("output: " + buf, "##teamcity[rootName name = 'root' location = 'java:suite://root']\n" + "\n" + "##teamcity[testIgnored name='TestA.testName' error='true' message='' details='java.lang.Exception|n']\n", StringUtil.convertLineSeparators(buf.toString())); - + } @Test @@ -826,7 +813,7 @@ public class JUnitTreeByDescriptionHierarchyTest { final StringBuffer buf = new StringBuffer(); final JUnit4TestListener sender = createListener(buf); - + sender.testRunStarted(root); for (Description test : tests) { sender.testStarted(test); @@ -857,7 +844,7 @@ public class JUnitTreeByDescriptionHierarchyTest { return new JUnit4TestListener(new PrintStream(new OutputStream() { @Override public void write(int b) { - buf.append(new String(new byte[]{(byte)b})); + buf.append(new String(new byte[]{(byte)b}, StandardCharsets.UTF_8)); } })) { @Override @@ -984,7 +971,7 @@ public class JUnitTreeByDescriptionHierarchyTest { param1.addChild(testDescription); } } - + private static void doTest(Description description, String expected) { final StringBuffer buf = new StringBuffer(); createListener(buf).sendTree(description); diff --git a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenResourceFileProcessor.java b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenResourceFileProcessor.java index caec4fcfc5f9..f23bc0f7dbe2 100644 --- a/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenResourceFileProcessor.java +++ b/plugins/maven/jps-plugin/src/org/jetbrains/jps/maven/compiler/MavenResourceFileProcessor.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package org.jetbrains.jps.maven.compiler; import com.intellij.openapi.util.io.FileUtil; @@ -32,6 +18,7 @@ import org.jetbrains.jps.model.JpsEncodingProjectConfiguration; import org.jetbrains.jps.model.JpsProject; import java.io.*; +import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; @@ -97,7 +84,7 @@ public class MavenResourceFileProcessor { } try { final byte[] bytes = FileUtil.loadFileBytes(file); - final String text = encoding != null? new String(bytes, encoding) : new String(bytes); + final String text = encoding != null? new String(bytes, encoding) : new String(bytes, StandardCharsets.UTF_8); doFilterText(text, getDelimitersPattern(), getProperties(), null, writer); } finally { diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java index 96e6711e7e5a..31caba992a39 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/execution/MavenExternalParameters.java @@ -65,6 +65,7 @@ import org.jetbrains.idea.maven.utils.MavenUtil; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; import static org.jetbrains.idea.maven.server.MavenServerManager.verifyMavenSdkRequirements; @@ -187,7 +188,7 @@ public class MavenExternalParameters { Scanner sc = new Scanner(originalConf); try { - BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dest))); + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dest), StandardCharsets.UTF_8)); try { boolean patched = false; diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenPropertiesVirtualFile.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenPropertiesVirtualFile.java index 4cc670f037c4..0cecd17ee614 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenPropertiesVirtualFile.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/vfs/MavenPropertiesVirtualFile.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package org.jetbrains.idea.maven.vfs; import com.intellij.openapi.util.text.StringUtil; @@ -24,6 +10,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Properties; import java.util.Set; @@ -50,7 +37,7 @@ public class MavenPropertiesVirtualFile extends VirtualFile { builder.append(StringUtil.escapeProperty(properties.getProperty(each), false)); builder.append("\n"); } - return builder.toString().getBytes(); + return builder.toString().getBytes(StandardCharsets.UTF_8); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java index ab02d7bfa33a..7a8888d47162 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/project/MavenProjectReaderTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package org.jetbrains.idea.maven.project; import com.intellij.openapi.application.WriteAction; @@ -80,7 +66,8 @@ public class MavenProjectReaderTest extends MavenTestCase { assertProblems(readProject(myProjectPom, new NullProjectLocator())); - createProjectPom("a" + new String(new byte[]{0x0}) + "a"); + createProjectPom("a" + new String(new byte[]{0x0}, StandardCharsets.UTF_8) + "a"); MavenProjectReaderResult result = readProject(myProjectPom, new NullProjectLocator()); assertProblems(result, "'pom.xml' has syntax errors"); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java index 0642b4bfcecd..44208dd55587 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/commandLine/CommandExecutor.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package org.jetbrains.idea.svn.commandLine; import com.intellij.execution.ExecutionException; @@ -25,6 +25,7 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; @@ -116,7 +117,7 @@ public class CommandExecutor { beforeCreateProcess(); myProcess = createProcess(); myHandler = createProcessHandler(); - myProcessWriter = new OutputStreamWriter(myHandler.getProcessInput()); + myProcessWriter = new OutputStreamWriter(myHandler.getProcessInput(), StandardCharsets.UTF_8); startHandlingStreams(); } catch (ExecutionException e) { diff --git a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java index db7bfb3fd12a..ee27ce69d2e8 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java +++ b/plugins/testng/src/com/theoryinpractice/testng/configuration/SearchingForTestsTask.java @@ -63,7 +63,7 @@ public class SearchingForTestsTask extends SearchForTestsTask { } try { - FileUtil.writeToFile(myTempFile, "end".getBytes(), true); + FileUtil.writeToFile(myTempFile, "end".getBytes(StandardCharsets.UTF_8), true); } catch (IOException e) { LOG.error(e); @@ -80,7 +80,7 @@ public class SearchingForTestsTask extends SearchForTestsTask { protected void logCantRunException(ExecutionException e) { try { final String message = "CantRunException" + e.getMessage() + "\n"; - FileUtil.writeToFile(myTempFile, message.getBytes()); + FileUtil.writeToFile(myTempFile, message.getBytes(StandardCharsets.UTF_8)); } catch (IOException e1) { LOG.error(e1); @@ -118,7 +118,7 @@ public class SearchingForTestsTask extends SearchForTestsTask { int logLevel = 1; try { final Properties properties = new Properties(); - properties.load(new ByteArrayInputStream(myConfig.getVMParameters().getBytes())); + properties.load(new ByteArrayInputStream(myConfig.getVMParameters().getBytes(StandardCharsets.UTF_8))); final String verbose = properties.getProperty("-Dtestng.verbose"); if (verbose != null) { logLevel = Integer.parseInt(verbose); diff --git a/plugins/testng/testSources/com/theoryinpractice/testng/configuration/TestNGTreeHierarchyTest.java b/plugins/testng/testSources/com/theoryinpractice/testng/configuration/TestNGTreeHierarchyTest.java index 337fcf101ea6..dded3b3b8650 100644 --- a/plugins/testng/testSources/com/theoryinpractice/testng/configuration/TestNGTreeHierarchyTest.java +++ b/plugins/testng/testSources/com/theoryinpractice/testng/configuration/TestNGTreeHierarchyTest.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 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-2019 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. package com.theoryinpractice.testng.configuration; import com.intellij.openapi.util.text.StringUtil; @@ -30,12 +16,13 @@ import org.testng.xml.XmlTest; import java.io.OutputStream; import java.io.PrintStream; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Collections; import java.util.List; public class TestNGTreeHierarchyTest { - + @Test public void testOneTestMethod() { final XmlSuite suite = new XmlSuite(); @@ -44,7 +31,7 @@ public class TestNGTreeHierarchyTest { xmlClass.getIncludedMethods().add(new XmlInclude("test1")); test.getClasses().add(xmlClass); suite.getTests().add(test); - + doTest(suite,"##teamcity[enteredTheMatrix]\n" + "\n" + "##teamcity[testSuiteStarted name ='ATest' locationHint = 'java:suite://a.ATest']\n" + @@ -276,7 +263,7 @@ public class TestNGTreeHierarchyTest { "##teamcity[testFinished name='ATest.setUp']\n" + "##teamcity[testSuiteFinished name='a.ATest']\n", StringUtil.convertLineSeparators(buf.toString())); } - + @Test public void testAfterMethodWithInjectedTestResult() { final StringBuffer buf = new StringBuffer(); @@ -384,7 +371,7 @@ public class TestNGTreeHierarchyTest { return new IDEATestNGRemoteListener(new PrintStream(new OutputStream() { @Override public void write(int b) { - buf.append(new String(new byte[]{(byte)b})); + buf.append(new String(new byte[]{(byte)b}, StandardCharsets.UTF_8)); } })) { @Override diff --git a/python/pydevSrc/com/jetbrains/python/debugger/PydevXmlUtils.java b/python/pydevSrc/com/jetbrains/python/debugger/PydevXmlUtils.java index 347615ac69c2..1d10556f198d 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-2018 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-2019 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. package com.jetbrains.python.debugger; import com.jetbrains.python.console.pydev.AbstractPyCodeCompletion; @@ -13,6 +13,7 @@ import javax.xml.parsers.SAXParserFactory; import java.io.ByteArrayInputStream; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -139,7 +140,7 @@ public class PydevXmlUtils { public static List xmlToCompletions(String payload, String actionToken) throws Exception { SAXParser parser = getSAXParser(); XMLToCompletionsInfo info = new XMLToCompletionsInfo(); - parser.parse(new ByteArrayInputStream(payload.getBytes()), info); + parser.parse(new ByteArrayInputStream(payload.getBytes(StandardCharsets.UTF_8)), info); return decodeCompletions(info.getCompletions(), actionToken); } } diff --git a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibUtil.java b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibUtil.java index d1c4f7637c08..e019f7e58650 100644 --- a/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibUtil.java +++ b/python/src/com/jetbrains/python/codeInsight/stdlib/PyStdlibUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package com.jetbrains.python.codeInsight.stdlib; import com.intellij.openapi.diagnostic.Logger; @@ -23,6 +9,7 @@ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -46,7 +33,7 @@ public class PyStdlibUtil { final Logger log = Logger.getInstance(PyStdlibUtil.class.getName()); final String helperPath = PythonHelpersLocator.getHelperPath("/tools/stdlib_packages.txt"); try { - final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(helperPath))); + final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(helperPath), StandardCharsets.UTF_8)); try { final Set result = new HashSet<>(); String line; diff --git a/python/src/com/jetbrains/python/debugger/PySignatureCacheManagerImpl.java b/python/src/com/jetbrains/python/debugger/PySignatureCacheManagerImpl.java index 0587c5e6c379..534fd24e9da1 100644 --- a/python/src/com/jetbrains/python/debugger/PySignatureCacheManagerImpl.java +++ b/python/src/com/jetbrains/python/debugger/PySignatureCacheManagerImpl.java @@ -1,4 +1,4 @@ -// Copyright 2000-2018 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-2019 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. package com.jetbrains.python.debugger; import com.google.common.cache.CacheBuilder; @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -119,7 +120,7 @@ public class PySignatureCacheManagerImpl extends PySignatureCacheManager { private static void writeAttributeToAFile(@NotNull VirtualFile file, @NotNull String attrString) { try { - CALL_SIGNATURES_ATTRIBUTE.writeAttributeBytes(file, attrString.getBytes()); + CALL_SIGNATURES_ATTRIBUTE.writeAttributeBytes(file, attrString.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { LOG.warn("Can't write attribute " + file.getCanonicalPath() + " " + attrString); @@ -206,7 +207,7 @@ public class PySignatureCacheManagerImpl extends PySignatureCacheManager { String content; if (data != null && data.length > 0) { - content = new String(data); + content = new String(data, StandardCharsets.UTF_8); } else { content = null; diff --git a/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java b/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java index f74b79d91314..efae13ba0d1d 100644 --- a/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java +++ b/python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.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-2019 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. package com.jetbrains.python.validation; import com.google.common.collect.ImmutableMap; @@ -72,6 +58,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -229,7 +216,7 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator readDependenciesTxt(String basePath, URL dependenciesTxtUrl) throws Exception { List files = new ArrayList<>(); - try (BufferedReader br = new BufferedReader(new InputStreamReader(dependenciesTxtUrl.openStream()))) { + try (BufferedReader br = new BufferedReader(new InputStreamReader(dependenciesTxtUrl.openStream(), StandardCharsets.UTF_8))) { String line; while ((line = br.readLine()) != null) { File file = new File(basePath + line); diff --git a/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java b/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java index 1ba2c4a2ac0e..7c4c8113349c 100644 --- a/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java +++ b/xml/impl/src/com/intellij/xml/actions/xmlbeans/Xsd2InstanceUtils.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2014 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-2019 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. package com.intellij.xml.actions.xmlbeans; import com.intellij.openapi.vfs.VirtualFile; @@ -38,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.io.UnsupportedEncodingException; +import java.nio.charset.StandardCharsets; import java.util.*; @@ -226,10 +213,10 @@ public class Xsd2InstanceUtils { bytes = content.getBytes(virtualFile.getCharset()); } else { try { - final String charsetName = XmlUtil.extractXmlEncodingFromProlog(content.getBytes()); - bytes = charsetName != null ? content.getBytes(charsetName) : content.getBytes(); + final String charsetName = XmlUtil.extractXmlEncodingFromProlog(content.getBytes(StandardCharsets.UTF_8)); + bytes = charsetName != null ? content.getBytes(charsetName) : content.getBytes(StandardCharsets.UTF_8); } catch (UnsupportedEncodingException e) { - bytes = content.getBytes(); + bytes = content.getBytes(StandardCharsets.UTF_8); } } diff --git a/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java b/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java index 78fdc6578fe8..014ef23392c3 100644 --- a/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java +++ b/xml/tests/src/com/intellij/xml/index/XmlSchemaIndexTest.java @@ -1,3 +1,4 @@ +// Copyright 2000-2019 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. package com.intellij.xml.index; import com.intellij.openapi.module.Module; @@ -12,6 +13,7 @@ import com.intellij.util.io.DataExternalizer; import com.intellij.xml.util.XmlUtil; import java.io.*; +import java.nio.charset.StandardCharsets; import java.util.*; /** @@ -42,7 +44,8 @@ public class XmlSchemaIndexTest extends LightCodeInsightFixtureTestCase { public void testXsdNamespaceBuilder() throws Exception { VirtualFile file = myFixture.copyFileToProject("web-app_2_5.xsd"); - final XsdNamespaceBuilder builder = XsdNamespaceBuilder.computeNamespace(new InputStreamReader(file.getInputStream())); + final XsdNamespaceBuilder builder = XsdNamespaceBuilder.computeNamespace(new InputStreamReader(file.getInputStream(), + StandardCharsets.UTF_8)); assertEquals(NS, builder.getNamespace()); assertEquals("2.5", builder.getVersion()); assertEquals(Collections.singletonList("web-app"), builder.getTags()); @@ -50,7 +53,8 @@ public class XmlSchemaIndexTest extends LightCodeInsightFixtureTestCase { public void testRootTags() throws Exception { VirtualFile file = myFixture.copyFileToProject("XMLSchema.xsd"); - final XsdNamespaceBuilder builder = XsdNamespaceBuilder.computeNamespace(new InputStreamReader(file.getInputStream())); + final XsdNamespaceBuilder builder = XsdNamespaceBuilder.computeNamespace(new InputStreamReader(file.getInputStream(), + StandardCharsets.UTF_8)); assertEquals(XmlUtil.XML_SCHEMA_URI, builder.getNamespace()); assertEquals("1.0", builder.getVersion()); assertEquals(Collections.singletonList("schema"), builder.getRootTags()); diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java index 6a0d6bfdd5dd..bd304e85cfef 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdComplexTypeInfoBuilder.java @@ -12,6 +12,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.util.Map; public class XsdComplexTypeInfoBuilder implements NanoXmlBuilder { @@ -26,7 +27,7 @@ public class XsdComplexTypeInfoBuilder implements NanoXmlBuilder { } public static MultiMap parse(final InputStream is) { - return parse(new InputStreamReader(is)); + return parse(new InputStreamReader(is, StandardCharsets.UTF_8)); } public static MultiMap parse(@NotNull Reader reader) { diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java index a1e80e95f322..3b85f113f840 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdNamespaceBuilder.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -24,7 +25,7 @@ import java.util.Set; */ public class XsdNamespaceBuilder implements Comparable, NanoXmlBuilder { public static String computeNamespace(final InputStream is) { - return computeNamespace(new InputStreamReader(is)).getNamespace(); + return computeNamespace(new InputStreamReader(is, StandardCharsets.UTF_8)).getNamespace(); } public static XsdNamespaceBuilder computeNamespace(@NotNull Reader reader) { diff --git a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java index e1ca5a0126f7..96d30601e55d 100644 --- a/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java +++ b/xml/xml-psi-impl/src/com/intellij/xml/index/XsdTagNameBuilder.java @@ -11,6 +11,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; @@ -20,7 +21,7 @@ import java.util.Collection; public class XsdTagNameBuilder implements NanoXmlBuilder { @NotNull public static Collection computeTagNames(final InputStream is) { - return computeTagNames(new InputStreamReader(is)); + return computeTagNames(new InputStreamReader(is, StandardCharsets.UTF_8)); } @NotNull