From ca23ee2ef6f007954b831101b0b5e2ef89fcf056 Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Wed, 1 Mar 2017 18:23:44 +0300 Subject: [PATCH] EA-97992 - assert: VirtualFile.setBinaryContent --- .../openapi/editor/actions/RemoveBomAction.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java index 6b5ec1d2ef02..f6ea4c016841 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/RemoveBomAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * 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. @@ -18,9 +18,10 @@ package com.intellij.openapi.editor.actions; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.PlatformDataKeys; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.DumbAware; +import com.intellij.openapi.util.ThrowableComputable; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; @@ -62,7 +63,13 @@ public class RemoveBomAction extends AnAction implements DumbAware { byte[] bytes = file.contentsToByteArray(); byte[] contentWithStrippedBom = new byte[bytes.length - bom.length]; System.arraycopy(bytes, bom.length, contentWithStrippedBom, 0, contentWithStrippedBom.length); - file.setBinaryContent(contentWithStrippedBom); + ApplicationManager.getApplication().runWriteAction(new ThrowableComputable() { + @Override + public Void compute() throws IOException { + file.setBinaryContent(contentWithStrippedBom); + return null; + } + }); } catch (IOException ex) { LOG.warn("Unexpected exception occurred on attempt to remove BOM from file " + file, ex);