]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Make more robust by catching some exceptions.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 21 May 2020 19:44:04 +0000 (21:44 +0200)
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>
Thu, 21 May 2020 19:44:04 +0000 (21:44 +0200)
src/com/hughes/android/dictionary/DictionaryActivity.java
src/com/hughes/android/dictionary/engine/Dictionary.java

index 05893c07a40b6cf22b6364bb95301634fbdd0087..840f2d89ba085b0169bac448323a4fe79a3f93e8 100644 (file)
@@ -853,7 +853,10 @@ public class DictionaryActivity extends AppCompatActivity {
             @Override
             public void run() {
                 searchTextView.setThreshold(0);
-                searchTextView.showDropDown();
+                try {
+                    searchTextView.showDropDown();
+                // ignore any errors, in particular BadTokenException happens a lot
+                } catch (Exception e) {}
             }
         });
     }
index 5b209b037da3095ebc398683331746062b237f92..03984315afa7ef2921390fbbfcd14c3a91b22b30 100644 (file)
@@ -20,6 +20,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.RandomAccessFile;
+import java.nio.BufferUnderflowException;
 import java.nio.MappedByteBuffer;
 import java.nio.channels.FileChannel;
 import java.util.ArrayList;
@@ -212,6 +213,10 @@ public class Dictionary {
             // Most likely due to a Buffer.limit beyond size of file,
             // do not crash just because of a truncated dictionary file
             return getErrorDictionaryInfo(file);
+        } catch (BufferUnderflowException e) {
+            // Most likely due to a read beyond the buffer limit set,
+            // do not crash just because of a truncated or corrupt dictionary file
+            return getErrorDictionaryInfo(file);
         } finally {
             if (raf != null) {
                 try {