Fix code requiring jdk 6
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@802859 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
index 6b08431..14eae3a 100644
--- a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
+++ b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/GogoPlugin.java
@@ -215,7 +215,7 @@
throw e;
} catch (Exception e) {
e.printStackTrace();
- throw new IOException(e);
+ throw (IOException) new IOException().initCause(e);
}
new Thread(console).start();
new Thread(this).start();
diff --git a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java
index ecb9a9e..661d1f9 100644
--- a/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java
+++ b/karaf/webconsole/gogo/src/main/java/org/apache/felix/karaf/webconsole/gogo/Terminal.java
@@ -247,7 +247,15 @@
//
private int[] peek(int y0, int x0, int y1, int x1) {
- return Arrays.copyOfRange(screen, width * y0 + x0, width * (y1 - 1) + x1);
+ int from = width * y0 + x0;
+ int to = width * (y1 - 1) + x1;
+ int newLength = to - from;
+ if (newLength < 0)
+ throw new IllegalArgumentException(from + " > " + to);
+ int[] copy = new int[newLength];
+ System.arraycopy(screen, from, copy, 0,
+ Math.min(screen.length - from, newLength));
+ return copy;
}
private void poke(int y, int x, int[] s) {