You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/04/07 22:22:11 UTC

[20/28] git commit: Removed the swallowing of exceptions, now throwing the proper exception. Removed some more codehaus jackson imports that were lying around.

Removed the swallowing of exceptions, now throwing the proper exception.
Removed some more codehaus jackson imports that were lying around.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a175c57c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a175c57c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a175c57c

Branch: refs/heads/two-dot-o
Commit: a175c57c852889f66aa2d237d3c9107504f3d18f
Parents: a16e6e4
Author: grey <gr...@apigee.com>
Authored: Thu Mar 20 12:06:18 2014 -0700
Committer: grey <gr...@apigee.com>
Committed: Thu Mar 20 12:06:18 2014 -0700

----------------------------------------------------------------------
 .../MvccEntitySerializationStrategyImpl.java     | 19 +++++--------------
 .../org/apache/usergrid/utils/JsonUtils.java     |  9 ---------
 2 files changed, 5 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a175c57c/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
index 4acc3ee..e06b5a8 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java
@@ -18,7 +18,6 @@
 package org.apache.usergrid.persistence.collection.serialization.impl;
 
 
-import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -44,8 +43,6 @@ import org.apache.usergrid.persistence.collection.util.EntityUtils;
 import org.apache.usergrid.persistence.model.entity.Entity;
 import org.apache.usergrid.persistence.model.entity.Id;
 
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.databind.JsonMappingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.dataformat.smile.SmileFactory;
 import com.google.common.base.Optional;
@@ -293,7 +290,6 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
         //the marker for when we're passed a "null" value
         private static final byte[] EMPTY = new byte[] { 0x0 };
 
-//TODO:Make sure your exceptions provide descriptive error messages.
         @Override
         public ByteBuffer toByteBuffer( final EntityWrapper wrapper ) {
             if ( wrapper == null ) {
@@ -324,14 +320,8 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
             try {
                 builder.addBytes( mapper.writeValueAsBytes( wrapper.entity.get() ) );
             }
-            catch ( JsonMappingException e ) {
-                e.printStackTrace();
-            }
-            catch ( JsonGenerationException e ) {
-                e.printStackTrace();
-            }
-            catch ( IOException e ) {
-                e.printStackTrace();
+            catch ( Exception e ) {
+                throw new CollectionRuntimeException(e.getMessage());
             }
 
             return builder.build();
@@ -365,10 +355,11 @@ public class MvccEntitySerializationStrategyImpl implements MvccEntitySerializat
                 byte[] array = jsonBytes.array();
                 int start = jsonBytes.arrayOffset();
                 int length = jsonBytes.remaining();
+
                 storedEntity = mapper.readValue( array,start,length,Entity.class);
             }
-            catch ( IOException e ) {
-                e.printStackTrace();
+            catch ( Exception e ) {
+                throw new CollectionRuntimeException(e.getMessage());
             }
 
             final Optional<Entity> entity = Optional.of( storedEntity );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a175c57c/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java
index 5b5e2a5..491ca50 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/utils/JsonUtils.java
@@ -35,15 +35,6 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.dataformat.smile.SmileFactory;
 
-//import org.apache.usergrid.persistence.Entity;
-//import org.codehaus.jackson.JsonNode;
-//import org.codehaus.jackson.io.JsonStringEncoder;
-//import org.codehaus.jackson.map.ObjectMapper;
-//import org.codehaus.jackson.map.SerializationConfig.Feature;
-//import org.codehaus.jackson.smile.SmileFactory;
-//import com.fasterxml.jackson.
-
-
 public class JsonUtils {
 
     private static final Logger LOG = LoggerFactory.getLogger( JsonUtils.class );