You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/01/19 16:16:05 UTC

[isis] branch master updated (282eba5 -> d1a888a)

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

ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.


    from 282eba5  ISIS-2223: revert false positive on html templates
     new 6c3b60f  ISIS-2223: polish _NullSafe.stream(final Enumeration<T> enumeration)
     new 788d8c6  ISIS-2223: Add a "NoSuchElementException" for iteration beyond the end of the collection
     new 78d4f98  ISIS-2223: add missing null guard
     new f9f8092  ISIS-2223: "InterruptedException" should not be ignored
     new d76e60d  ISIS-2223: Resources should be closed
     new eb6a278  ISIS-2223: dont redeclare field thats already in super
     new d1a888a  ISIS-2223: You cannot assume that any given stream reading call will fill the byte[] passed in to the method

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../isis/core/commons/internal/base/_NullSafe.java | 25 +++++++++++++---------
 .../internal/base/_Strings_SplitIterator.java      |  7 ++++++
 .../commons/internal/collections/_Collections.java |  3 +++
 .../internal/concurrent/_ConcurrentTaskList.java   |  5 ++++-
 .../core/commons/internal/context/_Plugin.java     | 18 +++++++++-------
 .../internal/encoding/FailedToDecodeException.java |  8 +------
 .../encoding/FailedToDeserializeException.java     |  8 +------
 .../core/commons/internal/encoding/FieldType.java  |  4 ++--
 8 files changed, 43 insertions(+), 35 deletions(-)


[isis] 02/07: ISIS-2223: Add a "NoSuchElementException" for iteration beyond the end of the collection

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 788d8c6dddcbf9c3b7fdb5b48db6b88138df088f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 16:54:09 2020 +0100

    ISIS-2223: Add a "NoSuchElementException" for iteration beyond the end
    of the collection
---
 .../isis/core/commons/internal/base/_Strings_SplitIterator.java    | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_Strings_SplitIterator.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_Strings_SplitIterator.java
index 7d03ba8..724a556 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_Strings_SplitIterator.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_Strings_SplitIterator.java
@@ -24,6 +24,8 @@ import java.util.Iterator;
 
 import javax.annotation.Nullable;
 
+import org.apache.isis.core.commons.internal.exceptions._Exceptions;
+
 /**
  *
  * package private mixin for utility class {@link _Strings}
@@ -63,6 +65,11 @@ final class _Strings_SplitIterator {
 
             @Override
             public String next() {
+                
+                if(!hasNext()) {
+                    throw _Exceptions.noSuchElement("end of string already reached");
+                }
+                
                 try {
                     return next;
                 } finally {


[isis] 05/07: ISIS-2223: Resources should be closed

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d76e60d3edce1de0f192986d298987e0be1e870b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 17:07:04 2020 +0100

    ISIS-2223: Resources should be closed
---
 .../isis/core/commons/internal/context/_Plugin.java    | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/context/_Plugin.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/context/_Plugin.java
index 9771bb8..4565a94 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/context/_Plugin.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/context/_Plugin.java
@@ -162,14 +162,16 @@ public final class _Plugin {
 
             ClassLoader parentCL = pluginInterfaceClass.getClassLoader();
             URL[] urls = {classPath.toURI().toURL()};
-            ClassLoader cl = URLClassLoader.newInstance(urls, parentCL);
-            Class<S> pluginClass = _Casts.uncheckedCast(
-                    cl.loadClass(pluginFullyQualifiedClassName));
-            S plugin = pluginClass.newInstance();
-
-            _Context.putSingleton(pluginInterfaceClass, plugin);
-
-            return plugin;
+            
+            try(URLClassLoader cl = URLClassLoader.newInstance(urls, parentCL)) {
+                Class<S> pluginClass = _Casts.uncheckedCast(
+                        cl.loadClass(pluginFullyQualifiedClassName));
+                S plugin = pluginClass.newInstance();
+
+                _Context.putSingleton(pluginInterfaceClass, plugin);
+                
+                return plugin;
+            }
 
         } catch (Exception e) {
             throw new PluginResolveException(


[isis] 04/07: ISIS-2223: "InterruptedException" should not be ignored

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f9f8092a6dc09f86bc6e941042aa26e837a4696a
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 17:04:07 2020 +0100

    ISIS-2223: "InterruptedException" should not be ignored
---
 .../isis/core/commons/internal/concurrent/_ConcurrentTaskList.java   | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/concurrent/_ConcurrentTaskList.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/concurrent/_ConcurrentTaskList.java
index 54a0429..389fc9c 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/concurrent/_ConcurrentTaskList.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/concurrent/_ConcurrentTaskList.java
@@ -124,8 +124,11 @@ public class _ConcurrentTaskList {
                     try {
                         future.get();
                         tasksExecuted.increment();
-                    } catch (InterruptedException | ExecutionException e) {
+                    } catch (ExecutionException e) {
                         // ignore, continue waiting on tasks
+                    } catch (InterruptedException e) {
+                        // Restore interrupted state...
+                        Thread.currentThread().interrupt();
                     }
                     
                 }


[isis] 07/07: ISIS-2223: You cannot assume that any given stream reading call will fill the byte[] passed in to the method

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d1a888a6e611c0a92e3012de4a83dcae14e7dc88
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 17:15:54 2020 +0100

    ISIS-2223: You cannot assume that any given stream reading call will
    fill the byte[] passed in to the method
---
 .../org/apache/isis/core/commons/internal/encoding/FieldType.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FieldType.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FieldType.java
index ec152e2..9b4ef04 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FieldType.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FieldType.java
@@ -42,7 +42,7 @@ import lombok.extern.log4j.Log4j2;
  * <p>
  * The {@link #write(DataOutputExtended, Object)} writes out field type and then
  * the data for that field type. The field type is represented by this
- * enumberation, with the {@link FieldType#getIdx() index} being what is written
+ * enumeration, with the {@link FieldType#getIdx() index} being what is written
  * to the stream (hence of type <tt>byte</tt> to keep small).
  *
  * <p>
@@ -228,7 +228,7 @@ public abstract class FieldType<T> {
         // rather than looping through the array,
         // we take advantage of optimization built into DataInputStream
         private void readBytes(final DataInputStream inputStream, final byte[] bytes) throws IOException {
-            inputStream.read(bytes);
+            inputStream.readFully(bytes);
         }
     };
 


[isis] 03/07: ISIS-2223: add missing null guard

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 78d4f98135b618db2498834af58a830fc4f85458
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 16:59:15 2020 +0100

    ISIS-2223: add missing null guard
---
 .../apache/isis/core/commons/internal/collections/_Collections.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java
index 6ae98e0..fea05ec 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/collections/_Collections.java
@@ -304,6 +304,9 @@ public final class _Collections {
      * @return inferred type or null if inference fails
      */
     public static @Nullable Class<?> inferElementTypeIfAny(@Nullable final Field field) {
+        if(field==null) {
+            return null;
+        }
         return inferElementTypeIfAny(field.getType(), field.getGenericType());
     }
 


