EA-37850 NPE
authorKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Sat, 11 Aug 2012 08:59:43 +0000 (12:59 +0400)
committerKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Sat, 11 Aug 2012 08:59:43 +0000 (12:59 +0400)
platform/platform-api/src/com/intellij/openapi/diff/FileContent.java
platform/vcs-impl/src/com/intellij/openapi/vcs/changes/actions/ShowDiffAction.java

index 84c2500233c4d57c1838f8ff853384cf3dcb43c1..409bd9bda4dec32b157092757812adf4d9b97469 100644 (file)
@@ -20,7 +20,6 @@ import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.fileEditor.FileDocumentManager;
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
 import com.intellij.openapi.fileTypes.FileType;
-import com.intellij.openapi.fileTypes.FileTypeManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
@@ -69,7 +68,7 @@ public class FileContent extends DiffContent {
     return myFile.getFileType().isBinary();
   }
 
-  public static FileContent createFromTempFile(Project project, String name, String ext, byte[] content) throws IOException {
+  public static FileContent createFromTempFile(Project project, String name, String ext, @NotNull byte[] content) throws IOException {
     final File tempFile = FileUtil.createTempFile(name, ext);
     tempFile.deleteOnExit();
     FileUtil.writeToFile(tempFile, content);
index 0b8ce1c89bde6a16433df43e00989f5bc801cee8..ca413b20ced6ebbbe018518b953831446d5401b1 100644 (file)
@@ -218,10 +218,11 @@ public class ShowDiffAction extends AnAction implements DumbAware {
                                               fileName,
                                               ArrayUtil.EMPTY_BYTE_ARRAY);
     } else {
+      byte[] content = ((BinaryContentRevision)contentRevision).getBinaryContent();
       fileContent = FileContent.createFromTempFile(project,
                                               contentRevision.getFile().getName(),
                                               contentRevision.getFile().getName(),
-                                              ((BinaryContentRevision)contentRevision).getBinaryContent());
+                                              content == null ? ArrayUtil.EMPTY_BYTE_ARRAY : content);
     }
     return fileContent;
   }