diff: EA-73535 - assert: FileManagerImpl.findFile

call isValid() with ReadLock
This commit is contained in:
Aleksey Pivovarov
2015-09-24 14:32:30 +03:00
parent 66129d0c98
commit b4b729fbe4
@@ -76,29 +76,30 @@ public class TwosideBinaryDiffViewer extends TwosideDiffViewer<BinaryEditorHolde
final VirtualFile file1 = ((FileContent)contents.get(0)).getFile();
final VirtualFile file2 = ((FileContent)contents.get(1)).getFile();
if (!file1.isValid() || !file2.isValid()) {
return applyNotification(DiffNotifications.createError());
}
final boolean equal = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
final JComponent notification = ApplicationManager.getApplication().runReadAction(new Computable<JComponent>() {
@Override
public Boolean compute() {
public JComponent compute() {
if (!file1.isValid() || !file2.isValid()) {
return DiffNotifications.createError();
}
try {
// we can't use getInputStream() here because we can't restore BOM marker
// (getBom() can return null for binary files, while getInputStream() strips BOM for all files).
// It can be made for files from VFS that implements FileSystemInterface though.
byte[] bytes1 = file1.contentsToByteArray();
byte[] bytes2 = file2.contentsToByteArray();
return Arrays.equals(bytes1, bytes2);
return Arrays.equals(bytes1, bytes2) ? DiffNotifications.createEqualContents() : null;
}
catch (IOException e) {
LOG.warn(e);
return false;
return null;
}
}
});
return applyNotification(equal ? DiffNotifications.createEqualContents(): null);
return applyNotification(notification);
}
catch (ProcessCanceledException e) {
throw e;