This is an automated email from the ASF dual-hosted git repository.

mthomsen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new ba64248  NIFI-5933 Stopped using sun's IOUtils. Using apahce's 
instead. NIFI-5933 Removed unused file with sun.* import NIFI-5933 Removed 
unsafe of sun.*. NIFI-5933 Added openjdk8 to test
ba64248 is described below

commit ba642485ccad9775d5b04e94e5e7c144e93691df
Author: Tomer Ghelber <[email protected]>
AuthorDate: Sat Dec 22 17:06:40 2018 +0200

    NIFI-5933 Stopped using sun's IOUtils. Using apahce's instead.
    NIFI-5933 Removed unused file with sun.* import
    NIFI-5933 Removed unsafe of sun.*.
    NIFI-5933 Added openjdk8 to test
    
    This closes #3234
    
    Signed-off-by: Mike Thomsen <[email protected]>
---
 .travis.yml                                        |   1 +
 .../nifi-avro-record-utils/pom.xml                 |   5 +
 .../schema/access/InferenceSchemaStrategy.java     |   4 +-
 .../java/org/apache/nifi/hbase/util/Bytes.java     | 172 ++++++++-------------
 .../nifi/processors/kafka/pubsub/TestUtils.java    |  45 ------
 5 files changed, 76 insertions(+), 151 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 05351b5..5ea61fd 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,6 +25,7 @@ os:
 
 jdk:
   - oraclejdk8
+  - openjdk8
 
 # Caches mvn repository in order to speed upbuilds
 cache:
diff --git 
a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/pom.xml
 
b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/pom.xml
index 3da535a..2dee6de 100755
--- 
a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/pom.xml
+++ 
b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/pom.xml
@@ -35,6 +35,11 @@
             <version>1.8.1</version>
         </dependency>
         <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
             <groupId>com.github.ben-manes.caffeine</groupId>
             <artifactId>caffeine</artifactId>
             <version>2.6.2</version>
diff --git 
a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/schema/access/InferenceSchemaStrategy.java
 
b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/schema/access/InferenceSchemaStrategy.java
index 6cfd35d..1b80886 100644
--- 
a/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/schema/access/InferenceSchemaStrategy.java
+++ 
b/nifi-nar-bundles/nifi-extension-utils/nifi-record-utils/nifi-avro-record-utils/src/main/java/org/apache/nifi/schema/access/InferenceSchemaStrategy.java
@@ -23,7 +23,7 @@ import org.apache.nifi.serialization.record.RecordFieldType;
 import org.apache.nifi.serialization.record.RecordSchema;
 import org.apache.nifi.serialization.record.type.RecordDataType;
 import org.codehaus.jackson.map.ObjectMapper;
