summaryrefslogtreecommitdiffstats
path: root/vespajlib
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-01-07 11:38:22 +0100
committerGitHub <noreply@github.com>2020-01-07 11:38:22 +0100
commitfbea1c3b5a6020d6d5fbd5b76d1eb3e693152500 (patch)
tree24efa382235105fa1255e19cc29a75751de38c18 /vespajlib
parent03ad85915b39cadb1bc0e74b4fa6daec294a88de (diff)
parentef00c557ff5e5b33f6f9fdef83f5357201562ec1 (diff)
Merge pull request #11662 from vespa-engine/bjorncs/apache-commons-libraries-cleanup
Bjorncs/apache commons libraries cleanup
Diffstat (limited to 'vespajlib')
-rw-r--r--vespajlib/pom.xml4
-rw-r--r--vespajlib/src/main/java/com/yahoo/collections/ListMap.java13
-rw-r--r--vespajlib/src/main/java/com/yahoo/exception/ExceptionUtils.java40
-rw-r--r--vespajlib/src/main/java/com/yahoo/exception/package-info.java8
4 files changed, 58 insertions, 7 deletions
diff --git a/vespajlib/pom.xml b/vespajlib/pom.xml
index 32040785fc2..a8380e9513c 100644
--- a/vespajlib/pom.xml
+++ b/vespajlib/pom.xml
@@ -24,10 +24,6 @@
<artifactId>lz4</artifactId>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
</dependency>
diff --git a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
index 479850beb1a..86ff9eacb8e 100644
--- a/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
+++ b/vespajlib/src/main/java/com/yahoo/collections/ListMap.java
@@ -3,10 +3,14 @@ package com.yahoo.collections;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import org.apache.commons.lang.builder.ToStringBuilder;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* A map holding multiple items at each key (using ArrayList and HashMap).
@@ -140,7 +144,10 @@ public class ListMap<K, V> {
@Override
public String toString() {
- return ToStringBuilder.reflectionToString(this);
+ return "ListMap{" +
+ "frozen=" + frozen +
+ ", map=" + map +
+ '}';
}
/** Returns the number of keys in this map */
diff --git a/vespajlib/src/main/java/com/yahoo/exception/ExceptionUtils.java b/vespajlib/src/main/java/com/yahoo/exception/ExceptionUtils.java
new file mode 100644
index 00000000000..4d4a2d02a1a
--- /dev/null
+++ b/vespajlib/src/main/java/com/yahoo/exception/ExceptionUtils.java
@@ -0,0 +1,40 @@
+// Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.exception;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UncheckedIOException;
+
+/**
+ * Misc exception utility methods - replacement for Apache commons-lang's ExceptionUtils
+ *
+ * @author bjorncs
+ */
+public class ExceptionUtils {
+
+ private ExceptionUtils() {}
+
+ public static String getStackTraceAsString(Throwable throwable) {
+ try (StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter, true)) {
+ throwable.printStackTrace(printWriter);
+ return stringWriter.getBuffer().toString();
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ public static String getStackTraceRecursivelyAsString(Throwable throwable) {
+ Throwable cause = throwable;
+ try (StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter, true)) {
+ do {
+ cause.printStackTrace(printWriter);
+ } while ((cause = cause.getCause()) != null);
+ return stringWriter.getBuffer().toString();
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+}
diff --git a/vespajlib/src/main/java/com/yahoo/exception/package-info.java b/vespajlib/src/main/java/com/yahoo/exception/package-info.java
new file mode 100644
index 00000000000..8254f90651f
--- /dev/null
+++ b/vespajlib/src/main/java/com/yahoo/exception/package-info.java
@@ -0,0 +1,8 @@
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+/**
+ * @author bjorncs
+ */
+@ExportPackage
+package com.yahoo.exception;
+
+import com.yahoo.osgi.annotation.ExportPackage; \ No newline at end of file