You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2017/06/07 04:34:30 UTC
[2/4] polygene-java git commit: Do not allow Composites in @Uses.
Do not allow Composites in @Uses.
Signed-off-by: niclas <ni...@hedhman.org>
Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/002794fe
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/002794fe
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/002794fe
Branch: refs/heads/develop
Commit: 002794fed1e070cf0b0217c69067272be472ee7c
Parents: 195da9f
Author: niclas <ni...@hedhman.org>
Authored: Wed Jun 7 08:58:31 2017 +0800
Committer: niclas <ni...@hedhman.org>
Committed: Wed Jun 7 08:58:31 2017 +0800
----------------------------------------------------------------------
.../apache/polygene/runtime/composite/UsesInstance.java | 11 +++++++++++
1 file changed, 11 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/polygene-java/blob/002794fe/core/runtime/src/main/java/org/apache/polygene/runtime/composite/UsesInstance.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/UsesInstance.java b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/UsesInstance.java
index 0fc8eb3..9d9632b 100644
--- a/core/runtime/src/main/java/org/apache/polygene/runtime/composite/UsesInstance.java
+++ b/core/runtime/src/main/java/org/apache/polygene/runtime/composite/UsesInstance.java
@@ -24,6 +24,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
+import org.apache.polygene.api.common.ConstructionException;
+import org.apache.polygene.runtime.PolygeneRuntimeImpl;
/**
* JAVADOC
@@ -45,6 +47,15 @@ public final class UsesInstance
public UsesInstance use( Object... objects )
{
+ // Validate that there are no Composites in the list, since they are possibly not fully initialized yet.
+ // TODO: The reason for that is that Composites may not be fully initialized when reaching here, and the hashCode() call later will cause an NPE.
+ for( Object obj : objects )
+ {
+ if( PolygeneRuntimeImpl.isCompositeType( obj ) )
+ {
+ throw new ConstructionException( "Composites are not allowed as @Uses arguments: " + obj.toString() );
+ }
+ }
HashSet<Object> useObjects = new HashSet<>();
if( !uses.isEmpty() )
{