-import sun.misc.IOUtils;
+import org.apache.commons.io.IOUtils;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -39,7 +39,7 @@ public class InferenceSchemaStrategy implements 
JsonSchemaAccessStrategy {
 
     @Override
     public RecordSchema getSchema(Map<String, String> variables, InputStream 
contentStream, RecordSchema readSchema) throws SchemaNotFoundException, 
IOException {
-        byte[] bytes = IOUtils.readFully(contentStream, -1, true);
+        byte[] bytes = IOUtils.toByteArray(contentStream);
         ObjectMapper mapper = new ObjectMapper();
 
         return convertSchema(mapper.readValue(bytes, Map.class));
diff --git 
a/nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/util/Bytes.java
 
b/nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/util/Bytes.java
index f79dfcd..2b24b6c 100644
--- 
a/nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/util/Bytes.java
+++ 
b/nifi-nar-bundles/nifi-hbase-bundle/nifi-hbase-processors/src/test/java/org/apache/nifi/hbase/util/Bytes.java
@@ -1,104 +1,68 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.hbase.util;
-
-import sun.misc.Unsafe;
-
-import java.lang.reflect.Field;
-import java.nio.ByteOrder;
-import java.nio.charset.Charset;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-
-public class Bytes {
-
-    public static String toString(byte[] b) {
-        return b == null ? null : toString(b, 0, b.length);
-    }
-
-    public static String toString(byte[] b1, String sep, byte[] b2) {
-        return toString(b1, 0, b1.length) + sep + toString(b2, 0, b2.length);
-    }
-
-    public static String toString(byte[] b, int off, int len) {
-        if (b == null) {
-            return null;
-        } else {
-            return len == 0 ? "" : new String(b, off, len, 
Charset.forName("UTF-8"));
-        }
-    }
-
-    public static long toLong(byte[] bytes) {
-        return toLong(bytes, 0, 8);
-    }
-
-    private static long toLong(byte[] bytes, int offset, int length) {
-        if (length == 8 && offset + length <= bytes.length) {
-            if (theUnsafe != null) {
-                return toLongUnsafe(bytes, offset);
-            } else {
-                long l = 0L;
-
-                for(int i = offset; i < offset + length; ++i) {
-                    l <<= 8;
-                    l ^= (long)(bytes[i] & 255);
-                }
-
-                return l;
-            }
-        } else {
-            throw explainWrongLengthOrOffset(bytes, offset, length, 8);
-        }
-    }
-
-    private static long toLongUnsafe(byte[] bytes, int offset) {
-        final boolean littleEndian = 
ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN);
-        final int BYTE_ARRAY_BASE_OFFSET = 
theUnsafe.arrayBaseOffset(byte[].class);
-
-        if (littleEndian) {
-            return Long.reverseBytes(theUnsafe.getLong(bytes,
-                    (long) offset + BYTE_ARRAY_BASE_OFFSET));
-        } else {
-            return theUnsafe.getLong(bytes,
-                    (long) offset + BYTE_ARRAY_BASE_OFFSET);
-        }
-    }
-
-    private static IllegalArgumentException explainWrongLengthOrOffset(byte[] 
bytes, int offset, int length, int expectedLength) {
-        String reason;
-        if (length != expectedLength) {
-            reason = "Wrong length: " + length + ", expected " + 
expectedLength;
-        } else {
-            reason = "offset (" + offset + ") + length (" + length + ") exceed 
the" + " capacity of the array: " + bytes.length;
-        }
-
-        return new IllegalArgumentException(reason);
-    }
-
-    private static final Unsafe theUnsafe = (Unsafe) 
AccessController.doPrivileged(new PrivilegedAction<Object>() {
-        public Object run() {
-            try {
-                Field f = Unsafe.class.getDeclaredField("theUnsafe");
-                f.setAccessible(true);
-                return f.get((Object)null);
-            } catch (NoSuchFieldException | IllegalAccessException var2) {
-                throw new Error();
-            }
-        }
-    });
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.hbase.util;
+
+import java.nio.charset.Charset;
+
+public class Bytes {
+
+    public static String toString(byte[] b) {
+        return b == null ? null : toString(b, 0, b.length);
+    }
+
+    public static String toString(byte[] b1, String sep, byte[] b2) {
+        return toString(b1, 0, b1.length) + sep + toString(b2, 0, b2.length);
+    }
+
+    public static String toString(byte[] b, int off, int len) {
+        if (b == null) {
+            return null;
+        } else {
+            return len == 0 ? "" : new String(b, off, len, 
Charset.forName("UTF-8"));
+        }
+    }
+
+    public static long toLong(byte[] bytes) {
+        return toLong(bytes, 0, 8);
+    }
+
+    private static long toLong(byte[] bytes, int offset, int length) {
+        if (length == 8 && offset + length <= bytes.length) {
+            long l = 0L;
+
+            for(int i = offset; i < offset + length; ++i) {
+                l <<= 8;
+                l ^= (long)(bytes[i] & 255);
+            }
+
+            return l;
+        } else {
+            throw explainWrongLengthOrOffset(bytes, offset, length, 8);
+        }
+    }
+
+    private static IllegalArgumentException explainWrongLengthOrOffset(byte[] 
bytes, int offset, int length, int expectedLength) {
+        String reason;
+        if (length != expectedLength) {
+            reason = "Wrong length: " + length + ", expected " + 
expectedLength;
+        } else {
+            reason = "offset (" + offset + ") + length (" + length + ") exceed 
the" + " capacity of the array: " + bytes.length;
+        }
+
+        return new IllegalArgumentException(reason);
+    }
+}
diff --git 
a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-0-10-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/TestUtils.java
 
b/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-0-10-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/TestUtils.java
deleted file mode 100644
index 819e3b7..0000000
--- 
a/nifi-nar-bundles/nifi-kafka-bundle/nifi-kafka-0-10-processors/src/test/java/org/apache/nifi/processors/kafka/pubsub/TestUtils.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.nifi.processors.kafka.pubsub;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-
-import sun.misc.Unsafe;
-
-class TestUtils {
-
-    public static void setFinalField(Field field, Object instance, Object 
newValue) throws Exception {
-        field.setAccessible(true);
-        Field modifiersField = Field.class.getDeclaredField("modifiers");
-        modifiersField.setAccessible(true);
-        modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
-
-        field.set(instance, newValue);
-    }
-
-    static Unsafe getUnsafe() {
-        try {
-            Field f = Unsafe.class.getDeclaredField("theUnsafe");
-            f.setAccessible(true);
-            return (Unsafe) f.get(null);
-        } catch (Exception e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-}

Reply via email to