[isis] 01/07: ISIS-2223: polish _NullSafe.stream(final Enumeration enumeration)

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6c3b60f17f18859059cd2e44238a471d29ea5035
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 16:50:31 2020 +0100

    ISIS-2223: polish _NullSafe.stream(final Enumeration<T> enumeration)
---
 .../isis/core/commons/internal/base/_NullSafe.java | 25 +++++++++++++---------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_NullSafe.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_NullSafe.java
index 39f9677..cab636f 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_NullSafe.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/base/_NullSafe.java
@@ -26,6 +26,7 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Spliterator;
 import java.util.Spliterators;
+import java.util.function.Consumer;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
@@ -124,20 +125,24 @@ public final class _NullSafe {
      */
     public static <T> Stream<T> stream(final Enumeration<T> enumeration){
         return enumeration!=null
-                ? stream(toIterator(enumeration))
+                ? StreamSupport.stream(toSpliterator(enumeration), /*parallel*/false)
                         : Stream.empty();
     }
 
-    // [ahuber] not public, since one time use of enumeration only!
-    private static <T> Iterator<T> toIterator(final Enumeration<T> e){
-        return new Iterator<T>() {
-            @Override
-            public T next() {
-                return e.nextElement();
+    // not public, used internally for stream(Enumeration) only
+    private static <T> Spliterator<T> toSpliterator(final Enumeration<T> e){
+        return new Spliterators.AbstractSpliterator<T>(Long.MAX_VALUE, Spliterator.ORDERED) {
+            public boolean tryAdvance(Consumer<? super T> action) {
+                if(e.hasMoreElements()) {
+                    action.accept(e.nextElement());
+                    return true;
+                }
+                return false;
             }
-            @Override
-            public boolean hasNext() {
-                return e.hasMoreElements();
+            public void forEachRemaining(Consumer<? super T> action) {
+                while(e.hasMoreElements()) {
+                    action.accept(e.nextElement());
+                }
             }
         };
     }


[isis] 06/07: ISIS-2223: dont redeclare field thats already in super

Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit eb6a278ffd12febbcdb961d5bf2ff3cbcf5decb4
Author: Andi Huber <ah...@apache.org>
AuthorDate: Sun Jan 19 17:10:07 2020 +0100

    ISIS-2223: dont redeclare field thats already in super
---
 .../core/commons/internal/encoding/FailedToDecodeException.java   | 8 +-------
 .../commons/internal/encoding/FailedToDeserializeException.java   | 8 +-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDecodeException.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDecodeException.java
index edaa399..373b953 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDecodeException.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDecodeException.java
@@ -28,15 +28,9 @@ public class FailedToDecodeException extends IOException {
 
     private static final long serialVersionUID = 1L;
 
-    private final Throwable cause;
-
     public FailedToDecodeException(final Throwable cause) {
-        this.cause = cause;
+        super(cause);
     }
 
-    @Override
-    public Throwable getCause() {
-        return cause;
-    }
 
 }
\ No newline at end of file
diff --git a/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDeserializeException.java b/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDeserializeException.java
index 6555be3..b10b15f 100644
--- a/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDeserializeException.java
+++ b/core/commons/src/main/java/org/apache/isis/core/commons/internal/encoding/FailedToDeserializeException.java
@@ -28,15 +28,9 @@ public class FailedToDeserializeException extends IOException {
 
     private static final long serialVersionUID = 1L;
 
-    private final Throwable cause;
-
     public FailedToDeserializeException(final ClassNotFoundException cause) {
-        this.cause = cause;
+        super(cause);
     }
 
-    @Override
-    public Throwable getCause() {
-        return cause;
-    }
 
 }
\ No newline at end of file