serialize keys before calling append appcode/146.1675 clion/146.1671 dbe/146.1668 idea/146.1669 phpstorm/146.1670 pycharm/146.1673 pycharm/146.1677 rubymine/146.1672 webstorm/146.1678
authorMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Tue, 3 May 2016 21:35:41 +0000 (23:35 +0200)
committerMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Tue, 3 May 2016 21:35:41 +0000 (23:35 +0200)
platform/lang-impl/src/com/intellij/util/indexing/SharedIndicesData.java

index 364c07c169aa05cf819328e604daf32d2e16919b..ef7cfad99a38759c220405a1f354a44e0e1609a8 100644 (file)
@@ -351,24 +351,25 @@ public class SharedIndicesData {
 
   private static <Key, Value> void doAssociateData(int id,
                                                    final ID<Key, ?> indexId,
-                                                   final Value keys,
-                                                   final DataExternalizer<Value> externalizer,
+                                                   Value keys,
+                                                   DataExternalizer<Value> externalizer,
                                                    FileAccessorCache<Integer, IndexedState> states,
                                                    PersistentHashMap<Integer, byte[]> index)
     throws IOException {
+    final BufferExposingByteArrayOutputStream savedKeysData;
+    if (keys != null) {
+      //noinspection IOResourceOpenedButNotSafelyClosed
+      externalizer.save(new DataOutputStream(savedKeysData = new BufferExposingByteArrayOutputStream()), keys);
+    } else {
+      savedKeysData = null;
+    }
+
     FileAccessorCache.Handle<IndexedState> stateHandle = states.getIfCached(id);
 
     try {
-
       index.appendData(id, new PersistentHashMap.ValueDataAppender() {
         @Override
         public void append(DataOutput out) throws IOException {
-          BufferExposingByteArrayOutputStream savedKeysData = null;
-          if (keys != null) {
-            //noinspection IOResourceOpenedButNotSafelyClosed
-            externalizer.save(new DataOutputStream(savedKeysData = new BufferExposingByteArrayOutputStream()), keys);
-          }
-
           byte[] internalBuffer = null;
           int size = 0;
           if (savedKeysData != null) {