From 1e00b854110c444a143543d8be1e599398748a94 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 2 Nov 2015 11:45:55 -0500 Subject: [PATCH 1/3] Fix auto-generated eclipse try/catch to be less trappy When generating a try-catch block, the eclipse default is something like this: ``` try { something(); } catch (Exception e) { // TODO: auto-generated stub e.printStackTrace(); } which is terrible, so the ES eclipse changes this to rethrow a RuntimeException instead. ``` try { something(); } catch (Exception e) { throw new RuntimeException(); } ``` Unfortunately, this loses the original exception entirely, instead it should be: ``` try { something(); } catch (Exception e) { throw new RuntimeException(e); } ``` --- .../main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs index a42667f8698..c7c10803c30 100644 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs @@ -3,4 +3,4 @@ formatter_settings_version=12 # Intellij IDEA import order org.eclipse.jdt.ui.importorder=;com;org;java;javax;\#; # License header -org.eclipse.jdt.ui.text.custom_code_templates= \ No newline at end of file +org.eclipse.jdt.ui.text.custom_code_templates= From 73a136e9fc38c7df64799cc0698ae20ea838b042 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 2 Nov 2015 11:58:34 -0500 Subject: [PATCH 2/3] Use ${exception_var} for the case of nested generated try/catch --- .../main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs index c7c10803c30..391a8715868 100644 --- a/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs +++ b/buildSrc/src/main/resources/eclipse.settings/org.eclipse.jdt.ui.prefs @@ -3,4 +3,4 @@ formatter_settings_version=12 # Intellij IDEA import order org.eclipse.jdt.ui.importorder=;com;org;java;javax;\#; # License header -org.eclipse.jdt.ui.text.custom_code_templates= +org.eclipse.jdt.ui.text.custom_code_templates= From f83800b1d283fc61b65772b4dfb90832450b5ec9 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Mon, 2 Nov 2015 12:05:44 -0500 Subject: [PATCH 3/3] don't discard original exception (suspiciously/possibly eclipse-generated) --- .../org/elasticsearch/index/mapper/object/ObjectMapper.java | 2 +- .../scripts/score/script/NativeNaiveTFIDFScoreScript.java | 2 +- .../elasticsearch/common/util/concurrent/CountDownTests.java | 2 +- .../http/netty/NettyHttpServerPipeliningTests.java | 2 +- .../java/org/elasticsearch/transport/netty/KeyedLockTests.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java index fc47fc561cb..9dc1a1d3dc7 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/object/ObjectMapper.java @@ -355,7 +355,7 @@ public class ObjectMapper extends Mapper implements AllFieldMapper.IncludeInAll, try { clone = (ObjectMapper) super.clone(); } catch (CloneNotSupportedException e) { - throw new RuntimeException(); + throw new RuntimeException(e); } return clone; } diff --git a/core/src/test/java/org/elasticsearch/benchmark/scripts/score/script/NativeNaiveTFIDFScoreScript.java b/core/src/test/java/org/elasticsearch/benchmark/scripts/score/script/NativeNaiveTFIDFScoreScript.java index 9d6a1cd2f07..e96b35df96a 100644 --- a/core/src/test/java/org/elasticsearch/benchmark/scripts/score/script/NativeNaiveTFIDFScoreScript.java +++ b/core/src/test/java/org/elasticsearch/benchmark/scripts/score/script/NativeNaiveTFIDFScoreScript.java @@ -70,7 +70,7 @@ public class NativeNaiveTFIDFScoreScript extends AbstractSearchScript { score += indexFieldTerm.tf() * indexField.docCount() / indexFieldTerm.df(); } } catch (IOException e) { - throw new RuntimeException(); + throw new RuntimeException(e); } } return score; diff --git a/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java b/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java index db10addfe2e..1a32064fe7d 100644 --- a/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java +++ b/core/src/test/java/org/elasticsearch/common/util/concurrent/CountDownTests.java @@ -43,7 +43,7 @@ public class CountDownTests extends ESTestCase { try { latch.await(); } catch (InterruptedException e) { - throw new RuntimeException(); + throw new RuntimeException(e); } while (true) { if(frequently()) { diff --git a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java index 53c743d34d5..b675d29c9da 100644 --- a/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java +++ b/core/src/test/java/org/elasticsearch/http/netty/NettyHttpServerPipeliningTests.java @@ -214,7 +214,7 @@ public class NettyHttpServerPipeliningTests extends ESTestCase { Thread.sleep(timeout); } catch (InterruptedException e1) { Thread.currentThread().interrupt(); - throw new RuntimeException(); + throw new RuntimeException(e1); } } diff --git a/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java b/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java index cbac0aded0e..9581dfff42f 100644 --- a/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java +++ b/core/src/test/java/org/elasticsearch/transport/netty/KeyedLockTests.java @@ -112,7 +112,7 @@ public class KeyedLockTests extends ESTestCase { try { startLatch.await(); } catch (InterruptedException e) { - throw new RuntimeException(); + throw new RuntimeException(e); } int numRuns = scaledRandomIntBetween(5000, 50000); for (int i = 0; i < numRuns; i++) {