You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2014/02/09 18:50:46 UTC

git commit: CLEREZZA-876: throwing RuntimeExceptions with explanation when property is missing

Updated Branches:
  refs/heads/master ab8d5fe97 -> 764400acc


CLEREZZA-876: throwing RuntimeExceptions with explanation when property is missing

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/764400ac
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/764400ac
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/764400ac

Branch: refs/heads/master
Commit: 764400acc39826a50604df13593eae7470282c21
Parents: ab8d5fe
Author: retobg <re...@apache.org>
Authored: Sun Feb 9 18:50:26 2014 +0100
Committer: retobg <re...@apache.org>
Committed: Sun Feb 9 18:50:26 2014 +0100

----------------------------------------------------------------------
 .../clerezza/platform/content/InfoDiscobit.java      | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/764400ac/platform.content/src/main/java/org/apache/clerezza/platform/content/InfoDiscobit.java
----------------------------------------------------------------------
diff --git a/platform.content/src/main/java/org/apache/clerezza/platform/content/InfoDiscobit.java b/platform.content/src/main/java/org/apache/clerezza/platform/content/InfoDiscobit.java
index bc2323f..8693216 100644
--- a/platform.content/src/main/java/org/apache/clerezza/platform/content/InfoDiscobit.java
+++ b/platform.content/src/main/java/org/apache/clerezza/platform/content/InfoDiscobit.java
@@ -71,25 +71,30 @@ public class InfoDiscobit {
             Iterator<Literal> mediaTypeLits = infoBit.getLiterals(DISCOBITS.mediaType);
             if (mediaTypeLits.hasNext()) {
                 return mediaTypeLits.next().getLexicalForm();
+            } else {
+                throw new RuntimeException("InfoDiscobit has no media type property");
             }
         } finally {
             readLock.unlock();
         }
-        return null;
     }
     
     public byte[] getData() {
-        byte[] result = null;
+        byte[] result;
         Lock readLock = infoBit.readLock();
         readLock.lock();
         try {
-            Iterator<Literal> mediaTypeLits = infoBit.getLiterals(DISCOBITS.infoBit);
-            if (mediaTypeLits.hasNext()) {
-                final Literal literalValue = mediaTypeLits.next();
+            Iterator<Literal> infoBitLits = infoBit.getLiterals(DISCOBITS.infoBit);
+            if (infoBitLits.hasNext()) {
+                final Literal literalValue = infoBitLits.next();
                 if (literalValue instanceof TypedLiteral) {
                     result = LiteralFactory.getInstance().createObject(
                             (new byte[0]).getClass(), (TypedLiteral) literalValue);
+                } else {
+                    throw new RuntimeException("InfoDiscobit has infoBit value which is not a TypedLiteral but "+literalValue);
                 }
+            } else {
+                throw new RuntimeException("InfoDiscobit has not infoBit property");
             }
         } finally {
             readLock.unlock();