lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r912375 - in /lucene/java/branches/lucene_3_0_back_compat_tests: ./ contrib/ contrib/highlighter/src/test/ src/java/org/apache/lucene/search/ src/test/org/apache/lucene/analysis/ src/test/org/apache/lucene/document/ src/test/org/apache/luce...
Date Sun, 21 Feb 2010 17:21:16 GMT
Author: uschindler
Date: Sun Feb 21 17:21:15 2010
New Revision: 912375

URL: http://svn.apache.org/viewvc?rev=912375&view=rev
Log:
LUCENE-2274: Backwards-branch: Add support for uncaught exceptions in threads

Modified:
    lucene/java/branches/lucene_3_0_back_compat_tests/   (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/contrib/   (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/contrib/CHANGES.txt   (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/contrib/highlighter/src/test/   (props
changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
  (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/document/TestDateTools.java
  (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/document/TestNumberTools.java
  (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
  (props changed)
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/LuceneTestCase.java
    lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java
  (props changed)

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests:818601-821336
 /lucene/java/branches/lucene_3_0:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/CHANGES.txt:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/CHANGES.txt:818601-821336
 /lucene/java/branches/lucene_3_0/CHANGES.txt:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/CHANGES.txt:881213,881315,881466,881819,882374,882464,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/CHANGES.txt:881213,881315,881466,881819,882374,882464,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/contrib:817269-818600,825998,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib:818601-821336
 /lucene/java/branches/lucene_3_0/contrib:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/contrib:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/contrib/CHANGES.txt
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/contrib/CHANGES.txt:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/CHANGES.txt:818601-821336
 /lucene/java/branches/lucene_3_0/contrib/CHANGES.txt:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/contrib/CHANGES.txt:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/contrib/highlighter/src/test/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/contrib/highlighter/src/test:817269-818600,825998,826775,829134,829816,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/contrib/highlighter/src/test:818601-821336
 /lucene/java/branches/lucene_3_0/contrib/highlighter/src/test:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/contrib/highlighter/src/test:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:818601-821336
 /lucene/java/branches/lucene_3_0/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881819,881984,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/src/java/org/apache/lucene/search/MultiTermQueryWrapperFilter.java:881213,881315,881466,881819,881984,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:825998,829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/document/TestDateTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestDateTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestDateTools.java:825998,829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestDateTools.java:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestDateTools.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/document/TestNumberTools.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/document/TestNumberTools.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/document/TestNumberTools.java:825998,829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/document/TestNumberTools.java:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/src/test/org/apache/lucene/document/TestNumberTools.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -1,4 +1,4 @@
 /lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:748824
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:825998,829134,829881,831036
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335
+/lucene/java/trunk/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,885214,912319,912324,912328,912335,912372

Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java?rev=912375&r1=912374&r2=912375&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
(original)
+++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/index/TestNRTReaderWithThreads.java
Sun Feb 21 17:21:15 2010
@@ -54,13 +54,16 @@
     int addCount = 0;
     for (int x=0; x < indexThreads.length; x++) {
       indexThreads[x].run = false;
-      assertTrue(indexThreads[x].ex == null);
+      assertNull("Exception thrown: "+indexThreads[x].ex, indexThreads[x].ex);
       addCount += indexThreads[x].addCount;
       delCount += indexThreads[x].delCount;
     }
     for (int x=0; x < indexThreads.length; x++) {
       indexThreads[x].join();
     }
+    for (int x=0; x < indexThreads.length; x++) {
+      assertNull("Exception thrown: "+indexThreads[x].ex, indexThreads[x].ex);
+    }
     //System.out.println("addCount:"+addCount);
     //System.out.println("delCount:"+delCount);
     writer.close();
@@ -69,8 +72,8 @@
 
   public class RunThread extends Thread {
     IndexWriter writer;
-    boolean run = true;
-    Throwable ex;
+    volatile boolean run = true;
+    volatile Throwable ex;
     int delCount = 0;
     int addCount = 0;
     int type;

Modified: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/LuceneTestCase.java?rev=912375&r1=912374&r2=912375&view=diff
==============================================================================
--- lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/LuceneTestCase.java
(original)
+++ lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/LuceneTestCase.java
Sun Feb 21 17:21:15 2010
@@ -21,6 +21,9 @@
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Random;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collections;
 
 import junit.framework.TestCase;
 
@@ -52,6 +55,20 @@
 
 
   private int savedBoolMaxClauseCount;
+  
+  private volatile Thread.UncaughtExceptionHandler savedUncaughtExceptionHandler = null;
+  
+  private static class UncaughtExceptionEntry {
+    public final Thread thread;
+    public final Throwable exception;
+    
+    public UncaughtExceptionEntry(Thread thread, Throwable exception) {
+      this.thread = thread;
+      this.exception = exception;
+    }
+  }
+  private List<UncaughtExceptionEntry> uncaughtExceptions = Collections.synchronizedList(new
ArrayList<UncaughtExceptionEntry>());
+
   public LuceneTestCase() {
     super();
   }
@@ -63,6 +80,16 @@
   @Override
   protected void setUp() throws Exception {
     super.setUp();
+    
+    savedUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
+    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+      public void uncaughtException(Thread t, Throwable e) {
+        uncaughtExceptions.add(new UncaughtExceptionEntry(t, e));
+        if (savedUncaughtExceptionHandler != null)
+          savedUncaughtExceptionHandler.uncaughtException(t, e);
+      }
+    });
+    
     ConcurrentMergeScheduler.setTestMode();
     savedBoolMaxClauseCount = BooleanQuery.getMaxClauseCount();
   }
@@ -105,6 +132,16 @@
       purgeFieldCache(FieldCache.DEFAULT);
     }
     
+    Thread.setDefaultUncaughtExceptionHandler(savedUncaughtExceptionHandler);
+    if (!uncaughtExceptions.isEmpty()) {
+      System.err.println("The following exceptions were thrown by threads:");
+      for (UncaughtExceptionEntry entry : uncaughtExceptions) {
+        System.err.println("*** Thread: " + entry.thread.getName() + " ***");
+        entry.exception.printStackTrace(System.err);
+      }
+      fail("Some threads throwed uncaught exceptions!");
+    }
+    
     super.tearDown();
   }
 

Propchange: lucene/java/branches/lucene_3_0_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Feb 21 17:21:15 2010
@@ -2,4 +2,4 @@
 /lucene/java/branches/lucene_2_9/src/test/org/apache/lucene/util/TestAttributeSource.java:817269-818600,825998,829134,829881,831036
 /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/util/TestAttributeSource.java:818601-821336
 /lucene/java/branches/lucene_3_0/src/test/org/apache/lucene/util/TestAttributeSource.java:880754,880793,880823,881216,881317,881376,881473,881549,881820,882467,882890,883076,883080
-/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,883079,885214,912319,912324,912328,912335
+/lucene/java/trunk/src/test/org/apache/lucene/util/TestAttributeSource.java:881213,881315,881466,881819,882374,882807,882888,882977,883074-883075,883079,885214,912319,912324,912328,912335,912372



Mime
View raw message